Skip to content

Commit b35914b

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Disallow 180 rotation for phones. Bug: 4981385"
2 parents a829e16 + d3187e3 commit b35914b

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

core/res/res/values-sw600dp/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@
3232
<!-- see comment in values/config.xml -->
3333
<dimen name="config_prefDialogWidth">580dp</dimen>
3434

35+
<!-- If true, the screen can be rotated via the accelerometer in all 4
36+
rotations as the default behavior. -->
37+
<bool name="config_allowAllRotations">true</bool>
3538
</resources>
3639

core/res/res/values/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231

232232
<!-- If true, the screen can be rotated via the accelerometer in all 4
233233
rotations as the default behavior. -->
234-
<bool name="config_allowAllRotations">true</bool>
234+
<bool name="config_allowAllRotations">false</bool>
235235

236236
<!-- If true, the direction rotation is applied to get to an application's requested
237237
orientation is reversed. Normally, the model is that landscape is

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
280280
int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE;
281281
int mUserRotation = Surface.ROTATION_0;
282282

283-
boolean mAllowAllRotations;
283+
int mAllowAllRotations = -1;
284284
boolean mCarDockEnablesAccelerometer;
285285
boolean mDeskDockEnablesAccelerometer;
286286
int mLidKeyboardAccessibility;
@@ -681,8 +681,6 @@ public void init(Context context, IWindowManager windowManager,
681681
com.android.internal.R.integer.config_carDockRotation);
682682
mDeskDockRotation = readRotation(
683683
com.android.internal.R.integer.config_deskDockRotation);
684-
mAllowAllRotations = mContext.getResources().getBoolean(
685-
com.android.internal.R.bool.config_allowAllRotations);
686684
mCarDockEnablesAccelerometer = mContext.getResources().getBoolean(
687685
com.android.internal.R.bool.config_carDockEnablesAccelerometer);
688686
mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean(
@@ -2921,8 +2919,15 @@ public int rotationForOrientationLw(int orientation, int lastRotation) {
29212919
|| orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) {
29222920
// Otherwise, use sensor only if requested by the application or enabled
29232921
// by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR.
2922+
if (mAllowAllRotations < 0) {
2923+
// Can't read this during init() because the context doesn't
2924+
// have display metrics at that time so we cannot determine
2925+
// tablet vs. phone then.
2926+
mAllowAllRotations = mContext.getResources().getBoolean(
2927+
com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0;
2928+
}
29242929
if (sensorRotation != Surface.ROTATION_180
2925-
|| mAllowAllRotations
2930+
|| mAllowAllRotations == 1
29262931
|| orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR) {
29272932
preferredRotation = sensorRotation;
29282933
} else {

0 commit comments

Comments
 (0)