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
This commit is contained in:
Eva Chen
2021-04-09 15:08:38 -07:00
parent 7fc36cc40e
commit 219d4e242b
3 changed files with 195 additions and 0 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;