summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorEva Chen <evaschen@google.com>2021-04-09 15:08:38 -0700
committerEva Chen <evaschen@google.com>2022-02-03 13:51:44 -0800
commit219d4e242be8e32f05d19f4bfd8c7d95e82c5a5f (patch)
tree1e44107d0fcbd35b0f0ac09ce4e5c1e896d068b6 /core/java/android
parent7fc36cc40ee4cd8b185e0b316afe2b9247c742f2 (diff)
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
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/hardware/Sensor.java84
-rw-r--r--core/java/android/hardware/SensorEvent.java103
2 files changed, 187 insertions, 0 deletions
diff --git a/core/java/android/hardware/Sensor.java b/core/java/android/hardware/Sensor.java
index 37cfb4935f0d..166ae451fb6d 100644
--- a/core/java/android/hardware/Sensor.java
+++ b/core/java/android/hardware/Sensor.java
@@ -726,6 +726,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 c77c8cc635e6..7da136f73c53 100644
--- a/core/java/android/hardware/SensorEvent.java
+++ b/core/java/android/hardware/SensorEvent.java
@@ -676,6 +676,109 @@ public class SensorEvent {
* <li> values[5] : Z component of Euler vector representing angular velocity</li>
* </ul>
*
+ * <h4>{@link android.hardware.Sensor#TYPE_ACCELEROMETER_LIMITED_AXES
+ * Sensor.TYPE_ACCELEROMETER_LIMITED_AXES}:
+ * </h4> 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}.
+ *
+ * <ul>
+ * <li> values[0]: Acceleration minus Gx on the x-axis (if supported)</li>
+ * <li> values[1]: Acceleration minus Gy on the y-axis (if supported)</li>
+ * <li> values[2]: Acceleration minus Gz on the z-axis (if supported)</li>
+ * <li> values[3]: Acceleration supported for x-axis</li>
+ * <li> values[4]: Acceleration supported for y-axis</li>
+ * <li> values[5]: Acceleration supported for z-axis</li>
+ * </ul>
+ *
+ * <h4>{@link android.hardware.Sensor#TYPE_GYROSCOPE_LIMITED_AXES
+ * Sensor.TYPE_GYROSCOPE_LIMITED_AXES}:
+ * </h4> 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}.
+ *
+ * <ul>
+ * <li> values[0]: Angular speed around the x-axis (if supported)</li>
+ * <li> values[1]: Angular speed around the y-axis (if supported)</li>
+ * <li> values[2]: Angular speed around the z-axis (if supported)</li>
+ * <li> values[3]: Angular speed supported for x-axis</li>
+ * <li> values[4]: Angular speed supported for y-axis</li>
+ * <li> values[5]: Angular speed supported for z-axis</li>
+ * </ul>
+ * <p>
+ *
+ * <h4>{@link android.hardware.Sensor#TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
+ * Sensor.TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED}:
+ * </h4> 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.
+ *
+ * <ul>
+ * <li> values[0]: x_uncalib without bias compensation (if supported)</li>
+ * <li> values[1]: y_uncalib without bias compensation (if supported)</li>
+ * <li> values[2]: z_uncalib without bias compensation (if supported)</li>
+ * <li> values[3]: estimated x_bias (if supported)</li>
+ * <li> values[4]: estimated y_bias (if supported)</li>
+ * <li> values[5]: estimated z_bias (if supported)</li>
+ * <li> values[6]: Acceleration supported for x-axis</li>
+ * <li> values[7]: Acceleration supported for y-axis</li>
+ * <li> values[8]: Acceleration supported for z-axis</li>
+ * </ul>
+ * </p>
+ *
+ * <h4> {@link android.hardware.Sensor#TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
+ * Sensor.TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED}:
+ * </h4> 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.
+ *
+ * <ul>
+ * <li> values[0]: Angular speed (w/o drift compensation) around the X axis (if supported)</li>
+ * <li> values[1]: Angular speed (w/o drift compensation) around the Y axis (if supported)</li>
+ * <li> values[2]: Angular speed (w/o drift compensation) around the Z axis (if supported)</li>
+ * <li> values[3]: estimated drift around X axis (if supported)</li>
+ * <li> values[4]: estimated drift around Y axis (if supported)</li>
+ * <li> values[5]: estimated drift around Z axis (if supported)</li>
+ * <li> values[6]: Angular speed supported for x-axis</li>
+ * <li> values[7]: Angular speed supported for y-axis</li>
+ * <li> values[8]: Angular speed supported for z-axis</li>
+ * </ul>
+ * </p>
+ *
* @see GeomagneticField
*/
public final float[] values;