From e7e5ac250ca6e682edc850a5148b6c46c4d2e060 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Tue, 22 Feb 2011 16:10:21 -0500 Subject: [PATCH] Rotation lock fix for sensor{Landscape,Portrait} activities. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit E.g. if an app is sensorLandscape and the device rotation is locked to landscape, the activity should not be allowed to flip to seascape even if the device is inverted. If the rotation is locked 90° from the activity's supported orientations, we must override the lock as before, but we now suppress the sensor input (confining the activity to one of its two orientations). This best preserves the spirit of the rotation lock while still allowing the activity to run in a supported configuration. Bug: 3453407 Change-Id: I8ee255e0250ba7e4534f4622ac37b82d31cf9936 --- .../internal/policy/impl/PhoneWindowManager.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 8fd0f0569c84..c4ce93bca882 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -2553,6 +2553,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { } private int getCurrentLandscapeRotation(int lastRotation) { + // if the user has locked rotation, we ignore the sensor + if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { + if (isLandscapeOrSeascape(mUserRotation)) { + return mUserRotation; + } else { + // it seems odd to obey the sensor at all if rotation lock is enabled + return mLandscapeRotation; + } + } + int sensorRotation = mOrientationListener.getCurrentRotation(lastRotation); if (isLandscapeOrSeascape(sensorRotation)) { return sensorRotation; @@ -2570,6 +2580,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { } private int getCurrentPortraitRotation(int lastRotation) { + // if the user has locked rotation, we ignore the sensor + if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { + if (isAnyPortrait(mUserRotation)) { + return mUserRotation; + } else { + // it seems odd to obey the sensor at all if rotation lock is enabled + return mPortraitRotation; + } + } + int sensorRotation = mOrientationListener.getCurrentRotation(lastRotation); if (isAnyPortrait(sensorRotation)) { return sensorRotation; -- 2.11.0