There is this function that you can use to get properties.
CarPropertyManager.getProperty()
You need to use constants defined in VehiclePropertyIds
. Here goes the one that could do the trick:
VehiclePropertyIds.ENGINE_RPM. Note that this requires certains permissions.
Also the function seems to take a areaId argument. It's a little confusing but using CarPropertyManager.getAreaId(ENGINE_RPM, VEHICLE_AREA_TYPE_WHEEL)
may yield the required value. Please double-check it as I cannot test it myself.
CarPropertyManager.getProperty(propertyId, areaId)
. This should return a CarPropertyValue
. Then you can use getValue()
.
As for the listener, you may implemented this interface to listen for changes in such properties.
CarPropertyManager.CarPropertyEventCallback
CarPropertyManager.registerCallback(callback, propertyId, refreshRate)
I'll link to registerCallback
documentation https://developer.android.com/reference/android/car/hardware/property/CarPropertyManager#registerCallback(android.car.hardware.property.CarPropertyManager.CarPropertyEventCallback,%20int,%20float)