summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@google.com>2010-08-17 00:41:00 -0400
committerDaniel Sandler <dsandler@google.com>2010-11-04 16:55:29 -0400
commitb73617de462579f7c12c25a4c2747c576f00f6a2 (patch)
tree1f070d8a32c97062feca491ed9675af8d7c874dc /core
parent1ab022b8c8b063d95a591bf40109986c5b1bbb11 (diff)
downloadframeworks_base-b73617de462579f7c12c25a4c2747c576f00f6a2.zip
frameworks_base-b73617de462579f7c12c25a4c2747c576f00f6a2.tar.gz
frameworks_base-b73617de462579f7c12c25a4c2747c576f00f6a2.tar.bz2
Rotation lock.
IWindowManager now supports two new methods, freezeRotation() and thawRotation(), that allow a caller to temporarily stash the device's current rotation as the default rotation (when no other constraints are present). The system bar uses this to implement a user-accessible rotation lock by calling freezeRotation() and then turning off accelerometer-based display rotation; unless overridden by an app, the display will continue to appear in the frozen rotation until the rotation is unlocked by the user (either via the rotation lock icon in the system bar or by checking "rotate screen automatically" in Settings). Bug: 2949639 Change-Id: Icd21c169d1053719590e72401f229424b254622f
Diffstat (limited to 'core')
-rw-r--r--core/java/android/provider/Settings.java11
-rw-r--r--core/java/android/view/IWindowManager.aidl13
-rw-r--r--core/java/android/view/WindowManagerPolicy.java17
3 files changed, 41 insertions, 0 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 2229964..9c72dec 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1573,6 +1573,16 @@ public final class Settings {
public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
/**
+ * Default screen rotation when no other policy applies.
+ * When {@link #ACCELEROMETER_ROTATION} is zero and no on-screen Activity expresses a
+ * preference, this rotation value will be used. Must be one of the
+ * {@link android.view.Surface#ROTATION_0 Surface rotation constants}.
+ *
+ * @see Display#getRotation
+ */
+ public static final String USER_ROTATION = "user_rotation";
+
+ /**
* Whether the audible DTMF tones are played by the dialer when dialing. The value is
* boolean (1 or 0).
*/
@@ -1806,6 +1816,7 @@ public final class Settings {
TIME_12_24,
DATE_FORMAT,
ACCELEROMETER_ROTATION,
+ USER_ROTATION,
DTMF_TONE_WHEN_DIALING,
DTMF_TONE_TYPE_WHEN_DIALING,
EMERGENCY_TONE,
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index d4dd05c..a54f342 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -156,4 +156,17 @@ interface IWindowManager
* calls back when it changes.
*/
int watchRotation(IRotationWatcher watcher);
+
+ /**
+ * Lock the device orientation to the current rotation. Sensor input will
+ * be ignored until thawRotation() is called.
+ * @hide
+ */
+ void freezeRotation();
+
+ /**
+ * Release the orientation lock imposed by freezeRotation().
+ * @hide
+ */
+ void thawRotation();
}
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 1a341e1..e78d6a8 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -362,6 +362,13 @@ public interface WindowManagerPolicy {
* modify the rotation.
*/
public final int USE_LAST_ROTATION = -1000;
+
+ /** When not otherwise specified by the activity's screenOrientation, rotation should be
+ * determined by the system (that is, using sensors). */
+ public final int USER_ROTATION_FREE = 0;
+ /** When not otherwise specified by the activity's screenOrientation, rotation is set by
+ * the user. */
+ public final int USER_ROTATION_LOCKED = 1;
/**
* Perform initialization of the policy.
@@ -787,4 +794,14 @@ public interface WindowManagerPolicy {
* Return false to disable key repeat events from being generated.
*/
public boolean allowKeyRepeat();
+
+ /**
+ * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
+ *
+ * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
+ * {@link * WindowManagerPolicy#USER_ROTATION_FREE}.
+ * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
+ * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
+ */
+ public void setUserRotationMode(int mode, int rotation);
}