summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJonas Larsson <jonas@hallerud.se>2011-12-29 12:30:51 -0800
committerSteve Kondik <shade@chemlab.org>2012-02-28 23:18:08 -0800
commitedcd72a59ecc14ab3bcd681675611c73f55c46cf (patch)
treeae1629638f3a7bd82acd69bfb6810ef8e04fd00a /policy
parente4052534bb749ff66e545b9b753aac75f1cbe6f3 (diff)
downloadframeworks_base-edcd72a59ecc14ab3bcd681675611c73f55c46cf.zip
frameworks_base-edcd72a59ecc14ab3bcd681675611c73f55c46cf.tar.gz
frameworks_base-edcd72a59ecc14ab3bcd681675611c73f55c46cf.tar.bz2
Configurable 0, 90, 180 and 270 degree rotation (framework part)
This is similar to my previous CM contributions. Requires settings UI to configure (not done yet). The rationale is to be able to have automatic rotation always enabled, but only for desired angles. Change-Id: I19d3d2cb91249ba2cdee310e6ff7b0978e9bfde0
Diffstat (limited to 'policy')
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 1aa2246..f9b80b5 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -329,6 +329,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE;
int mUserRotation = Surface.ROTATION_0;
+ int mUserRotationAngles = -1;
int mAllowAllRotations = -1;
boolean mCarDockEnablesAccelerometer;
@@ -497,6 +498,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
Settings.Secure.DEFAULT_INPUT_METHOD), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
"fancy_rotation_anim"), false, this);
+ resolver.registerContentObserver(Settings.System.getUriFor(
+ Settings.System.ACCELEROMETER_ROTATION_ANGLES), false, this);
updateSettings();
}
@@ -966,6 +969,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mUserRotation = Settings.System.getInt(resolver,
Settings.System.USER_ROTATION,
Surface.ROTATION_0);
+ mUserRotationAngles = Settings.System.getInt(resolver,
+ Settings.System.ACCELEROMETER_ROTATION_ANGLES, -1);
if (mAccelerometerDefault != accelerometerDefault) {
mAccelerometerDefault = accelerometerDefault;
@@ -3276,9 +3281,30 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mAllowAllRotations = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0;
}
- if (sensorRotation != Surface.ROTATION_180
- || mAllowAllRotations == 1
- || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR) {
+ // Rotation setting bitmask
+ // 1=0 2=90 4=180 8=270
+ boolean allowed = true;
+ if (mUserRotationAngles < 0) {
+ // Not set by user so use these defaults
+ mUserRotationAngles = mAllowAllRotations == 1 ?
+ (1 | 2 | 4 | 8) : // All angles
+ (1 | 2 | 8); // All except 180
+ }
+ switch (sensorRotation) {
+ case Surface.ROTATION_0:
+ allowed = (mUserRotationAngles & 1) != 0;
+ break;
+ case Surface.ROTATION_90:
+ allowed = (mUserRotationAngles & 2) != 0;
+ break;
+ case Surface.ROTATION_180:
+ allowed = (mUserRotationAngles & 4) != 0;
+ break;
+ case Surface.ROTATION_270:
+ allowed = (mUserRotationAngles & 8) != 0;
+ break;
+ }
+ if (allowed) {
preferredRotation = sensorRotation;
} else {
preferredRotation = lastRotation;