From 219d4e242be8e32f05d19f4bfd8c7d95e82c5a5f Mon Sep 17 00:00:00 2001
From: Eva Chen
Date: Fri, 9 Apr 2021 15:08:38 -0700
Subject: [PATCH] Add limited axes sensor types to sensor framework.
Includes changes for the following sensors:
- SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES
- SENSOR_TYPE_GYROSCOPE_LIMITED_AXES
- SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
- SENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
These changes will enable support for automotive style IMUs that have
more limited axes for accelerometers (x-axis and y-axis) and gyroscopes
(z-axis).
Bug: 187342209
Test: Compiled
Change-Id: I7030501ddfba5ee51d9e3e51a8e25d7c6708cb68
---
core/api/current.txt | 8 ++
core/java/android/hardware/Sensor.java | 84 ++++++++++++++++
core/java/android/hardware/SensorEvent.java | 103 ++++++++++++++++++++
3 files changed, 195 insertions(+)
diff --git a/core/api/current.txt b/core/api/current.txt
index dddf069c6695e..bb548929c0b25 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -16870,12 +16870,16 @@ 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 String STRING_TYPE_ACCELEROMETER = "android.sensor.accelerometer";
+ field public static final String STRING_TYPE_ACCELEROMETER_LIMITED_AXES = "android.sensor.accelerometer_limited_axes";
+ field public static final String STRING_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED = "android.sensor.accelerometer_limited_axes_uncalibrated";
field public static final String STRING_TYPE_ACCELEROMETER_UNCALIBRATED = "android.sensor.accelerometer_uncalibrated";
field public static final String STRING_TYPE_AMBIENT_TEMPERATURE = "android.sensor.ambient_temperature";
field public static final String STRING_TYPE_GAME_ROTATION_VECTOR = "android.sensor.game_rotation_vector";
field public static final String STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR = "android.sensor.geomagnetic_rotation_vector";
field public static final String STRING_TYPE_GRAVITY = "android.sensor.gravity";
field public static final String STRING_TYPE_GYROSCOPE = "android.sensor.gyroscope";
+ field public static final String STRING_TYPE_GYROSCOPE_LIMITED_AXES = "android.sensor.gyroscope_limited_axes";
+ field public static final String STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED = "android.sensor.gyroscope_limited_axes_uncalibrated";
field public static final String STRING_TYPE_GYROSCOPE_UNCALIBRATED = "android.sensor.gyroscope_uncalibrated";
field public static final String STRING_TYPE_HEAD_TRACKER = "android.sensor.head_tracker";
field public static final String STRING_TYPE_HEART_BEAT = "android.sensor.heart_beat";
@@ -16899,6 +16903,8 @@ package android.hardware {
field public static final String STRING_TYPE_STEP_DETECTOR = "android.sensor.step_detector";
field @Deprecated public static final String STRING_TYPE_TEMPERATURE = "android.sensor.temperature";
field public static final int TYPE_ACCELEROMETER = 1; // 0x1
+ field public static final int TYPE_ACCELEROMETER_LIMITED_AXES = 38; // 0x26
+ field public static final int TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED = 40; // 0x28
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
@@ -16907,6 +16913,8 @@ package android.hardware {
field public static final int TYPE_GEOMAGNETIC_ROTATION_VECTOR = 20; // 0x14
field public static final int TYPE_GRAVITY = 9; // 0x9
field public static final int TYPE_GYROSCOPE = 4; // 0x4
+ field public static final int TYPE_GYROSCOPE_LIMITED_AXES = 39; // 0x27
+ field public static final int TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED = 41; // 0x29
field public static final int TYPE_GYROSCOPE_UNCALIBRATED = 16; // 0x10
field public static final int TYPE_HEAD_TRACKER = 37; // 0x25
field public static final int TYPE_HEART_BEAT = 31; // 0x1f
diff --git a/core/java/android/hardware/Sensor.java b/core/java/android/hardware/Sensor.java
index 37cfb4935f0d3..166ae451fb6dd 100644
--- a/core/java/android/hardware/Sensor.java
+++ b/core/java/android/hardware/Sensor.java
@@ -725,6 +725,74 @@ public final class Sensor {
*/
public static final String STRING_TYPE_HEAD_TRACKER = "android.sensor.head_tracker";
+ /**
+ * A constant describing a limited axes accelerometer sensor.
+ *
+ * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details.
+ *
+ */
+ public static final int TYPE_ACCELEROMETER_LIMITED_AXES = 38;
+
+ /**
+ * A constant string describing a limited axes accelerometer sensor.
+ *
+ * @see #TYPE_ACCELEROMETER_LIMITED_AXES
+ *
+ */
+ public static final String STRING_TYPE_ACCELEROMETER_LIMITED_AXES =
+ "android.sensor.accelerometer_limited_axes";
+
+ /**
+ * A constant describing a limited axes gyroscope sensor.
+ *
+ * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details.
+ *
+ */
+ public static final int TYPE_GYROSCOPE_LIMITED_AXES = 39;
+
+ /**
+ * A constant string describing a limited axes gyroscope sensor.
+ *
+ * @see #TYPE_GYROSCOPE_LIMITED_AXES
+ *
+ */
+ public static final String STRING_TYPE_GYROSCOPE_LIMITED_AXES =
+ "android.sensor.gyroscope_limited_axes";
+
+ /**
+ * A constant describing an uncalibrated limited axes accelerometer sensor.
+ *
+ * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details.
+ *
+ */
+ public static final int TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED = 40;
+
+ /**
+ * A constant string describing an uncalibrated limited axes accelerometer sensor.
+ *
+ * @see #TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
+ *
+ */
+ public static final String STRING_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED =
+ "android.sensor.accelerometer_limited_axes_uncalibrated";
+
+ /**
+ * A constant describing an uncalibrated limited axes gyroscope sensor.
+ *
+ * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details.
+ *
+ */
+ public static final int TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED = 41;
+
+ /**
+ * A constant string describing an uncalibrated limited axes gyroscope sensor.
+ *
+ * @see #TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
+ *
+ */
+ public static final String STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED =
+ "android.sensor.gyroscope_limited_axes_uncalibrated";
+
/**
* A constant describing all sensor types.
*/
@@ -846,6 +914,10 @@ public final class Sensor {
6, // SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED
1, // SENSOR_TYPE_HINGE_ANGLE
6, // SENSOR_TYPE_HEAD_TRACKER (discontinuity count is excluded)
+ 6, // SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES
+ 6, // SENSOR_TYPE_GYROSCOPE_LIMITED_AXES
+ 9, // SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
+ 9, // SENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
};
/**
@@ -1301,6 +1373,18 @@ public final class Sensor {
case TYPE_HEAD_TRACKER:
mStringType = STRING_TYPE_HEAD_TRACKER;
return true;
+ case TYPE_ACCELEROMETER_LIMITED_AXES:
+ mStringType = STRING_TYPE_ACCELEROMETER_LIMITED_AXES;
+ return true;
+ case TYPE_GYROSCOPE_LIMITED_AXES:
+ mStringType = STRING_TYPE_GYROSCOPE_LIMITED_AXES;
+ return true;
+ case TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED:
+ mStringType = STRING_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED;
+ return true;
+ case TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED:
+ mStringType = STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED;
+ return true;
default:
return false;
}
diff --git a/core/java/android/hardware/SensorEvent.java b/core/java/android/hardware/SensorEvent.java
index c77c8cc635e68..7da136f73c533 100644
--- a/core/java/android/hardware/SensorEvent.java
+++ b/core/java/android/hardware/SensorEvent.java
@@ -676,6 +676,109 @@ public class SensorEvent {
* values[5] : Z component of Euler vector representing angular velocity
*
*
+ * {@link android.hardware.Sensor#TYPE_ACCELEROMETER_LIMITED_AXES
+ * Sensor.TYPE_ACCELEROMETER_LIMITED_AXES}:
+ *
Equivalent to TYPE_ACCELEROMETER, but supporting cases where one
+ * or two axes are not supported.
+ *
+ * The last three values represent whether the acceleration value for a
+ * given axis is supported. A value of 1.0 indicates that the axis is
+ * supported, while a value of 0 means it isn't supported. The supported
+ * axes should be determined at build time and these values do not change
+ * during runtime.
+ *
+ * The acceleration values for axes that are not supported are set to 0.
+ *
+ * Similar to {@link android.hardware.Sensor#TYPE_ACCELEROMETER}.
+ *
+ *
+ * - values[0]: Acceleration minus Gx on the x-axis (if supported)
+ * - values[1]: Acceleration minus Gy on the y-axis (if supported)
+ * - values[2]: Acceleration minus Gz on the z-axis (if supported)
+ * - values[3]: Acceleration supported for x-axis
+ * - values[4]: Acceleration supported for y-axis
+ * - values[5]: Acceleration supported for z-axis
+ *
+ *
+ * {@link android.hardware.Sensor#TYPE_GYROSCOPE_LIMITED_AXES
+ * Sensor.TYPE_GYROSCOPE_LIMITED_AXES}:
+ *
Equivalent to TYPE_GYROSCOPE, but supporting cases where one or two
+ * axes are not supported.
+ *
+ * The last three values represent whether the angular speed value for a
+ * given axis is supported. A value of 1.0 indicates that the axis is
+ * supported, while a value of 0 means it isn't supported. The supported
+ * axes should be determined at build time and these values do not change
+ * during runtime.
+ *
+ * The angular speed values for axes that are not supported are set to 0.
+ *
+ * Similar to {@link android.hardware.Sensor#TYPE_GYROSCOPE}.
+ *
+ *
+ * - values[0]: Angular speed around the x-axis (if supported)
+ * - values[1]: Angular speed around the y-axis (if supported)
+ * - values[2]: Angular speed around the z-axis (if supported)
+ * - values[3]: Angular speed supported for x-axis
+ * - values[4]: Angular speed supported for y-axis
+ * - values[5]: Angular speed supported for z-axis
+ *
+ *
+ *
+ *
{@link android.hardware.Sensor#TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
+ * Sensor.TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED}:
+ *
Equivalent to TYPE_ACCELEROMETER_UNCALIBRATED, but supporting cases
+ * where one or two axes are not supported.
+ *
+ * The last three values represent whether the acceleration value for a
+ * given axis is supported. A value of 1.0 indicates that the axis is
+ * supported, while a value of 0 means it isn't supported. The supported
+ * axes should be determined at build time and these values do not change
+ * during runtime.
+ *
+ * The acceleration values and bias values for axes that are not supported
+ * are set to 0.
+ *
+ *
+ * - values[0]: x_uncalib without bias compensation (if supported)
+ * - values[1]: y_uncalib without bias compensation (if supported)
+ * - values[2]: z_uncalib without bias compensation (if supported)
+ * - values[3]: estimated x_bias (if supported)
+ * - values[4]: estimated y_bias (if supported)
+ * - values[5]: estimated z_bias (if supported)
+ * - values[6]: Acceleration supported for x-axis
+ * - values[7]: Acceleration supported for y-axis
+ * - values[8]: Acceleration supported for z-axis
+ *
+ *
+ *
+ * {@link android.hardware.Sensor#TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
+ * Sensor.TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED}:
+ *
Equivalent to TYPE_GYROSCOPE_UNCALIBRATED, but supporting cases
+ * where one or two axes are not supported.
+ *
+ * The last three values represent whether the angular speed value for a
+ * given axis is supported. A value of 1.0 indicates that the axis is
+ * supported, while a value of 0 means it isn't supported. The supported
+ * axes should be determined at build time and these values do not change
+ * during runtime.
+ *
+ * The angular speed values and drift values for axes that are not supported
+ * are set to 0.
+ *
+ *
+ * - values[0]: Angular speed (w/o drift compensation) around the X axis (if supported)
+ * - values[1]: Angular speed (w/o drift compensation) around the Y axis (if supported)
+ * - values[2]: Angular speed (w/o drift compensation) around the Z axis (if supported)
+ * - values[3]: estimated drift around X axis (if supported)
+ * - values[4]: estimated drift around Y axis (if supported)
+ * - values[5]: estimated drift around Z axis (if supported)
+ * - values[6]: Angular speed supported for x-axis
+ * - values[7]: Angular speed supported for y-axis
+ * - values[8]: Angular speed supported for z-axis
+ *
+ *
+ *
* @see GeomagneticField
*/
public final float[] values;