diff options
author | Steve Howard <showard@google.com> | 2010-09-23 16:47:49 -0700 |
---|---|---|
committer | Steve Howard <showard@google.com> | 2010-09-23 17:46:41 -0700 |
commit | a7bfe6ad763208942d74a15933e2de1a3e06eba0 (patch) | |
tree | 729df22afe8218f26e8351ca7d1d9be1c90681c2 /policy | |
parent | cbb7b05e35368b104c27089f5f16640680f567c2 (diff) | |
download | frameworks_base-a7bfe6ad763208942d74a15933e2de1a3e06eba0.zip frameworks_base-a7bfe6ad763208942d74a15933e2de1a3e06eba0.tar.gz frameworks_base-a7bfe6ad763208942d74a15933e2de1a3e06eba0.tar.bz2 |
Support "seascape" rotation for "landscape-only" apps
Change-Id: Ibbbd850dc2bfb741b39c04c982fbdd98f3fa4a67
Diffstat (limited to 'policy')
-rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 45 |
1 files changed, 35 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 567b270..384f527 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -286,7 +286,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) int mIncallPowerBehavior; - int mLandscapeRotation = -1; + int mLandscapeRotation = -1; // default landscape rotation + int mSeascapeRotation = -1; // "other" landscape rotation, 180 degrees from mLandscapeRotation int mPortraitRotation = -1; // Nothing to see here, move along... @@ -356,9 +357,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { return true; } // The user preference says we can rotate, and the app is willing to rotate. + // Note we include SCREEN_ORIENTATION_LANDSCAPE since we can use the sensor to choose + // between the two possible landscape rotations. if (mAccelerometerDefault != 0 && (appOrientation == ActivityInfo.SCREEN_ORIENTATION_USER - || appOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) { + || appOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED + || appOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)) { return true; } // We're in a dock that has a rotation affinity, an the app is willing to rotate. @@ -367,7 +371,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Note we override the nosensor flag here. if (appOrientation == ActivityInfo.SCREEN_ORIENTATION_USER || appOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED - || appOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { + || appOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR + || appOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { return true; } } @@ -2053,20 +2058,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (d.getWidth() > d.getHeight()) { mPortraitRotation = Surface.ROTATION_90; mLandscapeRotation = Surface.ROTATION_0; + mSeascapeRotation = Surface.ROTATION_180; } else { mPortraitRotation = Surface.ROTATION_0; mLandscapeRotation = Surface.ROTATION_90; + mSeascapeRotation = Surface.ROTATION_270; } } synchronized (mLock) { - switch (orientation) { - case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: - //always return landscape if orientation set to landscape - return mLandscapeRotation; - case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: - //always return portrait if orientation set to portrait - return mPortraitRotation; + if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { + //always return portrait if orientation set to portrait + return mPortraitRotation; + } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { + return getCurrentLandscapeRotation(lastRotation); } // case for nosensor meaning ignore sensor and consider only lid // or orientation sensor disabled @@ -2086,6 +2091,26 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } + private int getCurrentLandscapeRotation(int lastRotation) { + // landscape-only apps can take either landscape rotation + if (useSensorForOrientationLp(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)) { + int sensorRotation = mOrientationListener.getCurrentRotation(lastRotation); + if (isLandscapeOrSeascape(sensorRotation)) { + return sensorRotation; + } + } + // try to preserve the old rotation if it was landscape + if (isLandscapeOrSeascape(lastRotation)) { + return lastRotation; + } + // default to one of the two landscape rotations + return mLandscapeRotation; + } + + private boolean isLandscapeOrSeascape(int sensorRotation) { + return sensorRotation == mLandscapeRotation || sensorRotation == mSeascapeRotation; + } + public boolean detectSafeMode() { try { int menuState = mWindowManager.getKeycodeState(KeyEvent.KEYCODE_MENU); |