[Magisk Module] Step By Step Definitive GPS Solution (Global)

Search This thread

someone8

Member
Aug 18, 2010
30
12
How do I know the NTP_SERVER for Italy?
The answer might be too late for you, but as the OP states, you can use
pool.ntp.org as the main NTP server because it's global, the system will try finding the closest available servers
This indeed works (just try it to ping it). Alternatively, to squeeze out a few milliseconds of latency, you may use it.pool.ntp.org.
 

someone8

Member
Aug 18, 2010
30
12
I just tried out many of the OPs suggestions because the given explanations make a lot of sense (still, many settings in the gps.conf will remain a mystery) and my device appears to be snappier with GNSS fixes. I have an additional recommendation for those who are interested:

INTERMEDIATE_POS=1
ACCURACY_THRES=800

It means: as soon as the location estimate has an accuracy of 800m or less, the app/system provides the location, which counts as "GPS/GNSS fix". You can vary the threshold; the default is somewhere around ~100m, which may result in never getting a fix in certain situations, for instance in a plane, a building, etc.
But with this adjustment, you almost always get a fast fix, which only requires a few satellites with low signal. Certainly, the estimated location will be coarse initially, but sometimes it may be already enough to roughly know where you are. If you are outside with good view of the sky, the accuracy will quickly converge to the usual values ~4-6m.
 

someone8

Member
Aug 18, 2010
30
12
In my experience, this module is all placebo. It doesnt seem to lock on any faster than my original gps.conf built into ROM. Accuracy seems the same too.
Yes; I pretty much agree. Most settings make no noticeable difference and remain a mystery, except for the INTERMEDIATE_POS and ACCURACY_THRES as I explained above.

This blog post goes into the same direction, who gives interpretations for a few settings (although several more settings might have been added since 2012).

At least one can reproduce in the logcat which parameters are actually respected/recognized by the system (filter for GNSSLocationProvider and switch airplane mode off/on to trigger reading the file).

Another thing to keep in mind for A-GPS to work (and the many related settings in the gps.conf - if they have a meaning) is also to not have the UID 1000 processes blocked by a firewall - otherwise the A-GPS data never gets downloaded and GPS fixes will take much longer.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 46
    *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.
    3
    Hi, i am from israel, i have the last version of miui 9 oreo i want to know if this modulesctill works for my version
    Thank you.-
    Yes, of course. But please, before just check if yours gps.conf is located at /system/etc or /system/vendor/etc and then choose the corresponding .zip file.
    gpsconfN.zip is for file located on /system/etc path and gpsconfO.zip is for file located on /system/vendor/etc path. :fingers-crossed:
    2
    I managed to install through MagiskManager, but it doesn't seem to alter the gps.conf file on the system/vendor/etc
    I use the gpsconfO.zip, the Magisk installation process went fine, rebooted, and on the Module page the GPS Replacer is checked. Did I miss something?
    Hi, firstly thanks for your work on this but the Magisk installer didnt seem to work. Using Magisk to install the module didnt appear to change the file once I checked it using root browser. I even flashed with TWRP and the file appears to remain the old file.
    I then used TWRP to mount system and used adb "pull" then "push" commnads to extract gps.conf, edit it with your new files information and then "push" back to the device. This seems to have worked and the file shows up edited in root browser.
    I cannot comment if it has fixed my terrible GPS performance yet.
    hi, im just modified gps.conf inside gpsconfO.zip, after it, the zip cant be flashed by magisk. Am i did something wrong?
    Magisk is not editing the file.. last modified time not changing for GPS conff file
    Kenzo RR May 20
    And now, can you tell us?
    Thanks
    I do not have an Mi 5, but another phone, with GPS problems but have been following this thread (and a few others) a little to possible get some ideas I can also apply.
    Anyway, just to let you know, I have noticed that if I sit inside at home near a window, I can get a fix pretty quick with 10+ satellites, and it holds perfectly. HOWEVER, if I use my GPS in my car (ie moving around) the GPS fix is often lost, but comes on again pretty soon; just sometimes at a very bad time for navigation:mad:.
    What I am saying, is that my GPS performs differently between when the phone is stationary and when it is moving about during navigation. Ensure you test both situations in case you get the same behavior.
    The old ones .zip modules was not replacing the gps.conf file - Now I updated and fixed it and this one and only works fine for both Nougat and Oreo and also is correctly replacing the gps.conf file. Check and Download it on attached files at the first page of this thread. Thanks!
    2
    Last update - Final version check it out!
    2
    *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.


    Does it replace the gps.config on every boot or just when installing?


    I am in Germany and my MI 9 MIUI 10.5 RevolutionOS 9.6.23 was getting vry bad GPS.
    I tried your solution, but it still didn't work.
    When using the following, it works very good:


    #XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra2.bin
    #XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra2.bin
    #XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra2.bin

    #Version check for XTRA
    #DISABLE = 0
    #AUTO = 1
    #XTRA2 = 2
    #XTRA3 = 3
    XTRA_VERSION_CHECK=0

    # Error Estimate
    # _SET = 1
    # _CLEAR = 0
    ERR_ESTIMATE=0

    #USA
    NTP_SERVER=pool.ntp.org
    NTP_SERVER=0.europe.pool.ntp.org
    NTP_SERVER=1.europe.pool.ntp.org
    NTP_SERVER=2.europe.pool.ntp.org
    NTP_SERVER=3.europe.pool.ntp.org

    # DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
    # 4 - Debug, 5 - Verbose
    # If DEBUG_LEVEL is commented, Android's logging levels will be used
    DEBUG_LEVEL = 3

    # Intermediate position report, 1=enable, 0=disable
    INTERMEDIATE_POS=0

    # Below bit mask configures how GPS functionalities
    # should be locked when user turns off GPS on Settings
    # Set bit 0x1 if MO GPS functionalities are to be locked
    # Set bit 0x2 if NI GPS functionalities are to be locked
    # default - non is locked for backward compatibility
    #GPS_LOCK = 0

    # supl version 1.0
    SUPL_VER=0x10000

    # Emergency SUPL, 1=enable, 0=disable
    SUPL_ES=0

    #Choose PDN for Emergency SUPL
    #1 - Use emergency PDN
    #0 - Use regular SUPL PDN for Emergency SUPL
    USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=1

    #SUPL_MODE is a bit mask set in config.xml per carrier by default.
    #If it is uncommented here, this value will overwrite the value from
    #config.xml.
    #MSA=0X2
    #MSB=0X1
    #SUPL_MODE=

    # GPS Capabilities bit mask
    # SCHEDULING = 0x01
    # MSB = 0x02
    # MSA = 0x04
    # ON_DEMAND_TIME = 0x10
    # GEOFENCE = 0x20
    # default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE
    CAPABILITIES=0x31

    # Accuracy threshold for intermediate positions
    # less accurate positions are ignored, 0 for passing all positions
    # ACCURACY_THRES=5000

    ################################
    ##### AGPS server settings #####
    ################################

    # FOR SUPL SUPPORT, set the following
    SUPL_HOST=supl.google.com
    SUPL_PORT=7276

    # FOR C2K PDE SUPPORT, set the following
    # C2K_HOST=c2k.pde.com or IP
    # C2K_PORT=1234

    # Bitmask of slots that are available
    # for write/install to, where 1s indicate writable,
    # and the default value is 0 where no slots
    # are writable. For example, AGPS_CERT_WRITABLE_MASK
    # of b1000001010 makes 3 slots available
    # and the remaining 7 slots unwritable.
    #AGPS_CERT_WRITABLE_MASK=0

    ####################################
    # LTE Positioning Profile Settings
    ####################################
    # 0: Enable RRLP on LTE(Default)
    # 1: Enable LPP_User_Plane on LTE
    # 2: Enable LPP_Control_Plane
    # 3: Enable both LPP_User_Plane and LPP_Control_Plane
    LPP_PROFILE = 2

    ################################
    # EXTRA SETTINGS
    ################################
    # NMEA provider (1=Modem Processor, 0=Application Processor)
    NMEA_PROVIDER=0
    # Mark if it is a SGLTE target (1=SGLTE, 0=nonSGLTE)
    SGLTE_TARGET=0

    ##################################################
    # Select Positioning Protocol on A-GLONASS system
    ##################################################
    # 0x1: RRC CPlane
    # 0x2: RRLP UPlane
    # 0x4: LLP Uplane
    A_GLONASS_POS_PROTOCOL_SELECT = 0



    informenter-marker-1.png