Loading core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -771,6 +771,11 @@ we rely on gravity to determine the effective orientation. --> <bool name="config_deskDockEnablesAccelerometer">true</bool> <!-- Control whether nosensor and locked orientation requests are respected from the app when config_deskDockEnablesAccelerometer is set to false. TODO(b/274763533): Consider making true by default and removing this. --> <bool name="config_deskRespectsNoSensorAndLockedWithoutAccelerometer">false</bool> <!-- Car dock behavior --> <!-- The number of degrees to rotate the display when the device is in a car dock. Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1739,6 +1739,7 @@ <java-symbol type="bool" name="config_carDockEnablesAccelerometer" /> <java-symbol type="bool" name="config_customUserSwitchUi" /> <java-symbol type="bool" name="config_deskDockEnablesAccelerometer" /> <java-symbol type="bool" name="config_deskRespectsNoSensorAndLockedWithoutAccelerometer" /> <java-symbol type="bool" name="config_disableMenuKeyInLockScreen" /> <java-symbol type="bool" name="config_enableCarDockHomeLaunch" /> <java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" /> Loading services/core/java/com/android/server/wm/DisplayPolicy.java +9 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,7 @@ public class DisplayPolicy { private final boolean mCarDockEnablesAccelerometer; private final boolean mDeskDockEnablesAccelerometer; private final boolean mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer; private final AccessibilityManager mAccessibilityManager; private final ImmersiveModeConfirmation mImmersiveModeConfirmation; private final ScreenshotHelper mScreenshotHelper; Loading Loading @@ -435,6 +436,8 @@ public class DisplayPolicy { final Resources r = mContext.getResources(); mCarDockEnablesAccelerometer = r.getBoolean(R.bool.config_carDockEnablesAccelerometer); mDeskDockEnablesAccelerometer = r.getBoolean(R.bool.config_deskDockEnablesAccelerometer); mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer = r.getBoolean(R.bool.config_deskRespectsNoSensorAndLockedWithoutAccelerometer); mCanSystemBarsBeShownByUser = !r.getBoolean( R.bool.config_remoteInsetsControllerControlsSystemBars) || r.getBoolean( R.bool.config_remoteInsetsControllerSystemBarsCanBeShownByUserAction); Loading Loading @@ -755,6 +758,10 @@ public class DisplayPolicy { return mDeskDockEnablesAccelerometer; } boolean isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer() { return mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer; } public void setPersistentVrModeEnabled(boolean persistentVrModeEnabled) { mPersistentVrModeEnabled = persistentVrModeEnabled; } Loading Loading @@ -2662,6 +2669,8 @@ public class DisplayPolicy { pw.print("mCarDockEnablesAccelerometer="); pw.print(mCarDockEnablesAccelerometer); pw.print(" mDeskDockEnablesAccelerometer="); pw.println(mDeskDockEnablesAccelerometer); pw.print(" mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer="); pw.println(mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer); pw.print(prefix); pw.print("mDockMode="); pw.print(Intent.dockStateToString(mDockMode)); pw.print(" mLidState="); pw.println(WindowManagerFuncs.lidStateToString(mLidState)); pw.print(prefix); pw.print("mAwake="); pw.print(mAwake); Loading services/core/java/com/android/server/wm/DisplayRotation.java +6 −1 Original line number Diff line number Diff line Loading @@ -1170,6 +1170,10 @@ public class DisplayRotation { mDisplayPolicy.isCarDockEnablesAccelerometer(); final boolean deskDockEnablesAccelerometer = mDisplayPolicy.isDeskDockEnablesAccelerometer(); final boolean deskDockRespectsNoSensorAndLockedWithoutAccelerometer = mDisplayPolicy.isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer() && (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED || orientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); final int preferredRotation; if (!isDefaultDisplay) { Loading @@ -1188,7 +1192,8 @@ public class DisplayRotation { } else if ((dockMode == Intent.EXTRA_DOCK_STATE_DESK || dockMode == Intent.EXTRA_DOCK_STATE_LE_DESK || dockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) && (deskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { && (deskDockEnablesAccelerometer || mDeskDockRotation >= 0) && !deskDockRespectsNoSensorAndLockedWithoutAccelerometer) { // Ignore sensor when in desk dock unless explicitly enabled. // This case can override the behavior of NOSENSOR, and can also // enable 180 degree rotation while docked. Loading services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +19 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.server.wm; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LOCKED; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Loading Loading @@ -823,6 +825,23 @@ public class DisplayRotationTests { SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_90)); } @Test public void testIgnoresDeskDockRotation_whenNoSensorAndLockedRespected() throws Exception { mBuilder.setDeskDockRotation(Surface.ROTATION_270).build(); when(mMockDisplayPolicy.isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer()) .thenReturn(true); configureDisplayRotation(SCREEN_ORIENTATION_LANDSCAPE, false, false); when(mMockDisplayPolicy.getDockMode()).thenReturn(Intent.EXTRA_DOCK_STATE_DESK); freezeRotation(Surface.ROTATION_90); assertEquals(Surface.ROTATION_90, mTarget.rotationForOrientation( SCREEN_ORIENTATION_LOCKED, Surface.ROTATION_90)); assertEquals(Surface.ROTATION_0, mTarget.rotationForOrientation( SCREEN_ORIENTATION_NOSENSOR, Surface.ROTATION_90)); } @Test public void testReturnsUserRotation_FixedToUserRotation_IgnoreIncompatibleAppRequest() throws Exception { Loading Loading
core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -771,6 +771,11 @@ we rely on gravity to determine the effective orientation. --> <bool name="config_deskDockEnablesAccelerometer">true</bool> <!-- Control whether nosensor and locked orientation requests are respected from the app when config_deskDockEnablesAccelerometer is set to false. TODO(b/274763533): Consider making true by default and removing this. --> <bool name="config_deskRespectsNoSensorAndLockedWithoutAccelerometer">false</bool> <!-- Car dock behavior --> <!-- The number of degrees to rotate the display when the device is in a car dock. Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1739,6 +1739,7 @@ <java-symbol type="bool" name="config_carDockEnablesAccelerometer" /> <java-symbol type="bool" name="config_customUserSwitchUi" /> <java-symbol type="bool" name="config_deskDockEnablesAccelerometer" /> <java-symbol type="bool" name="config_deskRespectsNoSensorAndLockedWithoutAccelerometer" /> <java-symbol type="bool" name="config_disableMenuKeyInLockScreen" /> <java-symbol type="bool" name="config_enableCarDockHomeLaunch" /> <java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" /> Loading
services/core/java/com/android/server/wm/DisplayPolicy.java +9 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,7 @@ public class DisplayPolicy { private final boolean mCarDockEnablesAccelerometer; private final boolean mDeskDockEnablesAccelerometer; private final boolean mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer; private final AccessibilityManager mAccessibilityManager; private final ImmersiveModeConfirmation mImmersiveModeConfirmation; private final ScreenshotHelper mScreenshotHelper; Loading Loading @@ -435,6 +436,8 @@ public class DisplayPolicy { final Resources r = mContext.getResources(); mCarDockEnablesAccelerometer = r.getBoolean(R.bool.config_carDockEnablesAccelerometer); mDeskDockEnablesAccelerometer = r.getBoolean(R.bool.config_deskDockEnablesAccelerometer); mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer = r.getBoolean(R.bool.config_deskRespectsNoSensorAndLockedWithoutAccelerometer); mCanSystemBarsBeShownByUser = !r.getBoolean( R.bool.config_remoteInsetsControllerControlsSystemBars) || r.getBoolean( R.bool.config_remoteInsetsControllerSystemBarsCanBeShownByUserAction); Loading Loading @@ -755,6 +758,10 @@ public class DisplayPolicy { return mDeskDockEnablesAccelerometer; } boolean isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer() { return mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer; } public void setPersistentVrModeEnabled(boolean persistentVrModeEnabled) { mPersistentVrModeEnabled = persistentVrModeEnabled; } Loading Loading @@ -2662,6 +2669,8 @@ public class DisplayPolicy { pw.print("mCarDockEnablesAccelerometer="); pw.print(mCarDockEnablesAccelerometer); pw.print(" mDeskDockEnablesAccelerometer="); pw.println(mDeskDockEnablesAccelerometer); pw.print(" mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer="); pw.println(mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer); pw.print(prefix); pw.print("mDockMode="); pw.print(Intent.dockStateToString(mDockMode)); pw.print(" mLidState="); pw.println(WindowManagerFuncs.lidStateToString(mLidState)); pw.print(prefix); pw.print("mAwake="); pw.print(mAwake); Loading
services/core/java/com/android/server/wm/DisplayRotation.java +6 −1 Original line number Diff line number Diff line Loading @@ -1170,6 +1170,10 @@ public class DisplayRotation { mDisplayPolicy.isCarDockEnablesAccelerometer(); final boolean deskDockEnablesAccelerometer = mDisplayPolicy.isDeskDockEnablesAccelerometer(); final boolean deskDockRespectsNoSensorAndLockedWithoutAccelerometer = mDisplayPolicy.isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer() && (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED || orientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); final int preferredRotation; if (!isDefaultDisplay) { Loading @@ -1188,7 +1192,8 @@ public class DisplayRotation { } else if ((dockMode == Intent.EXTRA_DOCK_STATE_DESK || dockMode == Intent.EXTRA_DOCK_STATE_LE_DESK || dockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) && (deskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { && (deskDockEnablesAccelerometer || mDeskDockRotation >= 0) && !deskDockRespectsNoSensorAndLockedWithoutAccelerometer) { // Ignore sensor when in desk dock unless explicitly enabled. // This case can override the behavior of NOSENSOR, and can also // enable 180 degree rotation while docked. Loading
services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +19 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.server.wm; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LOCKED; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Loading Loading @@ -823,6 +825,23 @@ public class DisplayRotationTests { SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_90)); } @Test public void testIgnoresDeskDockRotation_whenNoSensorAndLockedRespected() throws Exception { mBuilder.setDeskDockRotation(Surface.ROTATION_270).build(); when(mMockDisplayPolicy.isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer()) .thenReturn(true); configureDisplayRotation(SCREEN_ORIENTATION_LANDSCAPE, false, false); when(mMockDisplayPolicy.getDockMode()).thenReturn(Intent.EXTRA_DOCK_STATE_DESK); freezeRotation(Surface.ROTATION_90); assertEquals(Surface.ROTATION_90, mTarget.rotationForOrientation( SCREEN_ORIENTATION_LOCKED, Surface.ROTATION_90)); assertEquals(Surface.ROTATION_0, mTarget.rotationForOrientation( SCREEN_ORIENTATION_NOSENSOR, Surface.ROTATION_90)); } @Test public void testReturnsUserRotation_FixedToUserRotation_IgnoreIncompatibleAppRequest() throws Exception { Loading