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. GpsLocationProvider.java  GpsXtraDownloader.java  and loc_eng_cfg.cpp . The GpsLocationProvider reads the following variables from the config:
SUPL_HOST SUPL_PORT C2K_HOST C2K_PORT
XTRA_SERVER_1 XTRA_SERVER_2 XTRA_SERVER_3
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 supl.google.com is signed by Thawte.
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.
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 OK $ AT+CREG=2 OK $ AT+CREG? +CREG: 2,1,"59E2","31B0" OK $ AT+CREG=0 OK 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 = supl.google.com, port = 7276 D/libloc ( 169): loc_eng_set_server, addr = supl.google.com:7276 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.
An excellent write-up on a much misunderstood situation!
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.
Is this about CM7 or CM9?
Or is it the same for both?
Both. Android 2 and 4.
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
Cause it is pre-alpha software?
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.
GPS didn’t work on marvelc when I flashed cm9.
Open a bug and post a logcat of the error.
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?
I think you need to debug libloc and check the radio logs.
_This_ is what I call a quick reply 🙂 Thanks!
Can one use google SUPL _without_ TLS?