[26.Aug.2011][Dev] GPS Libraries v2.1 with AGPS support for HD2 Gingerbread

Status
Not open for further replies.
Search This thread

sebasmiles

Senior Member
Dec 10, 2008
56
5
Only for information, i tested this morning the accuracy of information returned by the new driver.
These tests were performed with Copilot.
1 - Latitude, longitude and precision are ok.
2 - Elevation returned is too large.
For example, instead of displaying 165 meters, it displays 220-230. (I can not remember the results with the native driver, i will test this week end)
3 - When i move slowly, my position on the map does not change until i have moved several tens of meters. Then, suddenly it jumps to the new position.

Hope this help.

1) It should've always given a good longitude and latitude, I don't think I have ever heard anyone get something far off.

2) Elevation with GPS has always had high inacuracy. I remember seeing sailing GPS systems telling me I was flying a few thousand feet above water. Its just the nature of the beast due to the way how the configuration of satelites are placed. If the earth didnt exist, you would have satelites on the oposite side which would give you a more precise "elevation" but right now you only see what is ontop of you. Other systems like WAAS can reduce this error alot. As of right now, altitude should be off by a factor of atleast 3 from what I understand so by 30m in the best conditions and escalating quickly once you factor in the VDOP.

3) The true precision in the best conditions should be like 10m. This is close to the natural error of the GPS unit itself, the degree of precision can easily increase this by a few magnitudes and still be considered a good position. Earlier in the thread I explained a bit about how "accuracy" is calculated.
 

RiNo808

Senior Member
Feb 25, 2006
1,108
115
I'm just chiming in and letting you ask know that I flashed v1.1 on my At&t inspire and my gps improved...where I was getting 5-6 satellites and 9-10 meters...I'm now getting 7-10 satellites and 6-8 meters...thanks...

Sent from my Inspire 4G
 

arne182

Inactive Recognized Developer
Feb 5, 2010
289
270
GPS Testing

I have downloaded the fix and will be doing some extreme testing today. Will take my two HD2's out and see the difference between the two tonight.

Thanks for the update, will let you know how it goes.
 

ozkaya

Senior Member
Mar 22, 2006
649
302
RPC calls

OK, I have disassembled HD2 winmo DLL's and here is the result:

(@tytung, proc addresses are commented in the code)

Code:
pdsm_xtra_set_data

LDR     R0, [SP,#0x4C+var_28]
BL      oncrpcxdr_mem_free
LDR     R3, =unk_100B35CC
STR     R3, [SP,#0x4C+var_48]
LDR     R3, =unk_100B35D8
STR     R3, [SP,#0x4C+var_4C]
MOV     R3, #0x1A       /// proc 
MOV     R2, 0x10001     /// vers 
MOV     R1, 0x3000005B  /// prog
LDR     R0, [SP,#0x4C+var_28]
BL      xdr_call_msg_start
LDR     R0, [SP,#0x4C+arg_0]
BL      rpc_clnt_callback_register


pdsm_xtra_inject_time_info

LDR     R0, [SP,#0x50+var_2C]
BL      oncrpcxdr_mem_free
LDR     R3, =unk_100B35CC
STR     R3, [SP,#0x50+var_4C]
LDR     R3, =unk_100B35D8
STR     R3, [SP,#0x50+var_50]
MOV     R3, #0x1E        ///proc
MOV     R2, 0x10001      ///vers
MOV     R1, 0x3000005B   ///prog
LDR     R0, [SP,#0x50+var_2C]
BL      xdr_call_msg_start
LDR     R0, [SP,#0x50+arg_0]
BL      rpc_clnt_callback_register

let me know if you need anything else.
 

ozkaya

Senior Member
Mar 22, 2006
649
302
I finished 95% code of gps_xtra_inject_xtra_data(char* data, int length) and pdsm_xtra_set_data(...) which are responsible for injecting xtra.bin (ephemeris data) to the GPS chip.
But I don't know which RPC call I should invoke.
I also cannot ensure how many parameters in pdsm_xtra_set_data(...) I should use.
RPC server is a black box for me.

Code:
For example, why we use [B]proc=[COLOR="Red"]0xb[/COLOR][/B] in [URL="http://gitorious.org/htc-hd2-android-libraries/libgps/blobs/master/leo-gps-rpc.c#line293"]pdsm_get_position()[/URL].
293    if(clnt_call(clnt, amss==A6125 ? [B][COLOR="red"]0xb[/COLOR][/B] : 0xc, 
             (xdrproc_t)xdr_args, 
             (caddr_t)&par, 
             (xdrproc_t)xdr_result_int, 
             (caddr_t)&res, timeout))

And which proc should I use in pdsm_xtra_set_data(...)?
Unless someone can find it out, AGPS won't be finished.

proc - the server procedure to call

I saw this post right now, the reason your calling the proc 0xb in pdsm_get_position is because that's its proc in winmo:

Code:
pdsm_get_position
LDR     R0, [SP,#0x60+var_34]
BL      oncrpcxdr_mem_free
LDR     R3, =unk_100B35CC
STR     R3, [SP,#0x60+var_5C]
LDR     R3, =unk_100B35D8
STR     R3, [SP,#0x60+var_60]
MOV     R3, #0xB		///proc
MOV     R2, 0x10001		///vers	
MOV     R1, 0x3000005B		///prog
LDR     R0, [SP,#0x60+var_34]
BL      xdr_call_msg_start
LDR     R0, [SP,#0x60+arg_0]
BL      rpc_clnt_callback_register

I thought you were interested in proc of pdsm_xtra_set_data and pdsm_xtra_inject_time_info, sorry if pdsm_get_position was just for example.
 
  • Like
Reactions: tytung

ChrisM001

Senior Member
Nov 20, 2009
241
10
OruxMaps which is my reference navigation app because of it' s stability, doesn't work correctly with these GPS Libaries. It keeps showing the blinking searching for gps icon in the status bar. It would be nice if the GPS libraries would use the same interfaces as the original libraries, so that all apps could work with them in the same way. I'm going back to the original library until these errors are fixed.

Sent from my HTC HD2 using XDA App
 
Last edited:

Olioaglio

Senior Member
Feb 9, 2007
1,582
221
Regensburg
tytung, this is absolutely marvelous. Thanks a thousand times for your efforts. Just installed your library v1.1 on raf4.0.2 desire hd froyo 2.2.1 and it works just great. Got an instant fix and also icon appeared and disappeared instantly as promised. Also satellites are seen before fix. This is a real step forward on completing native android power on our devices. Will definitely donate you.

Cheers, Olioaglio

Sent from my HD2 with XDA Premium App
 

tytung

Senior Member
Jun 21, 2010
3,574
15,005
sites.google.com
Have you already tried MSM values? Looks easy, but they might work?

Code:
name	 prog	 proc,vers	 function name

0x3000005B	 0x1A, 0x0	 pdsm_xtra_set_data
0x3000005B	 0x1B, 0x0	 pdsm_xtra_client_initiate_download_request
0x3000005B	 0x1C, 0x0	 pdsm_xtra_set_auto_download_params
0x3000005B	 0x1D, 0x0	 pdsm_xtra_query_data_validity
0x3000005B	 0x1E, 0x0	 pdsm_xtra_inject_time_info

Thank you so much.
I didn't get too much free time these days.
I used your proc number yesterday, but I didn't get success so far.
I think the problem may be the wrong parameters of pdsm_xtra_set_data() I used.
I was wondering if the data types of parameters I sent to RPC server were wrong.

Code Review Time:
You can see the complete source code here.
Please help review my code.

Partial code is as follows.
Code:
int [B]gps_xtra_set_data[/B](unsigned char *xtra_data_ptr, uint32_t part_len, uint8_t part, uint8_t total_parts) 
{
    //D("%s() is called", __FUNCTION__);
    uint32_t res;
    res = pdsm_xtra_set_data(_clnt, 0, client_IDs[0xb], 0, xtra_data_ptr, part_len, part, total_parts, 0);
    D("%s() is called: res=%d", __FUNCTION__, res);
    return res;
}
Code:
int [B]pdsm_xtra_set_data[/B](struct CLIENT *clnt, int val0, int val1, int val2, unsigned char *xtra_data_ptr, uint32_t part_len, uint8_t part, uint8_t total_parts, int val3) {
    struct xtra_data_params xtra_data;
    uint32_t res = -1;
    xtra_data.data=malloc(sizeof(int)*4);
    xtra_data.data[0]=val0;
    xtra_data.data[1]=val1;
    xtra_data.data[2]=val2;
    xtra_data.xtra_data_ptr = xtra_data_ptr;
    xtra_data.part_len      = part_len;
    xtra_data.part          = (int8_t) part;
    xtra_data.total_parts   = (int8_t) total_parts;
    xtra_data.data[3]=val3;
    enum clnt_stat cs = -1;
    [COLOR="red"][B]cs[/B][/COLOR] = [B][COLOR="Red"]clnt_call[/COLOR][/B](clnt, 0x1A, 
            (xdrproc_t) xtra_data_xdr_args, 
            (caddr_t) &xtra_data, 
            (xdrproc_t) xtra_xdr_result_int, 
            (caddr_t) &res, timeout);
    D("%s() is called: clnt_stat=%d", __FUNCTION__, cs);
    if (cs != RPC_SUCCESS){
        D("pdsm_xtra_set_data(%x, %x, %d, %x, %d, %d, %d, %d) failed\n", val0, val1, val2, (int) xtra_data_ptr, part_len, part, total_parts, val3);
        free(xtra_data.data);
        exit(-1);
    }
    D("pdsm_xtra_set_data(%x, %x, %d, %x, %d, %d, %d, %d)=%d\n", val0, val1, val2, (int) xtra_data_ptr, part_len, part, total_parts, val3, res);
    free(xtra_data.data);
    return res;
}
After calling clnt_call(), cs is 11 which means RPC_CANTDECODEARGS=11, /* decode arguments error */
Then the phone will enter the reboot loop.
So it's very time consuming to test the new libgps.so.

Logcat is as follows.
Code:
D/gps_leo_rpc(  118): pdsm_xtra_set_data() is called: clnt_stat=11
D/gps_leo_rpc(  118): pdsm_xtra_set_data(0, 1f40, 0, 40832180, 400, 1, 97, 0) failed
D/gps_leo_rpc(  118): gps_xtra_set_data() is called: res=-1
 
Last edited:

tytung

Senior Member
Jun 21, 2010
3,574
15,005
sites.google.com
OruxMaps which is my reference navigation app because of it' s stability, doesn't work correctly with these GPS Libaries. It keeps showing the blinking searching for gps icon in the status bar. It would be nice if the GPS libraries would use the same interfaces as the original libraries, so that all apps could work with them in the same way. I'm going back to the original library until these errors are fixed.

Sent from my HTC HD2 using XDA App

I think it should be the app issue.

GPS interface (GpsLocationProvider, etc.) has already changed between Froyo and Gingerbread.
If you have got a GPS lock, but still see the blinking searching for gps icon in the status bar, it may mean that your app, OruxMaps, still use the Froyo method to get GpsLocationProvider.

Google MyTracks is working well with the new libs.
 

Olioaglio

Senior Member
Feb 9, 2007
1,582
221
Regensburg
Can confirm working all right function of all tested apps so far (igo8, my tracks, cardio trainer, gps status, google maps/navigation, Velox Pro, Satellite AR, location, etc.)

Cheers, Olioaglio

Sent from my HD2 with XDA Premium App
 

webvan

Senior Member
May 20, 2008
1,167
72
Working pretty good here on AmericanAndroid but the altitude is completely off, as it shows 4294966640 meters right now!
 

arne182

Inactive Recognized Developer
Feb 5, 2010
289
270
GPS Testing

I have been out and about.

For the time (fix.timestamp):
The GPS time is converted correctly to NTP correctly. Syncing with NTP and checked against "GPS Time" shows a difference of about 1 second and sometimes below. Might be the delay in GPS and system and app. Will do more testing but Someone else needs to confirm this.

For the Height (fix.altitude):
Between 40 and 50 m above Google earth's topology map. This has been measured between 35 and 185 m above sea level. Want to hop in a plane soon and check it out at higher altitudes. Should actually compare with a Garmin or similar GPS unit. Can Someone check the difference between Commercial GPS and the new Lib.

Difference between old lib and new lib for height on average is less than 1% and max at 10% again between the heights specified above.

Suggested fix (fix.altitude = (double)ntohl(data[64]) / 10.0f-40)

For Accuracy:
Still I find that the accuracy could still go up at least double. I have been testing in various locations and moving around and comparing to Google map satellite data and seeing if I can move outside my specified accuracy drawn on the map as a circle. I would suggest bringing the accuracy multiplication up to 4.

Suggested fix (fix.accuracy = (float)ntohl(data[75]) / 10.0f * 4)

For the satellites showing up before lock is establishes does work well.

For GPS lock times though it is quite slow. Compared to the old lib the warm start GPS lock time is about 90 seconds for both. But the relock time for the old lib is faster than the new one. This will need more testing as this takes time.

FYI
The "GPS Status" application shows some new information about AGPS being available on the new lib.

Tomorrow is speed and bearing.

P.S.
Thanks for the leap time correction, credit, tytung.
 
Last edited:
  • Like
Reactions: Nixda99 and tytung

arne182

Inactive Recognized Developer
Feb 5, 2010
289
270
Working pretty good here on AmericanAndroid but the altitude is completely off, as it shows 4294966640 meters right now!

On what rom are you?
Which application shows this?
What is the height at your position? (You can use Google Earth to check this)
Is this a once off error or is this all the time?
Is it fixed by going back to the old gps.lib?
 

webvan

Senior Member
May 20, 2008
1,167
72
On what rom are you?
Which application shows this?
What is the height at your position? (You can use Google Earth to check this)
Is this a once off error or is this all the time?
Is it fixed by going back to the old gps.lib?
1. AmericanAndroid 05/29
2. Locus but others too, like GPS Status
3. 10 meters
4. All the time
5. Would have to try. A bit of a hasle since I did manual installs with RootExplorer. Haven't figured out how to use the "ROM Manager" with my Dual Boot setup.
 

Diem

Senior Member
May 26, 2007
63
44
Tytung, All, many thanks for taking the time getting in to it! Real life takes alot time and same applies for the other way around :p

Rgds,
Diem
 

ChrisM001

Senior Member
Nov 20, 2009
241
10
I think it should be the app issue.

GPS interface (GpsLocationProvider, etc.) has already changed between Froyo and Gingerbread.
If you have got a GPS lock, but still see the blinking searching for gps icon in the status bar, it may mean that your app, OruxMaps, still use the Froyo method to get GpsLocationProvider.

Google MyTracks is working well with the new libs.

Hi tytung,

thanks for your quick answer and great job. The developer of OruxMaps said, that OruxMaps is used by many users from rel 1.6 to 2.3.4 and no one reported such problem. The developer himself uses a nexus with 2.3.4 without any problem. Could you take one more look at your libraries to make it more universal usable? MyTracks is not really an alternative to OruxMaps. The latter is IMHO the far better offroad navigation app.

Thanks and Regards,

Chris
 

memin1857

Senior Member
Jun 2, 2010
907
202
Istanbul
...
Syncing with NTP and checked against GPS Time shows a difference of about 1 second and sometimes below. Might be the delay in GPS and system and app. Will do more testing but Someone else needs to confirm this.

For the Height (fix.altitude):
Between 40 and 50 m above Google earth's topology map. This has been measured between 35 and 185 m above sea level. Want to hop in a plane soon and check it out at higher altitudes. Should actually compare with a Garmin or similar GPS unit. Can Someone check the difference between Commercial GPS and the new Lib.

Difference between old lib and new lib for height on average is less than 1% and max at 10% again between the heights specified above.
...
For Accuracy:
Still I find that the accuracy could still go up at least double. I have been testing in various locations and moving around and comparing to Google map satellite data and seeing if I can move outside my specified accuracy drawn on the map as a circle. I would suggest bringing the accuracy multiplication up to 4.
...
For GPS lock times though it is quite slow. Compared to the old lib the cold start GPS lock time is about 90 seconds for both. But the relock time for the old lib is faster than the new one. This will need more testing as this takes time.
...
Thanks for the leap time correction, credit, tytung.
I think the fast relock behaviour with old libs was because the old lib didn't know that the gps usage session has ended, it actually restarted where it left off, as if it was suspended/slept. My samsung phone instantly showed loss of sat when going inside a tunnel but with hd2+diem's libs it just froze the signals at the last known level and did not find out about signal loss until several seconds later. (So when you closed the gps app, when you later reopen it it just continued from where it left off and if you are near your last location it took only 2-3 seconds to relock, but now it takes about 10-15) When relocking within short time, old libs just resumed exactly where it left off but new libs seem to do a small reset/restart of some sort. Maybe old libs were doing a "hot start" but new libs it is doing "warm start".
So I confirm cold lock times are about the same but relocks are faster with old libs which seems like a good side effect of wrong implementation :)

With 1.1 libs:
HD2 gps time is 16 seconds behind my samsung native android phone in GPS STATUS app but EXACTLY the SAME in clock sync app (without syncing with ntp) HD2 gps time is 1 second behind atomic time which also the case with my native android samsung phone. (clock sync app)
SO I confirm gps time is 1 sec behind atomic time BUT that is also the case with my samsung phone. I don't know why my samsung reports 16 seconds ahead in gps status app but hd2 also reported like that with old libs.

My locations altitude is 135 meters in google earth, but around 168-171 meters in gps status of both hd2 and samsung phone. Altuide is OK I guess. I did once see around 412552452453 altitude and it actually caused text corruption in gps status due to too long text but restarting the app (so turning gps off/on) fixed altitude back.

Accuracy is now "generally" similar to samsung phone but not always. With Diem's libs, HD2 showed unrealistically too accurate (reported 1 meter), with 1.0 tytung libs hd2 showed bad accuracy (reported around 22 meters), with 1.1 it seems on par with samsung phone when sat signals are good. (around 4-5 meters accuracy at best) But sometimes the two phones accuracy numbers differ a lot, so I guess hd2 1.1 lib accuracy is OK when you have good sat visibility but reports better than actual when sat signal levels are bad due to conditions.

HD2 sat signal levels are reported lower than the samsung phone. about 5-10db less with hd2. (they were reported higher with diems libs if I remember correctly)

Still, when using nav apps, when you come to a complete stop, your gps speed indicator won't stay at 0, it will flicker at 3-4-6-2 like that, somehow still location reporting changes a little by itself.

GPS status complains about data connection with my samsung phone but agps still works flawlessly so I guess samsung implemented agps differently and it doesn't really matter what gps status app says.
 
Last edited:
  • Like
Reactions: ernestus and tytung

corrsea

Senior Member
Apr 29, 2010
1,758
711
Xiaomi Mi 11 Ultra
Xiaomi 13 Ultra
I have been testing this on tytungs nexus hd2 since it was released. I have used igo, sygic aura, copilot and google maps. In addition I have used gps status, gps test and gps aids.
First fix (warm start) varies between 30 to 120 secs. (BTW I doubt if anybody is actually reporting cold starts as this would involve switching the device off for a considerable period or travelling a considerable distance with the phone switched off.)
Hot starts are between 3 and 13 seconds.
All the navigation programs appear to measure speed correctly. Both igo and sygic correctly indicate 0 when at rest. (i'm not sure if they even use gps data when under 5 kph)
IMO altitude is a red herring as i've never come across a gps that could accurately measure this, however all 3 are within a couple of meters of each other.
I have not yet had any drop of signal while navigating.
There does appear to be a lag of a couple of seconds which gives the appearance of my position jumping at slow speed.
I would add that I also had a reasonably good gps with the old libs. The main improvements are that I see more sats 10/11 as opposed to 6/7, the sats are visible prior to lock and the gps switches on and off instantly.
 

itais

Senior Member
Nov 15, 2008
283
27
Hi,

Will this fix work also on Desire HD ?
If not are you planning to make one ?

Thank you in advance,
Itai.
 

ozkaya

Senior Member
Mar 22, 2006
649
302
data types

@tytung,

I had a look at your source code and the documentation.
pdsm_xtra_set_data is originally documented with 8 variable constructor,whereas your implementation seems to have 9 variables and only 4 of them seems to match. Their data types look correct, but for some of the remaining ones you are feeding integer values like val0,val1,val2 and val3. Where do they come from and are you sure they should be integers?
 
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 265
    This implementation is based on GPS Library in HTC-HD2 Android Libraries. (Thanks to dan1j3l.)
    You can find my modified source code and AGPS development info in the second post.

    New Features:
    • Show the number of satellites before getting a location fix.
    • Show or hide the GPS symbol in the status bar instantly when you start or stop a GPS app.
    • Support the leap seconds. (Thanks to arne182.)
    • Modify the Accuracy (i.e. Error in meter) to be more reasonable.
    • Add AGPS interface. (Won't see "no AGPS interface in agps_data_conn_open" in logcat now.)
    • Add the missing functions to receive the NTP, XTRA, and SUPL settings from gps.conf.
    • Add AGPS implementation including injecting AGPS data (xtra.bin) and NTP time into the gpsOne engine.
    • Hide Fix/Sats info and make the GPS symbol in the status bar flashing when you go to basement or tunnel.
    • Show DOP/HDOP/VDOP values in GPS Status.
    • Show Altitude above Geoid (i.e. mean sea level) and Geoid height. (You will see both of them in GPS Status. The value within parentheses is Geoid height.)
    • Show correct SNR (Signal to noise ratio) value.
    • Activate the AGPS data injection. (You can get a cold lock very quickly due to the working AGPS.) (Thanks to qwerty_7564.)

    Known issues:
    • Accuracy value is for reference only.
      • Position Accuracy (meter) = HDOP (unitless) * Measurement Precision (meter). (Please confirm whether this formula is correct.)
      • We only get the correct HDOP value, and we assume the value of Measurement Precision, and then do a post calculation to get Accuracy. So don't trust it completely.
    • Some ROMs are not compatible with NMEA version of libgps.so.
      • Those ROMs don't set the correct permission to /dev/smd27, so libgps.so cannot read NMEA sentences from it.
      • The solution is to flash GPS_NMEA_permission_update.zip for correcting the permission after booting.
    • Some ROMs suffer from the "GPS off-and-on" bug.
      • Those ROMs can shutdown the gpsOne engine properly when turning off GPS setting using gps_cleanup(), but they cannot restart the gpsOne engine again because gps_init() is never called when turning GPS setting on after turning it off.
      • It's a Gingerbread bug which is fixed by applying this commit from the source code.
      • If you cannot modify the source code, the workaround is to set/add GPS1_CLEANUP_ENABLED=0 into gps.conf to avoid doing full cleanup.

    Downloads:

    Mod edit: Links removed

    Installation for CWM:
    • Place your downloaded file (GPS_Libraries_v1.x_for_HD2_Gingerbread_update.zip) in the SD card.
    • Enter CWM (ClockworkMod) Recovery
      • MAGLDR 1.13: Hold "Power" button during boot to enter MAGLDR, and then select "AD Recovery" or "Boot AD SD" (if ever copied CWM's initrd.gz and zImage to SD) to enter CMW.
      • cLK 1.4.0.1: Hold "Home" button during boot to enter CMW.
    • Choose install zip from sdcard and locate your downloaded file to finish the installation.
    • All done.

    You can install GPS Status & Toolbox or GPS TEST to test the new libs.

    How to inject the AGPS data (xtra.bin):
    It will be done in the following situations. (Data connection, WiFi or 3G, is a must in all of them.)
    • When you turn off GPS in setting and turn it on again.
    • When you keep GPS on and reboot. (also inject NTP time)
    • When you keep GPS on and run Leo AGPS Injector. (also inject NTP time)
    • When you keep GPS on and run GPS Status. (or any similar apps to download AGPS)
      • AGPS will be downloaded when you start GPS Status if AGPS is older than X days or Y hours where X and Y are read from the settings.
      • Or you can download it manually from Tools.
    • When you keep GPS on and replace with the modified gps.conf to set AGPS auto-download intervals when using GPS libs v1.8 or above.
      • AGPS auto-download intervals are disabled in default if you don't modify gps.conf.

    How to verify if AGPS works or not:
    • When AGPS works, you will be able to get a full lock (e.g. 7/7, 8/8, or 9/9) in cold start less than 20 seconds if you're outdoor in a sunny day.
      (Full locks mean fix and satellites equals to each other.)
    • If AGPS not works, you may see 5/7, 6/7, 5/8 (fix is less than satellites) right after you get a lock.

    How /system/etc/gps.conf works?
    There're three stock gps.conf in AOSP repository for different regions.
    1. gps.conf_AS_SUPL (Asia)
    2. gps.conf_EU_SUPL (Europe)
    3. gps.conf_US_SUPL (North-America)
    # Explanations are added. Don't copy them below to your gps.conf.
    NTP_SERVER=north-america.pool.ntp.org   (Used for NTP time injection)
    XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin   (Used for AGPS data xtra.bin injection. Randomly choose from one of these three servers and download xtra.bin from it.)
    XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
    XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
    SUPL_HOST=supl.google.com   (Be read but never be used)
    SUPL_PORT=7276   (Be read but never be used)
    SUPL_HOST and SUPL_PORT are not used in current GPS libs implementation, so you can delete them.

    Supported extra settings for /system/etc/gps.conf when using v2.0 or above. (Only valid for HD2)
    Beginning with character # means this line is a comment, so you can remove it.
    You don't need to add any of them if you don't know what they are.
    Code:
    ###########################################
    # Enable/disable automatic (periodic)     #
    # download requests of gpsOneXTRA         #
    # assistance data to client               #
    # Range: 0 to 1                           #
    # Default: 0 (Disabled)                   #
    ###########################################
    [COLOR="Red"]GPS1_XTRA_AUTO_DOWNLOAD_ENABLED=0[/COLOR]
    
    ###########################################
    # Time (in hours) between automatic       #
    # download requests of gpsOneXTRA         #
    # assistance data to client               #
    # Range: 1 to 168 (168 = hr in a week)    #
    # Default: 24 hr                          #
    ###########################################
    [COLOR="red"]GPS1_XTRA_DOWNLOAD_INTERVAL=24[/COLOR]
    
    ###########################################
    # Enable/disable to shutdown the gpsOne   #
    # engine properly on GPS off              #
    # Range: 0 to 1                           #
    # Default: 1 (Enabled)                    #
    ###########################################
    [COLOR="red"]GPS1_CLEANUP_ENABLED=1[/COLOR]
    
    ###########################################
    # Time (in seconds) between invoking      #
    # pdsm_get_position()                     #
    # Range: 2 to 120                         #
    # Default: 2 seconds                      #
    ###########################################
    [COLOR="red"]GPS1_SESSION_TIMEOUT=2[/COLOR]

    AGPS works in v1.7. The following workaround is for v1.6 and below versions only.
    Instructions for the AGPS data Injection.
    There're at least three methods (I recommend free apps here.) to be able to inject AGPS data.
    GScript method is the base, so I describe it as follows.
    Please download libgps_Switcher_v1.6.zip, decompress it to your SD card, and follow the steps below if you want AGPS support.
    You need to repeat steps 4 and 5 every time when you need AGPS.
    1. Put the following files in the SD card.
      /sdcard/ClockworkMod/GPS_Libraries_v1.6_for_HD2_Gingerbread_update.zip (Remember to download it.)
      /sdcard/ClockworkMod/libgps_with_AGPS_update.zip (Remember to download it.)
      /sdcard/GScript/1_install_Magic_AGPS.sh
      /sdcard/GScript/2_install_libgps_v1.6.sh
    2. Install GScript or GScript Lite.
    3. Add 1_install_Magic_AGPS.sh and 2_install_libgps_v1.6.sh to GScript.
    4. Run 1_install_Magic_AGPS.sh, and the phone will hot reboot itself.
      After reboot, make sure you have network connection, and wait at lease 1 min to let Android download and inject AGPS data.
    5. Run 2_install_libgps_v1.6.sh, and the phone will hot reboot itself.
      After reboot, you can enjoy the quicker GPS cold lock.

    Changelog:
    • Version 2.1 NMEA|RPC - (Aug. 26)
      • Both: Remove or reduce some debugging info output to logcat. (Cleanup and optimization stage.)
      • Both: Output NMEA or RPC version and parsed settings of gps.conf to logcat.
    • Version 2.0 NMEA|RPC - (Aug. 6)
      • Both: Add GPS1_SESSION_TIMEOUT in gps.conf to set time between invoking pdsm_get_position(). (Default is 2 seconds. Range is 2~120 seconds.)
      • RPC: Hide Fix/Sats info and make the GPS symbol in the status bar flashing when you go to basement or tunnel. (NMEA already has this feature. This is for RPC version.)
    • Version 1.9 NMEA|RPC - (Jul. 29)
      • Both: Include v1.7's latest gps.htcleo.so, gps.leo.so, and gps.bravo.so again.
      • Both: Add a new thread for getting GPS location locks: (Credits to qwerty_7564)
        • gps_get_position() is called in its own thread using callbacks to request the next position.
        • remove unnecessary sleep and the can_send flag in pdsm_get_position().
      • Both: Remove unnecessary mallocs since there is a performance cost for use. (Credits to qwerty_7564)
      • Both: Shutdown the gpsOne engine properly on GPS off. (i.e. turning off GPS from settings) (Credits to qwerty_7564)
      • Both: Support loading the GPS1_CLEANUP_ENABLED flag from gps.conf. (Set it to 0 if you use a ROM that has "GPS off-and-on bug".)
      • Both: Parse gps.conf and invoke pdsm_xtra_set_auto_download_params() only once until reboot.
      • Both: Support the customized fix update frequency, which is set by a GPS tracking app, via gps_get_position(int timeout).
      • NMEA: Add a timer thread for supporting the customized fix update frequency which is set by a GPS tracking app.
        (As a result, we won't see the fast-forwarding effect in time field in GPS Status, and the random hot reboot issue in NMEA version may be fixed too.)
    • Version 1.8 NMEA|RPC - (Jul. 19)
      • Both: Support automatic (periodic) download requests of gpsOneXTRA assistance data to client. (Default is disabled.) (Credits to qwerty_7564.)
      • Both: Support enabling xtra.bin download requests and setting download interval from gps.conf.
      • Both: Include v1.6's old gps.htcleo.so, gps.leo.so, and gps.bravo.so. (It seems that v1.7's new gps.xxx.so causes the battery drain in some ROMs, but not all ROMs.)
      • NMEA: Disable $GPGSV report to make NMEA version more stable. (It seems that random hot reboot issue is reduced.)
      • RPC: Support the negative altitude. (Credits to arne182.)
      • RPC: Fix the incorrect HDOP value.
    • Version 1.7 NMEA|RPC - (Jul. 10)
      • Both: Activate the AGPS data injection. (You can get a cold lock very quickly due to the working AGPS.) (Thanks to qwerty_7564.)
      • Both: Include updated gps.htcleo.so, gps.leo.so, and gps.bravo.so. (Fix suspension issues.) (Thanks to rmcc.)
      • RPC: Disable NMEA sentences output and enable RPC Callback function output.
    • Version 1.6 - (Jul. 05)
      • Set Measurement Precision to 10.0 meters.
    • Version 1.5 - (Jun. 26)
      • Support daylight saving time (DST).
    • Version 1.4 - (Jun. 24)
      • A whole new version using NMEA sentences.
      • Hide Fix/Sats info when you go to basement or tunnel.
      • Show DOP/HDOP/VDOP values in GPS Status.
      • Show Altitude above Geoid (i.e. mean sea level) and Geoid height. (You will see both of them in GPS Status. The value within parentheses is Geoid height.)
      • Show correct SNR (Signal to noise ratio) value.
      • Disable AGPS Ephemeris data (xtra.bin) injection.
      • Assume Measurement Precision to 5.0 meters.
      • Include updated gps.htcleo.so, gps.leo.so, and gps.bravo.so. (Only one file will be used by your ROM. I suggest to delete the other two files in this zip file, and then flash it.)
    • Version 1.3 - (Jun. 15)
      • Fix the reboot issue. (In v1.2, reboot your phone when the GPS setting is off, you will enter the boot loop.)
      • Inject the correct time to the gpsOne engine.
      • Comment out some debugging data.
    • Version 1.2 - (Jun. 12)
      • Support injecting AGPS Ephemeris data (xtra.bin) into the gpsOne engine by implementing pdsm_xtra_set_data().
      • Support injecting time into the gpsOne engine by implementing pdsm_xtra_inject_time_info().
      • Assume Measurement Precision to 2.5 meters.
    • Version 1.1 - (Jun. 02)
      • Assume Measurement Precision to 2.0 meters.
    • Version 1.0 - (May 28)
      • Show the number of satellites before getting a location fix.
      • Show or hide the GPS icon in the status bar instantly when you start or stop a GPS app.
      • Support the leap seconds. (Thanks to arne182 for figuring it out.)
      • Modify the Accuracy to be more reasonable. (Assume Measurement Precision to 10 meters)
      • Add AGPS interface. (Won't see "no AGPS interface in agps_data_conn_open" in logcat now.)
      • Add the missing functions to receive the NTP, XTRA, and SUPL settings from gps.conf.

    Credits: the XDAndroid Project, dan1j3l, rmcc, tytung, arne182, clyder, ozkaya, qwerty_7564, and everyone who participated in the related discussion or helped test the libs.
    73
    Leo AGPS Injector v0.5

    Leo AGPS Injector is an Android app for quickly injecting NTP time and AGPS xtra.bin data, and lets you explicitly know when the AGPS data is injected.

    • Manual execution: Run this app to finish the AGPS injection task manually.
    • Auto execution: Use Script Manager(free app) or Tasker(paid app) to schedule the routine task by using the script below or using any similar method.
      agps_injection.sh
      Code:
      am startservice -n leo.android.agps/leo.android.agps.AGpsService
    Download and install LeoAGpsInjector_v0.5.apk
    chart



    Changelog:
    • v0.5:
      • Add a network check for refreshing widget's injection time only if connecting to a really available network. (i.e. can download xtra.bin and get NTP time)
        In v0.4, it will still refresh the time even if you are roaming and disable data roaming. (Under this situation, you cannot download anything but this app doesn't know.)
    • v0.4:
      • Merge versions 0.3 and 0.3a:
        Add a check box for determining if showing the setting dialog every time when running this app.
        • When you uncheck it and run this app again, it will inject NTP time and AGPS xtra.bin data, and then destroy this app by itself. So you won't see any UI.
        • When you uncheck it and leave this dialog, you must go to [Settings]->[Applications]->[Manage appliciation]->[Leo AGPS Injector], and press "Clear data" to get this dialog popped up again.
    • v0.3:
      • Add a widget for quickly injecting NTP time and AGPS xtra.bin data.
      • Display the last injection time in the widget.
      • Include three types of notifications: Notification/Status Bar, Pop-up message, and None.
    • v0.2:
      • You can choose to see the real injection time in the notification bar or to be notified through a pop-up message.
    • v0.1:
      • If you network is unavailable, this app will run as a background Service and passively wait for the connectivity change notification from the Android.
        • Besides, you can see the "Waiting for an available network." message in the notification bar.
      • When you network is available, this app will download and inject NTP time and xtra.bin, and then the Service will destroy itself to free the memory, so this app won't occupy your memory.
        • Besides, you can see the real injection time in the notification bar, and you can clear it if needed.
    LeoAGPSInjector_v0.5_01.png
    LeoAGPSInjector_v0.5_02.png
    56
    AGPS Development is finished.

    My modified source code of libgps.so has been uploaded to Github. https://github.com/tytung/android_hardware_leo_libgps

    Notice:
    The source code is released under the GNU General Public License version 3 (GPLv3).
    So you must release your modified source code if you would like to release a modified libgps.so.

    Development info:
    Credits: tytung, clyder, ozkaya, qwerty_7564, and everyone who participated in the related discussion or helped test the libs.
    36
    AGPS Devel

    I changed this line in gps_xtra_set_data from leo-gps-rpc.c.
    from:
    Code:
    res = pdsm_xtra_set_data(_clnt, 0, client_IDs[0xb], 0, xtra_data_ptr, part_len, part, total_parts, 0);
    to:
    Code:
    res = pdsm_xtra_set_data(_clnt, 0, client_IDs[0xb], 0, xtra_data_ptr, part_len, part, total_parts, 1);
    and agps appears to be working. I have uploaded the modified libgps.so in tytung's zip package just replaced the libgps.so. I was wondering if people would try it out.
    23
    If you want to enable xtra.bin download requests and set download interval, you need to modify gps.conf.
    Set GPS1_XTRA_AUTO_DOWNLOAD_ENABLED to 1 and set GPS1_XTRA_DOWNLOAD_INTERVAL to 24 hr or whatever. (range is 1~168)

    Code:
    NTP_SERVER=north-america.pool.ntp.org
    XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
    XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
    XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
    SUPL_HOST=supl.google.com
    SUPL_PORT=7276
    
    ###########################################
    # Enable/disable automatic (periodic)     #
    # download requests of gpsOneXTRA         #
    # assistance data to client               #
    # Range: 0 to 1                           #
    # Default value: 0 (Disabled)             #
    ###########################################
    [COLOR="Red"]GPS1_XTRA_AUTO_DOWNLOAD_ENABLED=1[/COLOR]
    
    ###########################################
    # Time (in hours) between automatic       #
    # download requests of gpsOneXTRA         #
    # assistance data to client               #
    # Range: 1 to 168 (168 = hr in a week)    #
    # Default value: 24 hr                    #
    ###########################################
    [COLOR="red"]GPS1_XTRA_DOWNLOAD_INTERVAL=24[/COLOR]