diff options
author | Kai <kwangsudo@google.com> | 2018-06-07 16:25:46 -0700 |
---|---|---|
committer | Kai Wang <kwangsudo@google.com> | 2018-06-13 23:52:02 +0000 |
commit | f571107d283cd219a2390122cd16028e7a65afe9 (patch) | |
tree | 9eaf7a56b7cdad1cf168ae96809397aa13ce348b /car-lib/src/android | |
parent | 6d7fa556fd78caa490d5a03f4c77b19d97fca722 (diff) | |
download | Car-f571107d283cd219a2390122cd16028e7a65afe9.tar.gz |
Clean up for ENV_OUTSIDE_TEMPERATURE
Replace SENSOR_TYPE_ENVIRONMENT with ENV_OUTSIDE_TEMPERATURE.
Correct permission of ENV_OUTSIDE_TEMPERATURE in
PropertyHalServiceIds.
Bug: 109742155
Test: runtest -x packages/services/Car/tests/android_car_api_test
runtest -x packages/services/Car/tests/carservice_unit_test
Change-Id: I28b3567407d81584711b1f27ca98892e1b56d1e5
Diffstat (limited to 'car-lib/src/android')
-rw-r--r-- | car-lib/src/android/car/hardware/CarSensorEvent.java | 43 | ||||
-rw-r--r-- | car-lib/src/android/car/hardware/CarSensorManager.java | 15 |
2 files changed, 41 insertions, 17 deletions
diff --git a/car-lib/src/android/car/hardware/CarSensorEvent.java b/car-lib/src/android/car/hardware/CarSensorEvent.java index 86af0637a7..8cba0a27f8 100644 --- a/car-lib/src/android/car/hardware/CarSensorEvent.java +++ b/car-lib/src/android/car/hardware/CarSensorEvent.java @@ -92,15 +92,11 @@ public class CarSensorEvent implements Parcelable { public static final int IGNITION_STATE_START = 5; /** - * Index for {@link CarSensorManager#SENSOR_TYPE_ENVIRONMENT} in floatValues. + * Index for {@link CarSensorManager#SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE} in floatValues. * Temperature in Celsius degrees. */ public static final int INDEX_ENVIRONMENT_TEMPERATURE = 0; - /** - * Index for {@link CarSensorManager#SENSOR_TYPE_ENVIRONMENT} in floatValues. - * Pressure in kPa. - */ - public static final int INDEX_ENVIRONMENT_PRESSURE = 1; + /** * Index for {@link 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 @@ -208,8 +204,6 @@ public class CarSensorEvent implements Parcelable { public long timestamp; /** If unsupported by the car, this value is NaN. */ public float temperature; - /** If unsupported by the car, this value is NaN. */ - public float pressure; /** @hide */ private EnvironmentData() {}; @@ -217,7 +211,7 @@ public class CarSensorEvent implements Parcelable { /** * Convenience method for obtaining an {@link EnvironmentData} object from a CarSensorEvent - * object with type {@link CarSensorManager#SENSOR_TYPE_ENVIRONMENT}. + * object with type {@link CarSensorManager#SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE}. * * @param data an optional output parameter which, if non-null, will be used by this method * instead of a newly created object. @@ -225,13 +219,40 @@ public class CarSensorEvent implements Parcelable { * @hide */ public EnvironmentData getEnvironmentData(EnvironmentData data) { - checkType(CarSensorManager.SENSOR_TYPE_ENVIRONMENT); + checkType(CarSensorManager.SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE); if (data == null) { data = new EnvironmentData(); } data.timestamp = timestamp; data.temperature = floatValues[INDEX_ENVIRONMENT_TEMPERATURE]; - data.pressure = floatValues[INDEX_ENVIRONMENT_PRESSURE]; + return data; + } + + /** @hide*/ + public static class IgnitionStateData { + public long timestamp; + public int ignitionState; + + /** @hide */ + private IgnitionStateData() {}; + } + + /** + * Convenience method for obtaining a {@link IgnitionStateData} object from a CarSensorEvent + * object with type {@link CarSensorManager#SENSOR_TYPE_IGNITION_STATE}. + * + * @param data an optional output parameter which, if non-null, will be used by this method + * instead of a newly created object. + * @return a IgnitionStateData object corresponding to the data contained in the CarSensorEvent. + * @hide + */ + public IgnitionStateData getIgnitionStateData(IgnitionStateData data) { + checkType(CarSensorManager.SENSOR_TYPE_IGNITION_STATE); + if (data == null) { + data = new IgnitionStateData(); + } + data.timestamp = timestamp; + data.ignitionState = intValues[0]; return data; } diff --git a/car-lib/src/android/car/hardware/CarSensorManager.java b/car-lib/src/android/car/hardware/CarSensorManager.java index 253660462f..338d74f417 100644 --- a/car-lib/src/android/car/hardware/CarSensorManager.java +++ b/car-lib/src/android/car/hardware/CarSensorManager.java @@ -91,14 +91,17 @@ public final class CarSensorManager implements CarManagerBase { * Day/night sensor. Sensor data is intValues[0]. */ public static final int SENSOR_TYPE_NIGHT = 0x11200407; + /** + * Outside Environment like temperature. + * This requires {@link Car#PERMISSION_EXTERIOR_ENVIRONMENT} permission. + */ + public static final int SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE = 0x11600703; /** @hide */ public static final int SENSOR_TYPE_RESERVED10 = 10; /** @hide */ public static final int SENSOR_TYPE_RESERVED11 = 11; - /** - * Environment like temperature and pressure. - */ - public static final int SENSOR_TYPE_ENVIRONMENT = 12; + /** @hide */ + public static final int SENSOR_TYPE_RESERVED12 = 12; /** @hide */ public static final int SENSOR_TYPE_RESERVED13 = 13; /** @hide */ @@ -186,7 +189,7 @@ public final class CarSensorManager implements CarManagerBase { SENSOR_TYPE_PARKING_BRAKE, SENSOR_TYPE_GEAR, SENSOR_TYPE_NIGHT, - SENSOR_TYPE_ENVIRONMENT, + SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE, SENSOR_TYPE_IGNITION_STATE, SENSOR_TYPE_WHEEL_TICK_DISTANCE, SENSOR_TYPE_ABS_ACTIVE, @@ -209,7 +212,7 @@ public final class CarSensorManager implements CarManagerBase { SENSOR_TYPE_PARKING_BRAKE, SENSOR_TYPE_GEAR, SENSOR_TYPE_NIGHT, - SENSOR_TYPE_ENVIRONMENT, + SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE, SENSOR_TYPE_IGNITION_STATE, SENSOR_TYPE_WHEEL_TICK_DISTANCE, SENSOR_TYPE_ABS_ACTIVE, |