Skip to content

Commit 4bd149e

Browse files
author
Craig Mautner
committed
Do not use last app rotation as default.
If the rotation sensor has been disabled we were substituting the last app rotation for the sensor value. This fix uses the last sensor value delivered before the sensor was disabled. Only use the last app rotation if we never have received a valid sensor value. Fixes bug 6387946. Change-Id: I50743c30ee2b4455e9848d3a619809be97eec3c8
1 parent b92edf9 commit 4bd149e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
361361
boolean mScreenOnEarly = false;
362362
boolean mScreenOnFully = false;
363363
boolean mOrientationSensorEnabled = false;
364+
int mLastSensorRotation = -1;
364365
int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
365366
boolean mHasSoftInput = false;
366367

@@ -3728,7 +3729,16 @@ public int rotationForOrientationLw(int orientation, int lastRotation) {
37283729
synchronized (mLock) {
37293730
int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1
37303731
if (sensorRotation < 0) {
3731-
sensorRotation = lastRotation;
3732+
// Sensor is disabled, device probably just turned off.
3733+
if (mLastSensorRotation >= 0) {
3734+
sensorRotation = mLastSensorRotation;
3735+
} else {
3736+
// Sensor has never been enabled. Last resort is to use lastRotation.
3737+
sensorRotation = lastRotation;
3738+
}
3739+
} else {
3740+
// Valid sensor data, save it away.
3741+
mLastSensorRotation = sensorRotation;
37323742
}
37333743

37343744
final int preferredRotation;

0 commit comments

Comments
 (0)