diff options
author | Kai Wang <kwangsudo@google.com> | 2018-06-14 20:04:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-06-14 20:04:24 +0000 |
commit | 6db591368f60d249ef4779442c493ac788be42f2 (patch) | |
tree | e0d6017e0803310abdeff0040a12d46acffc836c /car-lib | |
parent | 5b9840513954394c79f9479ad99df005a2d80935 (diff) | |
parent | f571107d283cd219a2390122cd16028e7a65afe9 (diff) | |
download | Car-6db591368f60d249ef4779442c493ac788be42f2.tar.gz |
Merge "Clean up for ENV_OUTSIDE_TEMPERATURE" into pi-dev
Diffstat (limited to 'car-lib')
-rw-r--r-- | car-lib/api/current.txt | 4 | ||||
-rw-r--r-- | car-lib/src/android/car/hardware/CarSensorEvent.java | 43 | ||||
-rw-r--r-- | car-lib/src/android/car/hardware/CarSensorManager.java | 15 |
3 files changed, 42 insertions, 20 deletions
diff --git a/car-lib/api/current.txt b/car-lib/api/current.txt index 9cd2e4c314..8a380ff839 100644 --- a/car-lib/api/current.txt +++ b/car-lib/api/current.txt @@ -265,7 +265,6 @@ package android.car.hardware { field public static final int IGNITION_STATE_ON = 4; // 0x4 field public static final int IGNITION_STATE_START = 5; // 0x5 field public static final int IGNITION_STATE_UNDEFINED = 0; // 0x0 - field public static final int INDEX_ENVIRONMENT_PRESSURE = 1; // 0x1 field public static final int INDEX_ENVIRONMENT_TEMPERATURE = 0; // 0x0 field public static final int INDEX_WHEEL_DISTANCE_FRONT_LEFT = 1; // 0x1 field public static final int INDEX_WHEEL_DISTANCE_FRONT_RIGHT = 2; // 0x2 @@ -280,7 +279,6 @@ package android.car.hardware { } public static class CarSensorEvent.EnvironmentData { - field public float pressure; field public float temperature; field public long timestamp; } @@ -300,7 +298,7 @@ package android.car.hardware { field public static final int SENSOR_RATE_UI = 5; // 0x5 field public static final int SENSOR_TYPE_ABS_ACTIVE = 287310858; // 0x1120040a field public static final int SENSOR_TYPE_CAR_SPEED = 291504647; // 0x11600207 - field public static final int SENSOR_TYPE_ENVIRONMENT = 12; // 0xc + field public static final int SENSOR_TYPE_ENV_OUTSIDE_TEMPERATURE = 291505923; // 0x11600703 field public static final int SENSOR_TYPE_EV_BATTERY_CHARGE_RATE = 291504908; // 0x1160030c field public static final int SENSOR_TYPE_EV_BATTERY_LEVEL = 291504905; // 0x11600309 field public static final int SENSOR_TYPE_EV_CHARGE_PORT_CONNECTED = 287310603; // 0x1120030b 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, |