Skip to content

Vehicle Data & VHAL

Location, GNSS and vehicle sensors

Why positioning in a car is both better and harder than on a phone — satellite fixes, dead reckoning through tunnels, wheel ticks, and the sensors Android does not own.

Intermediate6 minGNSS · Location · Sensors

A phone knows where it is by listening to satellites. A car does too — but it also knows how far its wheels have turned, which way the steering is pointed, and how it is accelerating.

That extra information makes vehicle positioning better than a phone's in some situations and completely different to reason about in others.

Two sources, not one#

gives an absolute position from satellites. It is accurate, it does not drift, and it stops working the moment you enter a tunnel or a multi-storey car park.

estimates position from motion — how far the wheels turned, which direction, how the vehicle accelerated. It works anywhere, and its error grows the longer it runs without correction.

What feeds dead reckoning#

The vehicle properties that matter here:

PropertyContribution
PERF_ODOMETERTotal distance travelled
WHEEL_TICKPer-wheel rotation counts — the precise distance source
PERF_VEHICLE_SPEEDCurrent speed
PERF_STEERING_ANGLEWhich way the front wheels point
GEAR_SELECTIONForwards or reverse — the sign of the movement

Where the fusion actually happens#

Here is the part that surprises people: it is usually not in Android.

Reading location is ordinary Android
val locationManager = context.getSystemService(LocationManager::class.java)
 
locationManager.requestLocationUpdates(
    LocationManager.GPS_PROVIDER,
    /* minTimeMs = */ 1000L,
    /* minDistanceM = */ 0f,
    locationListener,
)

Checking positioning health#

What the platform is receiving
# Satellite state, fix quality, which constellations
adb shell dumpsys location | grep -A20 -i gnss
 
# Are the motion inputs arriving?
adb shell dumpsys car_service --get-property 0x11400306   # WHEEL_TICK
adb shell dumpsys car_service --get-property 0x11600204   # PERF_ODOMETER
 
# The GNSS HAL itself
adb shell lshal | grep -i gnss

Ordinary Android sensors#

A head unit also has the sensors a phone has — accelerometer, gyroscope, ambient light — reached through SensorManager exactly as on a phone.

Ambient light, for automatic display dimming
val sensorManager = context.getSystemService(SensorManager::class.java)
val light = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT)
 
sensorManager.registerListener(listener, light, SensorManager.SENSOR_DELAY_NORMAL)

Privacy: location is the most sensitive data here#

Night mode comes from here too#

Automatic day/night switching is driven by a vehicle property rather than the light sensor on many programmes:

adb shell dumpsys car_service --get-property 0x11200407   # NIGHT_MODE
adb shell dumpsys uimode

Next#

The framework module — starting with how Binder actually carries all of this.

References & further reading

Code links target the main branch on cs.android.com. AOSP moves — if a path 404s, search the symbol instead.