From e33eb92809ffa1f96a61c31275bb98b14554463d Mon Sep 17 00:00:00 2001
From: Ashutosh Joshi
Date: Tue, 10 Jan 2017 21:55:50 -0800
Subject: [PATCH] Add an uncalibrated acclerometer sensor type.
Adding the uncalibrated accelerometer sensor type.
Test: Build compiles.
Change-Id: I586bd924e0fb90ef4b4a9565f8fbf72a39eccb36
---
api/current.txt | 2 ++
api/system-current.txt | 2 ++
api/test-current.txt | 2 ++
core/java/android/hardware/Sensor.java | 31 +++++++++++++++++++++
core/java/android/hardware/SensorEvent.java | 27 ++++++++++++++++++
5 files changed, 64 insertions(+)
diff --git a/api/current.txt b/api/current.txt
index 8a19a7e72d0d9..906ac85d2576a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -13970,6 +13970,7 @@ package android.hardware {
field public static final int REPORTING_MODE_ON_CHANGE = 1; // 0x1
field public static final int REPORTING_MODE_SPECIAL_TRIGGER = 3; // 0x3
field public static final java.lang.String STRING_TYPE_ACCELEROMETER = "android.sensor.accelerometer";
+ field public static final java.lang.String STRING_TYPE_ACCELEROMETER_UNCALIBRATED = "android.sensor.accelerometer_uncalibrated";
field public static final java.lang.String STRING_TYPE_AMBIENT_TEMPERATURE = "android.sensor.ambient_temperature";
field public static final java.lang.String STRING_TYPE_GAME_ROTATION_VECTOR = "android.sensor.game_rotation_vector";
field public static final java.lang.String STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR = "android.sensor.geomagnetic_rotation_vector";
@@ -13995,6 +13996,7 @@ package android.hardware {
field public static final java.lang.String STRING_TYPE_STEP_DETECTOR = "android.sensor.step_detector";
field public static final deprecated java.lang.String STRING_TYPE_TEMPERATURE = "android.sensor.temperature";
field public static final int TYPE_ACCELEROMETER = 1; // 0x1
+ field public static final int TYPE_ACCELEROMETER_UNCALIBRATED = 35; // 0x23
field public static final int TYPE_ALL = -1; // 0xffffffff
field public static final int TYPE_AMBIENT_TEMPERATURE = 13; // 0xd
field public static final int TYPE_DEVICE_PRIVATE_BASE = 65536; // 0x10000
diff --git a/api/system-current.txt b/api/system-current.txt
index 58fc103215f11..40bea9d2898a6 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -14470,6 +14470,7 @@ package android.hardware {
field public static final int REPORTING_MODE_ON_CHANGE = 1; // 0x1
field public static final int REPORTING_MODE_SPECIAL_TRIGGER = 3; // 0x3
field public static final java.lang.String STRING_TYPE_ACCELEROMETER = "android.sensor.accelerometer";
+ field public static final java.lang.String STRING_TYPE_ACCELEROMETER_UNCALIBRATED = "android.sensor.accelerometer_uncalibrated";
field public static final java.lang.String STRING_TYPE_AMBIENT_TEMPERATURE = "android.sensor.ambient_temperature";
field public static final java.lang.String STRING_TYPE_DYNAMIC_SENSOR_META = "android.sensor.dynamic_sensor_meta";
field public static final java.lang.String STRING_TYPE_GAME_ROTATION_VECTOR = "android.sensor.game_rotation_vector";
@@ -14497,6 +14498,7 @@ package android.hardware {
field public static final deprecated java.lang.String STRING_TYPE_TEMPERATURE = "android.sensor.temperature";
field public static final java.lang.String STRING_TYPE_WRIST_TILT_GESTURE = "android.sensor.wrist_tilt_gesture";
field public static final int TYPE_ACCELEROMETER = 1; // 0x1
+ field public static final int TYPE_ACCELEROMETER_UNCALIBRATED = 35; // 0x23
field public static final int TYPE_ALL = -1; // 0xffffffff
field public static final int TYPE_AMBIENT_TEMPERATURE = 13; // 0xd
field public static final int TYPE_DEVICE_PRIVATE_BASE = 65536; // 0x10000
diff --git a/api/test-current.txt b/api/test-current.txt
index 0129832a07b34..85e11d5fcfdac 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -14001,6 +14001,7 @@ package android.hardware {
field public static final int REPORTING_MODE_ON_CHANGE = 1; // 0x1
field public static final int REPORTING_MODE_SPECIAL_TRIGGER = 3; // 0x3
field public static final java.lang.String STRING_TYPE_ACCELEROMETER = "android.sensor.accelerometer";
+ field public static final java.lang.String STRING_TYPE_ACCELEROMETER_UNCALIBRATED = "android.sensor.accelerometer_uncalibrated";
field public static final java.lang.String STRING_TYPE_AMBIENT_TEMPERATURE = "android.sensor.ambient_temperature";
field public static final java.lang.String STRING_TYPE_GAME_ROTATION_VECTOR = "android.sensor.game_rotation_vector";
field public static final java.lang.String STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR = "android.sensor.geomagnetic_rotation_vector";
@@ -14026,6 +14027,7 @@ package android.hardware {
field public static final java.lang.String STRING_TYPE_STEP_DETECTOR = "android.sensor.step_detector";
field public static final deprecated java.lang.String STRING_TYPE_TEMPERATURE = "android.sensor.temperature";
field public static final int TYPE_ACCELEROMETER = 1; // 0x1
+ field public static final int TYPE_ACCELEROMETER_UNCALIBRATED = 35; // 0x23
field public static final int TYPE_ALL = -1; // 0xffffffff
field public static final int TYPE_AMBIENT_TEMPERATURE = 13; // 0xd
field public static final int TYPE_DEVICE_PRIVATE_BASE = 65536; // 0x10000
diff --git a/core/java/android/hardware/Sensor.java b/core/java/android/hardware/Sensor.java
index c9ae69c93b8ce..06ab13e9c0a5d 100644
--- a/core/java/android/hardware/Sensor.java
+++ b/core/java/android/hardware/Sensor.java
@@ -644,6 +644,31 @@ public final class Sensor {
public static final String STRING_TYPE_DYNAMIC_SENSOR_META =
"android.sensor.dynamic_sensor_meta";
+ /* TYPE_ADDITIONAL_INFO - defined as type 33 in the HAL is not exposed to
+ * applications. There are parts of the framework that require the sensors
+ * to be in the same order as the HAL. Skipping this sensor
+ */
+
+ /* TYPE_LOW_LATENCY_OFF_BODY_SENSOR - defined as type 34 in the HAL needs to
+ * be defined in this space.
+ */
+
+ /**
+ * A constant describing an uncalibrated accelerometer sensor.
+ *
+ * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details.
+ *
+ */
+ public static final int TYPE_ACCELEROMETER_UNCALIBRATED = 35;
+
+ /**
+ * A constant string describing an uncalibrated accelerometer sensor.
+ *
+ * @see #TYPE_ACCELEROMETER_UNCALIBRATED
+ *
+ */
+ public static final String STRING_TYPE_ACCELEROMETER_UNCALIBRATED =
+ "android.sensor.accelerometer_uncalibrated";
/**
* A constant describing all sensor types.
*/
@@ -752,6 +777,9 @@ public final class Sensor {
1, // SENSOR_TYPE_MOTION_DETECT
1, // SENSOR_TYPE_HEART_BEAT
2, // SENSOR_TYPE_DYNAMIC_SENSOR_META
+ 16,// skip over additional sensor info type
+ 1, // reserving for LLOB sensor type
+ 6, // SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED
};
/**
@@ -1123,6 +1151,9 @@ public final class Sensor {
case TYPE_DYNAMIC_SENSOR_META:
mStringType = STRING_TYPE_DYNAMIC_SENSOR_META;
return true;
+ case TYPE_ACCELEROMETER_UNCALIBRATED:
+ mStringType = STRING_TYPE_ACCELEROMETER_UNCALIBRATED;
+ return true;
default:
return false;
}
diff --git a/core/java/android/hardware/SensorEvent.java b/core/java/android/hardware/SensorEvent.java
index 0d96b8e82a5d9..d67b6a89eb63e 100644
--- a/core/java/android/hardware/SensorEvent.java
+++ b/core/java/android/hardware/SensorEvent.java
@@ -578,6 +578,33 @@ public class SensorEvent {
* A confidence value of 1.0 indicates complete certainly - that a peak is
* completely unlikely to be anywhere else on the QRS complex.
*
+ *
+ * {@link android.hardware.Sensor#TYPE_ACCELEROMETER_UNCALIBRATED
+ * Sensor.TYPE_ACCELEROMETER_UNCALIBRATED}:
All values are in SI
+ * units (m/s^2)
+ *
+ * Similar to {@link android.hardware.Sensor#TYPE_ACCELEROMETER},
+ * Factory calibration and temperature compensation will still be applied
+ * to the "uncalibrated" measurement.
+ *
+ *
+ * The values array is shown below:
+ *
+ * - values[0] = x_uncalib without bias compensation
+ * - values[1] = y_uncalib without bias compensation
+ * - values[2] = z_uncalib without bias compensation
+ * - values[3] = estimated x_bias
+ * - values[4] = estimated y_bias
+ * - values[5] = estimated z_bias
+ *
+ *
+ *
+ * x_uncalib, y_uncalib, z_uncalib are the measured acceleration in X, Y, Z
+ * axes similar to the {@link android.hardware.Sensor#TYPE_ACCELEROMETER},
+ * without any bias correction (factory bias compensation and any
+ * temperature compensation is allowed).
+ * x_bias, y_bias, z_bias are the estimated biases.
+ *
*/
public final float[] values;