summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorSteve Howard <showard@google.com>2010-09-23 21:40:48 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-23 21:40:48 -0700
commit04e79051dce4f7ea3b3c6ced2c03676083449267 (patch)
tree717d0e7556ecc679cb0e966f0ec0462aff3cd959 /policy
parent77cf6f29f97f9ef6213a0a9b8b6ec2215fff20ff (diff)
parent56d6090380027efc7910537a2c2b99097ca36778 (diff)
downloadframeworks_base-04e79051dce4f7ea3b3c6ced2c03676083449267.zip
frameworks_base-04e79051dce4f7ea3b3c6ced2c03676083449267.tar.gz
frameworks_base-04e79051dce4f7ea3b3c6ced2c03676083449267.tar.bz2
am 56d60903: am a7bfe6ad: Support "seascape" rotation for "landscape-only" apps
Merge commit '56d6090380027efc7910537a2c2b99097ca36778' * commit '56d6090380027efc7910537a2c2b99097ca36778': Support "seascape" rotation for "landscape-only" apps
Diffstat (limited to 'policy')
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java45
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 bd774ce..c047522 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -290,7 +290,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...
@@ -363,9 +364,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.
@@ -374,7 +378,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;
}
}
@@ -2120,20 +2125,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
@@ -2153,6 +2158,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);