[Xiaomi Mi 5 Guides, News, & Discussion] ianhughes74:
*This module also works for any another device with Qualcomm Snapdragon chipset based, so feel free to test it on another device that have Magisk and recommend for your friends that want a better GPS experience and functionality.

The original gps.conf file present in any version of MIUI is very wrong, it has a lot of bad information and settings for the correct operation of the GPS and A-GPS. But on most Custom ROMs it was solved, however, I believe the changes I've made for a better optimization has the best results.

A little reflection tested and proven by myself: If you have a nice FW version with wrong gps.conf you won't have good results with the GPS, but if you have any FW version with gps.conf file correctly edited, maybe you might get better results.

Then we can finally conclude that, the Xiaomi Mi5 don't have any HW problem with GPS. What happens is that the firmware works in conjunction with the file.

There's not much difference with the default file included in LOS or other ROMs but let me explain about some of my relevant changes:

1 - Now basically the A-GPS data files are XTRA 3.0 files (It provides GPS, GLO and BDS assistance data) served over HTTPS with SSL and without # preceding the address lines while the default on MIUI ROMs was XTRA 2.0 (provides only GPS and GLO) served over HTTP without SSL, this allows an attacker to mount a MITM attack on the network level and modify the GPS assistance data while in transit.

2 - I switched the XTRA_VERSION_CHECK from 0 to 3 because it's obvious that xtra3grc.bin are XTRA 3.0 files.

3 - I included the address servers from pool.ntp.org as the main NTP server because it's global, the system will try finding the closest available servers for you

4 - I set SUPL_HOST google.com as default, before was qxwz.com on MIUI and this is an A-GPS server in China. Google server is more "Global" and can do the job very well.

5 - I updated the SUPL version from 2.0 to 3.0

6 - I changed the SUPL_MODE from 3 (so bad, this option doesn't even exist) to 0x2 (MSA), under normal circumstances, the MSA method is applicable to situation which the satellite signal is poor, to achieve a single positioning.

7 - Changed the value of GPS CAPABILITIES from 0x37 to 0x35 for correctly MSA mode functionality.

8 - Changed the LTE Positioning Profile Settings from 0 (RRLP) to 3 (LPP_User_Plane and LPP_Control_Plane)

9 - Changed the A-GLONASS Positioning Protocol from 0 to 0x4 (LLP Uplane)

The reason for the 8 and 9 changes is because SUPL 3.0 doesn't support RRC and RRLP anymore.

[Step By Step]

It's Magisk install-able, don't install it by TWRP but with Magisk instead!

1 - Go on Magisk > Modules > Click on "+" yellow button > Search and find this "optimizedgpsconf.zip" file (Now this one and only works fine for both Nougat and Oreo and also is correctly replacing the gps.conf file), long press on it and select open and after installed then reboot your device.

2 - Make sure your location settings is setup on mode "High accuracy"

3 - Skirt outdoors, can be in the yard of your house or anywhere else with a line of sight to the sky, download some Compass app on Google Play Store (I recommend the Compass Steel 3D) and then calibrate the compass.

4 - Stay in that outdoor place and download GPS Locker on Google Play Store and open the app and wait for the first time fix/lock. This is necessary and essential because the app will recognize some GPS satellites signals for the very first time.

*Note 1 - Location mode "Battery saving" is gone due to Google's location accuracy is now a binary setting.

*Note 2 - Consider using the GPS Locker app because it is much better than the GPS Test and GPS Data. You just need to open it once and wait for fix, then your gps signal is locked and when you close it the app keep awake running in the background. (press Cancel in "Unlock GPS on exit" message). GPS was made to work on outdoor places. For indoor/enclosed places such as inside of your house don't forget that, it will take a few minutes to fix. It drains more battery, but is required if you're an advanced user that use gps all the time.

Whenever I'm on the street I keep the GPS Locker and Cellular data open because I use Cerberus antitheft, so if I get mugged or if I lose my phone I can track him down and retrieve it.

I hope I've helped. Please, give me some feedback if it worked for you.