CarValue

public final class CarValue
extends Object

java.lang.Object
   ↳ androidx.car.app.hardware.common.CarValue<T>


A data value object returned from car hardware with associated metadata including status, timestamp, and the actual value.

Summary

Constants

int STATUS_SUCCESS

CarValue was obtained successfully.

int STATUS_UNAVAILABLE

CarValue attempted for unavailable property, sensor, or action.

int STATUS_UNIMPLEMENTED

CarValue attempted for unimplemented property, sensor, or action.

int STATUS_UNKNOWN

CarValue has unknown status.

Public constructors

CarValue(T value, long timestampMillis, int status)

Constructs a new instance of a CarValue.

Public methods

boolean equals(Object other)
int getStatus()

Returns the status of this particular result such as success, unavailable, or unimplemented.

long getTimestampMillis()

Returns the time in milliseconds at which the event happened.

T getValue()

Returns a the data value or null if the status is not successful.

int hashCode()
String toString()

Inherited methods

Constants

STATUS_SUCCESS

public static final int STATUS_SUCCESS

CarValue was obtained successfully.

Constant Value: 1 (0x00000001)

STATUS_UNAVAILABLE

public static final int STATUS_UNAVAILABLE

CarValue attempted for unavailable property, sensor, or action.

For example, the car hardware might not be able to return a value such as climate at the current time because the engine is off and will set the status to this value.

Constant Value: 3 (0x00000003)

STATUS_UNIMPLEMENTED

public static final int STATUS_UNIMPLEMENTED

CarValue attempted for unimplemented property, sensor, or action.

For example, the car hardware might not be able to return a value such as speed or energy level and will set the status to this value.

Constant Value: 2 (0x00000002)

STATUS_UNKNOWN

public static final int STATUS_UNKNOWN

CarValue has unknown status.

Constant Value: 0 (0x00000000)

Public constructors

CarValue

public CarValue (T value, 
                long timestampMillis, 
                int status)

Constructs a new instance of a CarValue.

Parameters
value T: data to be returned with the result

timestampMillis long: the time in milliseconds when the value was generated (see getTimestampMillis())

status int: the status code associated with this value

Public methods

equals

public boolean equals (Object other)

Parameters
other Object

Returns
boolean

getStatus

public int getStatus ()

Returns the status of this particular result such as success, unavailable, or unimplemented.

Returns
int

getTimestampMillis

public long getTimestampMillis ()

Returns the time in milliseconds at which the event happened.

For a given property, sensor, or action, each new value's timestamp should be monotonically increasing using the same time base as SystemClock.elapsedRealtime().

Returns
long

getValue

public T getValue ()

Returns a the data value or null if the status is not successful.

Returns
T

See also:

hashCode

public int hashCode ()

Returns
int

toString

public String toString ()

Returns
String