Android, CyanogenMod and the GPS fix

There are a lot of people around providing gps fixes for Android. Most of them don’t really help at all. I want to explain here what variables the code recognizes and what they do. The other thing is SuplCert which is the certificate to verify the ssl connection for the supl server. Most of the time poeple provide the wrong certificate.


There are two locations in the code which read the gps.conf file. [1] [2] and loc_eng_cfg.cpp [3]. The GpsLocationProvider reads the following variables from the config:




This is pretty obvious. It then calls a function from libloc_api called loc_eng_set_server() to set the agps server. libloc_api itself reads also the gps.conf to get the values for the following variables:

    INTERMEDIATE_POS (Turn on intermediate position)
    ACCURACY_THRES   (Turn-off  intermediate positions outside required accuracy)
    ENABLE_WIPER     (The code only reads this variable but it doesn't do anything)
    DEBUG_LEVEL      (0-5, default: 4)


In most of the flashable gps fixes you find a SuplCert. Most of them I looked at have the wrong certificate. They include a Verisign certificate but is signed by Thawte.


This is a SSL encrypted supl request to on port 7275.

However as you can see above. There is no support for a TLS supl request in the code. It doesn’t make sense to add the host, port and certificate in CyanogenMod.

Supl Protocol

For supl you need to have a cell connection. You ask the radio for the cell parameters and send it to the supl server. The supl server will return the gps coordinates of the tower or an estimation of your location.

You can get the cell id information with the following AT commands:

       $ AT+COP?
       +COPS: 0,2,"24405",2
       $ AT+CREG=2
       $ AT+CREG?
       +CREG: 2,1,"59E2","31B0"
       $ AT+CREG=0

       This results in:

       MCC = 244     (Mobile Country Code)
       MCN = 05      (Mobile Country Network)
       LAC = 0x59e2  (Local Area Code)
       CI  = 0x31b0  (Cell Identifier)


The default gps.conf by CyanogenMod provides all needed variables to have supl support for a faster GPS fix.

With DEBUG_LEVEL=5 you normally see the following lines:

    D/libloc  (  169): loc_eng_init created client, id = 1
    D/libloc  (  169): loc_eng_ni_init: entered.
    D/libloc  (  169): loc_eng_set_server, type = 1, hostname =, port = 7276
    D/libloc  (  169): loc_eng_set_server, addr =
    D/libloc  (  169): loc_eng_ioctl called: client = 1, ioctl_type = RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR
    D/RPC     (  169): 3000008c:00020002 call success.
    D/RPC     (  169): 3000008c:00020002 sending call (XID 2).
    D/RPC     (  169): 3000008c:00020002 received REPLY (XID 2), grabbing mutex to wake up client.

[1] frameworks/base/services/java/com/android/server/location/
[2] frameworks/base/services/java/com/android/server/location/
[2] hardware/qcom/gps/loc_api/libloc_api/loc_eng_cfg.cpp

You may also like...

13 Responses

  1. Matt says:

    An excellent write-up on a much misunderstood situation!

  2. Sometimes I hate the Android community cause there are so many people having no clue what they are actually doing, but they praise their solution as the ultimative one.

  3. Benedikt Morbach says:

    Is this about CM7 or CM9?

    Or is it the same for both?

  4. Both. Android 2 and 4.

  5. Mena Aboud says:

    So, why GPS is not working in this ROM too 😀 ? i’m using your fist release of [ROM] CyanogenMod 10.0.0-RC0 marvel/marvelc ALPHA0

  6. Cause it is pre-alpha software?

  7. Mena Aboud says:

    hhhh, ok.. i didn’t mean to Pressure you. or make like you feel you must fix it. if i did 😀

    Appreciate your huge effort for Wildfire S.
    Regards. 🙂

  8. Jun Colorina says:

    GPS didn’t work on marvelc when I flashed cm9.

  9. Open a bug and post a logcat of the error.

  10. kwast says:

    Thanks for this great post!

    On my phone, I checked the log with debug level 5 and it does not query the supl server at all. I added supl as apn type and added the google supl to the gps.conf. Any idea why it is not working?

  11. I think you need to debug libloc and check the radio logs.

  12. kwast says:

    _This_ is what I call a quick reply 🙂 Thanks!

  13. genius kid loves xmpp says:

    Can one use google SUPL _without_ TLS?

Leave a Reply

Your email address will not be published. Required fields are marked *