@@ -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