diff options
Diffstat (limited to 'policy/src')
-rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 38 |
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); |