Define TYPE_DEVICE_ORIENTATION

Bug: 23470411
Change-Id: Iceba2656936525c655f23fb00bb77521c432ba6a
This commit is contained in:
Trevor Bunker
2016-01-08 11:11:13 -08:00
parent d55ece0b38
commit 3c288e6f2e
2 changed files with 36 additions and 0 deletions

View File

@@ -533,6 +533,24 @@ public final class Sensor {
@SystemApi
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.
*/
@@ -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;
}

View File

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