Merge "Disallow 180 rotation for phones. Bug: 4981385"

This commit is contained in:
Jeff Brown
2011-09-21 21:09:15 -07:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 5 deletions

View File

@@ -32,5 +32,8 @@
<!-- see comment in values/config.xml --> <!-- see comment in values/config.xml -->
<dimen name="config_prefDialogWidth">580dp</dimen> <dimen name="config_prefDialogWidth">580dp</dimen>
<!-- If true, the screen can be rotated via the accelerometer in all 4
rotations as the default behavior. -->
<bool name="config_allowAllRotations">true</bool>
</resources> </resources>

View File

@@ -231,7 +231,7 @@
<!-- If true, the screen can be rotated via the accelerometer in all 4 <!-- If true, the screen can be rotated via the accelerometer in all 4
rotations as the default behavior. --> rotations as the default behavior. -->
<bool name="config_allowAllRotations">true</bool> <bool name="config_allowAllRotations">false</bool>
<!-- If true, the direction rotation is applied to get to an application's requested <!-- If true, the direction rotation is applied to get to an application's requested
orientation is reversed. Normally, the model is that landscape is orientation is reversed. Normally, the model is that landscape is

View File

@@ -280,7 +280,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE;
int mUserRotation = Surface.ROTATION_0; int mUserRotation = Surface.ROTATION_0;
boolean mAllowAllRotations; int mAllowAllRotations = -1;
boolean mCarDockEnablesAccelerometer; boolean mCarDockEnablesAccelerometer;
boolean mDeskDockEnablesAccelerometer; boolean mDeskDockEnablesAccelerometer;
int mLidKeyboardAccessibility; int mLidKeyboardAccessibility;
@@ -681,8 +681,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
com.android.internal.R.integer.config_carDockRotation); com.android.internal.R.integer.config_carDockRotation);
mDeskDockRotation = readRotation( mDeskDockRotation = readRotation(
com.android.internal.R.integer.config_deskDockRotation); com.android.internal.R.integer.config_deskDockRotation);
mAllowAllRotations = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_allowAllRotations);
mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( mCarDockEnablesAccelerometer = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_carDockEnablesAccelerometer); com.android.internal.R.bool.config_carDockEnablesAccelerometer);
mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean(
@@ -2921,8 +2919,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|| orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) {
// Otherwise, use sensor only if requested by the application or enabled // Otherwise, use sensor only if requested by the application or enabled
// by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR.
if (mAllowAllRotations < 0) {
// Can't read this during init() because the context doesn't
// have display metrics at that time so we cannot determine
// tablet vs. phone then.
mAllowAllRotations = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0;
}
if (sensorRotation != Surface.ROTATION_180 if (sensorRotation != Surface.ROTATION_180
|| mAllowAllRotations || mAllowAllRotations == 1
|| orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR) { || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR) {
preferredRotation = sensorRotation; preferredRotation = sensorRotation;
} else { } else {