Introduction
The Global Navigation Satellite System (GNSS) HAL interfaces the Android LocationManager with the device's GPS/GLONASS/Galileo receiver hardware. Because satellite locks can take significant time and drain battery, the HAL is responsible for managing the radio efficiently and injecting assistance data to speed up fix times.
GNSS HAL Interfaces
The core interface is IGnss. Through this, the framework can initialize the hardware, start and stop navigation sessions, and inject time or location data.
In modern Android, the GNSS HAL is actually a collection of specialized interfaces:
IGnssMeasurement: Provides raw pseudorange measurements directly from the satellites, used for advanced location algorithms or RTK (Real-Time Kinematic) positioning.IGnssGeofencing: Offloads geofence calculations to the GNSS chip, allowing the main CPU to sleep while the modem monitors if the device has crossed a boundary.IGnssBatching: Allows the hardware to record location points while the application processor sleeps, uploading them in a batch later.
Fix Acquisition Flow
When an app requests a location update, LocationManagerService passes the request to GnssLocationProvider. The provider calls IGnss::start() on the HAL.
The vendor daemon turns on the GNSS radio, searches for satellite signals, computes the ephemeris and almanac, and calculates a triangulation. Once a fix is acquired, the HAL fires a callback to the framework.
GNSS Callbacks to Framework
Because location calculation is asynchronous, the HAL relies heavily on the IGnssCallback interface.
interface IGnssCallback {
void gnssLocationCb(in GnssLocation location);
void gnssStatusCb(in GnssStatusValue status);
void gnssSvStatusCb(in hidl_vec<GnssSvInfo> svInfoList);
}
The gnssLocationCb provides the actual latitude, longitude, and accuracy. The gnssSvStatusCb provides the "Satellite View" status, detailing exactly which satellites are visible in the sky, their signal-to-noise ratio (SNR), and whether they were used in the fix.
GNSS Assistance Data
Without prior knowledge, a GNSS chip doing a "cold start" can take several minutes to download satellite orbital data at 50 bits per second. To achieve a "Time to First Fix" (TTFF) of under 3 seconds, Android uses Assisted GPS (A-GPS).
The IGnssXtra (or IGnssPsds) interface allows the Android framework to download satellite orbital prediction files (XTRA data) over Wi-Fi or LTE and inject them directly into the vendor HAL. Similarly, IGnssTime allows the system network time (NTP) to be injected into the modem, drastically accelerating the signal search process.