diff options
| author | Trevor Bunker <trevorbunker@google.com> | 2016-01-08 11:11:13 -0800 |
|---|---|---|
| committer | Trevor Bunker <trevorbunker@google.com> | 2016-01-15 16:40:07 +0000 |
| commit | 3c288e6f2ee762b5e058c4f73f06ef384fab5dc8 (patch) | |
| tree | 26357c5eb66d0789f6653f556e2010bc2a587898 /core/java | |
| parent | d55ece0b38f63ebd7f9b64048653331666650b05 (diff) | |
Define TYPE_DEVICE_ORIENTATION
Bug: 23470411
Change-Id: Iceba2656936525c655f23fb00bb77521c432ba6a
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/hardware/Sensor.java | 22 | ||||
| -rw-r--r-- | core/java/android/hardware/SensorEvent.java | 14 |
2 files changed, 36 insertions, 0 deletions
diff --git a/core/java/android/hardware/Sensor.java b/core/java/android/hardware/Sensor.java index e87586424232..6935174f58d6 100644 --- a/core/java/android/hardware/Sensor.java +++ b/core/java/android/hardware/Sensor.java @@ -534,6 +534,24 @@ public final class Sensor { public static final String STRING_TYPE_WRIST_TILT_GESTURE = "android.sensor.wrist_tilt_gesture"; /** + * The current orientation of the device. + * <p> + * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details. + * + * @hide Expected to be used internally for auto-rotate and speaker rotation. + * + */ + public static final int TYPE_DEVICE_ORIENTATION = 27; + + /** + * A constant string describing a device orientation sensor type. + * + * @hide + * @see #TYPE_DEVICE_ORIENTATION + */ + public static final String STRING_TYPE_DEVICE_ORIENTATION = "android.sensor.device_orientation"; + + /** * A constant describing all sensor types. */ public static final int TYPE_ALL = -1; @@ -618,6 +636,7 @@ public final class Sensor { 1, // SENSOR_TYPE_GLANCE_GESTURE 1, // SENSOR_TYPE_PICK_UP_GESTURE 1, // SENSOR_TYPE_WRIST_TILT_GESTURE + 1, // SENSOR_TYPE_DEVICE_ORIENTATION }; /** @@ -939,6 +958,9 @@ public final class Sensor { case TYPE_TEMPERATURE: mStringType = STRING_TYPE_TEMPERATURE; return true; + case TYPE_DEVICE_ORIENTATION: + mStringType = STRING_TYPE_DEVICE_ORIENTATION; + return true; default: return false; } diff --git a/core/java/android/hardware/SensorEvent.java b/core/java/android/hardware/SensorEvent.java index 906c2a1941d5..9937b2cb2d26 100644 --- a/core/java/android/hardware/SensorEvent.java +++ b/core/java/android/hardware/SensorEvent.java @@ -483,6 +483,20 @@ public class SensorEvent { * on it. In earlier versions, this used to be always 3 which has changed now. </p> * * @see GeomagneticField + * + * <h4> {@link android.hardware.Sensor#TYPE_DEVICE_ORIENTATION + * Sensor.TYPE_DEVICE_ORIENTATION}:</h4> + * The current device orientation will be available in values[0]. The only + * available values are: + * <ul> + * <li> 0: device is in default orientation (Y axis is vertical and points up) + * <li> 1: device is rotated 90 degrees counter-clockwise from default + * orientation (X axis is vertical and points up) + * <li> 2: device is rotated 180 degrees from default orientation (Y axis is + * vertical and points down) + * <li> 3: device is rotated 90 degrees clockwise from default orientation (X axis + * is vertical and points down) + * </ul> */ public final float[] values; |
