Add HEAD_TRACKER sensor type definition
This new sensor type supports tracking the orientation and rate of
rotation of a user's head, which can be useful for features such as
spatial audio.
Bug: 210156629
Test: compile only; to be validated in later CLs
Change-Id: I861be09d14e208fb992b23554b6c0733e4163f0c
diff --git a/sensors/aidl/Android.bp b/sensors/aidl/Android.bp
index fd1ac44..7324abf 100644
--- a/sensors/aidl/Android.bp
+++ b/sensors/aidl/Android.bp
@@ -1,5 +1,3 @@
-// This is the expected build file, but it may not be right in all cases
-
aidl_interface {
name: "android.hardware.sensors",
vendor_available: true,
diff --git a/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/Event.aidl b/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/Event.aidl
index 186b2be..c92ab1a 100644
--- a/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/Event.aidl
+++ b/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/Event.aidl
@@ -51,6 +51,7 @@
android.hardware.sensors.DynamicSensorInfo dynamic;
android.hardware.sensors.AdditionalInfo additional;
android.hardware.sensors.Event.EventPayload.Data data;
+ android.hardware.sensors.Event.EventPayload.HeadTracker headTracker;
@FixedSize @VintfStability
parcelable Vec4 {
float x;
@@ -75,6 +76,16 @@
float zBias;
}
@FixedSize @VintfStability
+ parcelable HeadTracker {
+ float rx;
+ float ry;
+ float rz;
+ float vx;
+ float vy;
+ float vz;
+ int discontinuityCount;
+ }
+ @FixedSize @VintfStability
parcelable HeartRate {
float bpm;
android.hardware.sensors.SensorStatus status;
diff --git a/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/SensorType.aidl b/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/SensorType.aidl
index 4f3b5b2..3d7ab45 100644
--- a/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/SensorType.aidl
+++ b/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/SensorType.aidl
@@ -70,5 +70,6 @@
LOW_LATENCY_OFFBODY_DETECT = 34,
ACCELEROMETER_UNCALIBRATED = 35,
HINGE_ANGLE = 36,
+ HEAD_TRACKER = 37,
DEVICE_PRIVATE_BASE = 65536,
}
diff --git a/sensors/aidl/android/hardware/sensors/Event.aidl b/sensors/aidl/android/hardware/sensors/Event.aidl
index 6ef9acb..fd6a8cc 100644
--- a/sensors/aidl/android/hardware/sensors/Event.aidl
+++ b/sensors/aidl/android/hardware/sensors/Event.aidl
@@ -127,6 +127,11 @@
*/
Data data;
+ /**
+ * SensorType::HEAD_TRACKER
+ */
+ HeadTracker headTracker;
+
@FixedSize
@VintfStability
parcelable Vec4 {
@@ -156,6 +161,46 @@
float zBias;
}
+ /**
+ * Payload of the HEAD_TRACKER sensor type. Note that the axis
+ * definition of this sensor type differs from the rest of Android. See
+ * SensorType::HEAD_TRACKER for more information.
+ */
+ @FixedSize
+ @VintfStability
+ parcelable HeadTracker {
+ /**
+ * An Euler vector (rotation vector, i.e. a vector whose direction
+ * indicates the axis of rotation and magnitude indicates the angle
+ * to rotate around that axis) representing the transform from
+ * the (arbitrary, possibly slowly drifting) reference frame to the
+ * head frame. Expressed in radians. Magnitude of the vector must be
+ * in the range [0, pi], while the value of individual axes are
+ * in the range [-pi, pi].
+ */
+ float rx;
+ float ry;
+ float rz;
+
+ /**
+ * An Euler vector (rotation vector) representing the angular
+ * velocity of the head (relative to itself), in radians per second.
+ * The direction of this vector indicates the axis of rotation, and
+ * the magnitude indicates the rate of rotation.
+ */
+ float vx;
+ float vy;
+ float vz;
+
+ /**
+ * This value increments (or wraps around to 0) each time the
+ * reference frame is suddenly and significantly changed, for
+ * example if an orientation filter algorithm used for determining
+ * the orientation has had its state reset.
+ */
+ int discontinuityCount;
+ }
+
@FixedSize
@VintfStability
parcelable HeartRate {
diff --git a/sensors/aidl/android/hardware/sensors/SensorType.aidl b/sensors/aidl/android/hardware/sensors/SensorType.aidl
index 95c7a6a..01e6bee 100644
--- a/sensors/aidl/android/hardware/sensors/SensorType.aidl
+++ b/sensors/aidl/android/hardware/sensors/SensorType.aidl
@@ -142,6 +142,10 @@
* The rotation vector symbolizes the orientation of the device relative to
* the East-North-Up coordinates frame.
*
+ * Note that despite the name, SensorType::ROTATION_VECTOR uses
+ * quaternion representation, rather than the rotation vector representation
+ * (aka Euler vector) seen in SensorType::HEAD_TRACKER.
+ *
* Implement the non-wake-up version of this sensor and implement the
* wake-up version if the system possesses a wake up fifo.
*/
@@ -634,6 +638,35 @@
HINGE_ANGLE = 36,
/**
+ * HEAD_TRACKER
+ * reporting-mode: continuous
+ *
+ * A sensor of this type measures the orientation of a user's head relative
+ * to an arbitrary reference frame, and the rate of rotation.
+ *
+ * Events produced by this sensor follow a special head-centric coordinate
+ * frame, where:
+ * - The X axis crosses through the user's ears, with the positive X
+ * direction extending out of the user's right ear
+ * - The Y axis crosses from the back of the user's head through their
+ * nose, with the positive direction extending out of the nose, and the
+ * X/Y plane being nominally parallel to the ground when the user is
+ * upright and looking straight ahead
+ * - The Z axis crosses from the neck through the top of the user's head,
+ * with the positive direction extending out from the top of the head
+ *
+ * When this sensor type is exposed as a dynamic sensor through a
+ * communications channel that uses HID, such as Bluetooth or USB, as part
+ * of a device with audio output capability (e.g. headphones), then the
+ * DynamicSensorInfo::uuid field shall be set to contents of the HID
+ * Persistent Unique ID to permit association between the sensor and audio
+ * device. Accordingly, the HID Persistent Unique ID (Sensors Page 0x20,
+ * Usage ID 0x302) must be populated as a UUID in binary representation,
+ * following RFC 4122 byte order.
+ */
+ HEAD_TRACKER = 37,
+
+ /**
* Base for device manufacturers private sensor types.
* These sensor types can't be exposed in the SDK.
*/