CarSensorEvent
public
class
CarSensorEvent
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.car.hardware.CarSensorEvent |
This class was deprecated
in API level 29.
consider using CarPropertyValue
and
CarPropertyManager
instead.
A CarSensorEvent object corresponds to a single sensor event coming from the car. The sensor
data is stored in a sensor-type specific format in the object's float and byte arrays.
To aid unmarshalling the object's data arrays, this class provides static nested classes and
conversion methods. The conversion methods each have an optional data parameter which,
if not null, will be used and returned. This parameter should be used to avoid unnecessary
object churn whenever possible. Additionally, calling a conversion method on a CarSensorEvent
object with an inappropriate type will result in an UnsupportedOperationException
being thrown.
Summary
Nested classes | |
---|---|
class |
CarSensorEvent.EnvironmentData
Environment data with timestamp and temperature. |
Constants | |
---|---|
int |
GEAR_DRIVE
This is for transmission without specific gear number for moving forward like CVT. |
int |
GEAR_EIGHTH
Gear number 8. |
int |
GEAR_FIFTH
Gear number 5. |
int |
GEAR_FIRST
intValues[0] from 1 to 99 represents transmission gear number for moving forward. |
int |
GEAR_FOURTH
Gear number 4. |
int |
GEAR_NEUTRAL
GEAR_* represents meaning of intValues[0] for |
int |
GEAR_NINTH
Gear number 9. |
int |
GEAR_PARK
Gear in parking state |
int |
GEAR_REVERSE
Gear in reverse |
int |
GEAR_SECOND
Gear number 2. |
int |
GEAR_SEVENTH
Gear number 7. |
int |
GEAR_SIXTH
Gear number 6. |
int |
GEAR_TENTH
Gear number 10. |
int |
GEAR_THIRD
Gear number 3. |
int |
IGNITION_STATE_ACC
Accessory is turned off, but engine is not running yet (for EV car is not ready to move). |
int |
IGNITION_STATE_LOCK
Steering wheel is locked. |
int |
IGNITION_STATE_OFF
Typically engine is off, but steering wheel is unlocked. |
int |
IGNITION_STATE_ON
In this state engine typically is running (for EV, car is ready to move). |
int |
IGNITION_STATE_START
In this state engine is typically starting (cranking). |
int |
IGNITION_STATE_UNDEFINED
Ignition state is unknown. |
int |
INDEX_ENVIRONMENT_TEMPERATURE
Index for |
int |
INDEX_WHEEL_DISTANCE_FRONT_LEFT
|
int |
INDEX_WHEEL_DISTANCE_FRONT_RIGHT
|
int |
INDEX_WHEEL_DISTANCE_REAR_LEFT
|
int |
INDEX_WHEEL_DISTANCE_REAR_RIGHT
|
int |
INDEX_WHEEL_DISTANCE_RESET_COUNT
Index for |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<CarSensorEvent> |
CREATOR
|
public
final
float[] |
floatValues
array holding float type of sensor data. |
public
final
int[] |
intValues
array holding int type of sensor data |
public
final
long[] |
longValues
array holding long int type of sensor data |
public
int |
sensorType
Sensor type for this event like |
public
long |
timestamp
When this data was received from car. |
Public methods | |
---|---|
int
|
describeContents()
|
void
|
writeToParcel(Parcel dest, int flags)
|
Inherited methods | |
---|---|
Constants
GEAR_DRIVE
public static final int GEAR_DRIVE
This is for transmission without specific gear number for moving forward like CVT. It tells that car is in a transmission state to move it forward.
Constant Value: 8 (0x00000008)
GEAR_EIGHTH
public static final int GEAR_EIGHTH
Gear number 8.
Constant Value: 2048 (0x00000800)
GEAR_FIFTH
public static final int GEAR_FIFTH
Gear number 5.
Constant Value: 256 (0x00000100)
GEAR_FIRST
public static final int GEAR_FIRST
intValues[0] from 1 to 99 represents transmission gear number for moving forward. GEAR_FIRST is for gear number 1.
Constant Value: 16 (0x00000010)
GEAR_FOURTH
public static final int GEAR_FOURTH
Gear number 4.
Constant Value: 128 (0x00000080)
GEAR_NEUTRAL
public static final int GEAR_NEUTRAL
GEAR_* represents meaning of intValues[0] for CarSensorManager#SENSOR_TYPE_GEAR
sensor type.
GEAR_NEUTRAL means transmission gear is in neutral state, and the car may be moving.
Constant Value: 1 (0x00000001)
GEAR_NINTH
public static final int GEAR_NINTH
Gear number 9.
Constant Value: 4096 (0x00001000)
GEAR_PARK
public static final int GEAR_PARK
Gear in parking state
Constant Value: 4 (0x00000004)
GEAR_REVERSE
public static final int GEAR_REVERSE
Gear in reverse
Constant Value: 2 (0x00000002)
GEAR_SECOND
public static final int GEAR_SECOND
Gear number 2.
Constant Value: 32 (0x00000020)
GEAR_SEVENTH
public static final int GEAR_SEVENTH
Gear number 7.
Constant Value: 1024 (0x00000400)
GEAR_SIXTH
public static final int GEAR_SIXTH
Gear number 6.
Constant Value: 512 (0x00000200)
GEAR_TENTH
public static final int GEAR_TENTH
Gear number 10.
Constant Value: 8192 (0x00002000)
GEAR_THIRD
public static final int GEAR_THIRD
Gear number 3.
Constant Value: 64 (0x00000040)
IGNITION_STATE_ACC
public static final int IGNITION_STATE_ACC
Accessory is turned off, but engine is not running yet (for EV car is not ready to move).
Constant Value: 3 (0x00000003)
IGNITION_STATE_LOCK
public static final int IGNITION_STATE_LOCK
Steering wheel is locked.
Constant Value: 1 (0x00000001)
IGNITION_STATE_OFF
public static final int IGNITION_STATE_OFF
Typically engine is off, but steering wheel is unlocked.
Constant Value: 2 (0x00000002)
IGNITION_STATE_ON
public static final int IGNITION_STATE_ON
In this state engine typically is running (for EV, car is ready to move).
Constant Value: 4 (0x00000004)
IGNITION_STATE_START
public static final int IGNITION_STATE_START
In this state engine is typically starting (cranking).
Constant Value: 5 (0x00000005)
IGNITION_STATE_UNDEFINED
public static final int IGNITION_STATE_UNDEFINED
Ignition state is unknown.
The constants that starts with IGNITION_STATE_ represent values for
CarSensorManager#SENSOR_TYPE_IGNITION_STATE
sensor.
Constant Value: 0 (0x00000000)
INDEX_ENVIRONMENT_TEMPERATURE
public static final int INDEX_ENVIRONMENT_TEMPERATURE
Index for CarSensorManager#SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE
in floatValues.
Temperature in Celsius degrees.
Constant Value: 0 (0x00000000)
INDEX_WHEEL_DISTANCE_FRONT_LEFT
public static final int INDEX_WHEEL_DISTANCE_FRONT_LEFT
Constant Value: 1 (0x00000001)
INDEX_WHEEL_DISTANCE_FRONT_RIGHT
public static final int INDEX_WHEEL_DISTANCE_FRONT_RIGHT
Constant Value: 2 (0x00000002)
INDEX_WHEEL_DISTANCE_REAR_LEFT
public static final int INDEX_WHEEL_DISTANCE_REAR_LEFT
Constant Value: 4 (0x00000004)
INDEX_WHEEL_DISTANCE_REAR_RIGHT
public static final int INDEX_WHEEL_DISTANCE_REAR_RIGHT
Constant Value: 3 (0x00000003)
INDEX_WHEEL_DISTANCE_RESET_COUNT
public static final int INDEX_WHEEL_DISTANCE_RESET_COUNT
Index for CarSensorManager#SENSOR_TYPE_WHEEL_TICK_DISTANCE
in longValues. RESET_COUNT
is incremented whenever the HAL detects that a sensor reset has occurred. It represents to
the upper layer that the WHEEL_DISTANCE values will not be contiguous with other values
reported with a different RESET_COUNT.
Constant Value: 0 (0x00000000)
Fields
CREATOR
public static final Creator<CarSensorEvent> CREATOR
floatValues
public final float[] floatValues
array holding float type of sensor data. If the sensor has single value, only floatValues[0] should be used.
intValues
public final int[] intValues
array holding int type of sensor data
longValues
public final long[] longValues
array holding long int type of sensor data
sensorType
public int sensorType
Sensor type for this event like CarSensorManager#SENSOR_TYPE_CAR_SPEED
.
timestamp
public long timestamp
When this data was received from car. It is elapsed real-time of data reception from car in nanoseconds since system boot.
Public methods
describeContents
public int describeContents ()
Returns | |
---|---|
int |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Parameters | |
---|---|
dest |
Parcel |
flags |
int |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.