Android HAL driver for GPS and BDS
This is an GNSS HAL driver project. Support for both GPS and BDS satellites system. And use SUPL2.0 for AGPS.
- This project is about to make a gps.xxxx.so lib, which loaded by android system at the booting time.
- When gps.xxxx.so is loaded, it start an new thread to listen the gnss tty.
- The gnss device outputs navigation data in the format of NMEA 0183 protocol to gnss tty.
- The gps.xxxx.so lib draw location information and satellite's status from navigation data.
- The gps.xxxx.so lib contains some "callback" functions, which used to report location information and satellite's status to android framework.
A little trick
As android's original location service only support prn from 1 to 32(for it's use an int32 to hold all the satellites's in_use_fix_flag), that's only enough for GPS system.
To support BDS system, we need something more tricky.
As satellite's azimuth is always in range [0, 360), but with a float type, that's quite enough to hold something more.
So I add in_use_fix_flag to azimuth.
If the satellite is used in fix, it's azimuth will plus 720, else nothing changed.
And when the LocationAPI request satellite's status, if it's azimuth is bigger than 720, then it's used in fix, else, it's not.
I use different satellite's id range to distinguish GPS and BDS satellites. [1, 32] for GPS satellites, and [201, 216] for BDS satellites.
As we do all the things in android's hal(parse nmea and conceal satellites's in_use_fix_flag) and framework(reveal satellites's in_use_fix_flag and restore azimuth to normal), so any 3rd party application can work with it.
- Android source code.
- Android build enviroment.
- Build the android source.
- This project is build and tested on origin android v4.0.4.
- Someone said they found it also work well on origin android4.4 and android5.x.
- It definitelly NOT work on any MTK android version.
- Not guarantee anything on other android versions.
How to use
- Replace android's old /frameworks/base/location/java/android/locaton/GpsStatus.java file with the new one in this project.
- Copy folder /hardware/libgps/ to android source path.
- Rebuild android source code.
- Update your device with the new image.
- Change the settings in /system/etc/gnss.conf and copy it to android device.
Snapshots of GPSTest
- Dots are GPS satellites.
- Triangles are BDS satellites.
- 02,05,13,15,20,21,24,29 and 30 with white foreground and black background are GPS satellites.
- 201, 202 and 203 with black foreground and white background are BDS satellites.
- The maximum display satellites number of GPSTest are 12, but there are 21 satellites in view, so the rest are not displayed.
- SUPL2 is an optional feature, which can improves the gnss devices's startup performance.
- All my SUPL codes are based on tajuma's project.
- To support LTE(4G) network, I update asn-rrlp and asn-supl to SUPL2.0.
- To enable/disable SUPL2, edit hardware/libgps/Android.mk and set SUPL_ENABLED := 1/0.