Merge "Add TYPE_HEADING sensor type to sensor framework."

This commit is contained in:
Eva Chen
2022-02-07 08:34:49 +00:00
committed by Android (Google) Code Review
3 changed files with 39 additions and 0 deletions

View File

@@ -16885,6 +16885,7 @@ package android.hardware {
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_HEADING = "android.sensor.heading";
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";
field public static final String STRING_TYPE_HEART_RATE = "android.sensor.heart_rate";
@@ -16920,6 +16921,7 @@ package android.hardware {
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_HEADING = 42; // 0x2a
field public static final int TYPE_HEAD_TRACKER = 37; // 0x25
field public static final int TYPE_HEART_BEAT = 31; // 0x1f
field public static final int TYPE_HEART_RATE = 21; // 0x15

View File

@@ -793,6 +793,21 @@ public final class Sensor {
public static final String STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED =
"android.sensor.gyroscope_limited_axes_uncalibrated";
/**
* A constant string describing a heading sensor.
*
* See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details.
*/
public static final int TYPE_HEADING = 42;
/**
* A constant string describing a heading sensor.
*
* @see #TYPE_HEADING
*
*/
public static final String STRING_TYPE_HEADING = "android.sensor.heading";
/**
* A constant describing all sensor types.
*/
@@ -918,6 +933,7 @@ public final class Sensor {
6, // SENSOR_TYPE_GYROSCOPE_LIMITED_AXES
9, // SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
9, // SENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
2, // SENSOR_TYPE_HEADING
};
/**
@@ -1385,6 +1401,9 @@ public final class Sensor {
case TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED:
mStringType = STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED;
return true;
case TYPE_HEADING:
mStringType = STRING_TYPE_HEADING;
return true;
default:
return false;
}

View File

@@ -779,6 +779,24 @@ public class SensorEvent {
* </ul>
* </p>
*
* <h4>{@link android.hardware.Sensor#TYPE_HEADING Sensor.TYPE_HEADING}:</h4>
*
* A sensor of this type measures the direction in which the device is
* pointing relative to true north in degrees. The value must be between
* 0.0 (inclusive) and 360.0 (exclusive), with 0 indicating north, 90 east,
* 180 south, and 270 west.
*
* Accuracy is defined at 68% confidence. In the case where the underlying
* distribution is assumed Gaussian normal, this would be considered one
* standard deviation. For example, if heading returns 60 degrees, and
* accuracy returns 10 degrees, then there is a 68 percent probability of
* the true heading being between 50 degrees and 70 degrees.
*
* <ul>
* <li> values[0]: Measured heading in degrees.</li>
* <li> values[1]: Heading accuracy in degrees.</li>
* </ul>
*
* @see GeomagneticField
*/
public final float[] values;