Merge "Do not use last app rotation as default." into jb-mr1-dev
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index fe459c7..5d4159a 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -361,6 +361,7 @@
boolean mScreenOnEarly = false;
boolean mScreenOnFully = false;
boolean mOrientationSensorEnabled = false;
+ int mLastSensorRotation = -1;
int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
boolean mHasSoftInput = false;
@@ -3721,7 +3722,16 @@
synchronized (mLock) {
int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1
if (sensorRotation < 0) {
- sensorRotation = lastRotation;
+ // Sensor is disabled, device probably just turned off.
+ if (mLastSensorRotation >= 0) {
+ sensorRotation = mLastSensorRotation;
+ } else {
+ // Sensor has never been enabled. Last resort is to use lastRotation.
+ sensorRotation = lastRotation;
+ }
+ } else {
+ // Valid sensor data, save it away.
+ mLastSensorRotation = sensorRotation;
}
final int preferredRotation;