summaryrefslogtreecommitdiffstats
path: root/policy/src
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 /policy/src
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 'policy/src')
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index af1bf59..2f2f943 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -230,6 +230,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int mLidOpenRotation;
int mCarDockRotation;
int mDeskDockRotation;
+
+ int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE;
+ int mUserRotation = Surface.ROTATION_0;
+
boolean mCarDockEnablesAccelerometer;
boolean mDeskDockEnablesAccelerometer;
int mLidKeyboardAccessibility;
@@ -336,6 +340,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.ACCELEROMETER_ROTATION), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
+ Settings.System.USER_ROTATION), false, this);
+ resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.SCREEN_OFF_TIMEOUT), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.POINTER_LOCATION), false, this);
@@ -678,10 +684,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
"fancy_rotation_anim", 0) != 0 ? 0x80 : 0;
int accelerometerDefault = Settings.System.getInt(resolver,
Settings.System.ACCELEROMETER_ROTATION, DEFAULT_ACCELEROMETER_ROTATION);
+
+ // set up rotation lock state
+ mUserRotationMode = (mAccelerometerDefault == 0)
+ ? WindowManagerPolicy.USER_ROTATION_LOCKED
+ : WindowManagerPolicy.USER_ROTATION_FREE;
+ mUserRotation = Settings.System.getInt(resolver,
+ Settings.System.USER_ROTATION,
+ Surface.ROTATION_0);
+
if (mAccelerometerDefault != accelerometerDefault) {
mAccelerometerDefault = accelerometerDefault;
updateOrientationListenerLp();
}
+
if (mSystemReady) {
int pointerLocation = Settings.System.getInt(resolver,
Settings.System.POINTER_LOCATION, 0);
@@ -2280,6 +2296,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return mCarDockRotation;
} else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
return mDeskDockRotation;
+ } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) {
+ return mUserRotation;
} else {
if (useSensorForOrientationLp(orientation)) {
return mOrientationListener.getCurrentRotation(lastRotation);
@@ -2323,6 +2341,26 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return sensorRotation == mPortraitRotation || sensorRotation == mUpsideDownRotation;
}
+
+ // User rotation: to be used when all else fails in assigning an orientation to the device
+ public void setUserRotationMode(int mode, int rot) {
+ ContentResolver res = mContext.getContentResolver();
+ mUserRotationMode = mode;
+ if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) {
+ mUserRotation = rot;
+ Settings.System.putInt(res,
+ Settings.System.ACCELEROMETER_ROTATION,
+ 0);
+ Settings.System.putInt(res,
+ Settings.System.USER_ROTATION,
+ rot);
+ } else {
+ Settings.System.putInt(res,
+ Settings.System.ACCELEROMETER_ROTATION,
+ 1);
+ }
+ }
+
public boolean detectSafeMode() {
try {
int menuState = mWindowManager.getKeycodeState(KeyEvent.KEYCODE_MENU);