diff options
Diffstat (limited to 'policy/src/com/android/internal')
-rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index a977618..c7d204e 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -446,9 +446,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } @Override - public void onOrientationChanged(int rotation) { - // Send updates based on orientation value - if (localLOGV) Log.v(TAG, "onOrientationChanged, rotation changed to " +rotation); + public void onProposedRotationChanged(int rotation) { + if (localLOGV) Log.v(TAG, "onProposedRotationChanged, rotation=" + rotation); updateRotation(false); } } @@ -654,6 +653,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { mKeyguardMediator = new KeyguardViewMediator(context, this, powerManager); mHandler = new Handler(); mOrientationListener = new MyOrientationListener(mContext); + try { + mOrientationListener.setCurrentRotation(windowManager.getRotation()); + } catch (RemoteException ex) { } SettingsObserver settingsObserver = new SettingsObserver(mHandler); settingsObserver.observe(); mShortcutManager = new ShortcutManager(context, mHandler); @@ -2882,7 +2884,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } synchronized (mLock) { - int sensorRotation = mOrientationListener.getCurrentRotation(); // may be -1 + int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 + if (sensorRotation < 0) { + sensorRotation = lastRotation; + } int preferredRotation = -1; if (mHdmiPlugged) { @@ -2892,20 +2897,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Ignore sensor when lid switch is open and rotation is forced. preferredRotation = mLidOpenRotation; } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR - && ((mCarDockEnablesAccelerometer && sensorRotation >= 0) - || mCarDockRotation >= 0)) { + && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { // Ignore sensor when in car dock unless explicitly enabled. // This case can override the behavior of NOSENSOR, and can also // enable 180 degree rotation while docked. - preferredRotation = mCarDockEnablesAccelerometer && sensorRotation >= 0 + preferredRotation = mCarDockEnablesAccelerometer ? sensorRotation : mCarDockRotation; } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK - && ((mDeskDockEnablesAccelerometer && sensorRotation >= 0) - || mDeskDockRotation >= 0)) { + && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { // Ignore sensor when in desk dock unless explicitly enabled. // This case can override the behavior of NOSENSOR, and can also // enable 180 degree rotation while docked. - preferredRotation = mDeskDockEnablesAccelerometer && sensorRotation >= 0 + preferredRotation = mDeskDockEnablesAccelerometer ? sensorRotation : mDeskDockRotation; } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { // Ignore sensor when user locked rotation. @@ -3006,6 +3009,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } + @Override + public void setRotationLw(int rotation) { + mOrientationListener.setCurrentRotation(rotation); + } + private boolean isLandscapeOrSeascape(int rotation) { return rotation == mLandscapeRotation || rotation == mSeascapeRotation; } |