Loading services/core/java/com/android/server/wm/DisplayRotation.java +17 −27 Original line number Diff line number Diff line Loading @@ -1920,40 +1920,30 @@ public class DisplayRotation { mDeviceStateEnum = newState; return; } final DeviceStateController.DeviceStateEnum oldState = mDeviceStateEnum; mDeviceStateEnum = newState; handleDeviceStateChangeForHalfFoldOverride(oldState, newState); // Alert the activity of possible new bounds. UiThread.getHandler().removeCallbacks(mActivityBoundsUpdateCallback); UiThread.getHandler().postDelayed(mActivityBoundsUpdateCallback, FOLDING_RECOMPUTE_CONFIG_DELAY_MS); } private void handleDeviceStateChangeForHalfFoldOverride( DeviceStateController.DeviceStateEnum oldState, DeviceStateController.DeviceStateEnum newState) { if (!mAllowHalfFoldAutoRotationOverride) return; final boolean switchingToHalfFolded = newState == DeviceStateController.DeviceStateEnum.HALF_FOLDED && mDeviceStateEnum != DeviceStateController.DeviceStateEnum.HALF_FOLDED; if (switchingToHalfFolded) { // The device has transitioned to HALF_FOLDED state: save the current rotation // and update the device rotation. if (newState == DeviceStateController.DeviceStateEnum.HALF_FOLDED && mDeviceStateEnum != DeviceStateController.DeviceStateEnum.HALF_FOLDED) { // The device has transitioned to HALF_FOLDED state: save the current rotation and // update the device rotation. mDisplayContent.getRotationReversionController().beforeOverrideApplied( REVERSION_TYPE_HALF_FOLD); mHalfFoldSavedRotation = mRotation; mDeviceStateEnum = newState; // Now mFoldState is set to HALF_FOLDED, the overrideFrozenRotation function will // return true, so rotation is unlocked. mService.updateRotation(false /* alwaysSendConfiguration */, false /* forceRelayout */); } else { mInHalfFoldTransition = true; } mDeviceStateEnum = newState; // Tell the device to update its orientation. mService.updateRotation(false /* alwaysSendConfiguration */, false /* forceRelayout */); } // Alert the activity of possible new bounds. UiThread.getHandler().removeCallbacks(mActivityBoundsUpdateCallback); UiThread.getHandler().postDelayed(mActivityBoundsUpdateCallback, FOLDING_RECOMPUTE_CONFIG_DELAY_MS); } boolean shouldIgnoreSensorRotation() { return mShouldIgnoreSensorRotation; Loading services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +1 −16 Original line number Diff line number Diff line Loading @@ -53,7 +53,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import android.app.WindowConfiguration; import android.content.ContentResolver; Loading Loading @@ -1161,20 +1160,6 @@ public class DisplayRotationTests { SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0)); } @Test public void testHalfFoldOverrideDisabled_halfFolded_rotationOverrideIsNotApplied() throws Exception { mBuilder.setSupportHalfFoldAutoRotateOverride(false); mBuilder.build(); configureDisplayRotation(SCREEN_ORIENTATION_LANDSCAPE, false, false); enableOrientationSensor(); mTarget.foldStateChanged(DeviceStateController.DeviceStateEnum.OPEN); freezeRotation(Surface.ROTATION_270); mTarget.foldStateChanged(DeviceStateController.DeviceStateEnum.HALF_FOLDED); verify(mMockDisplayRotationReversionController, never()).beforeOverrideApplied(anyInt()); } @Test public void sensorRotation_locked_halfFolded_configOff_rotationUnchanged() throws Exception { mBuilder.setIsFoldable(true); Loading @@ -1197,7 +1182,7 @@ public class DisplayRotationTests { // ... half-fold -> still no rotation mTarget.foldStateChanged(DeviceStateController.DeviceStateEnum.HALF_FOLDED); assertTrue(waitForUiHandler()); verify(sMockWm, never()).updateRotation(false, false); verify(sMockWm).updateRotation(false, false); assertTrue(waitForUiHandler()); assertEquals(Surface.ROTATION_270, mTarget.rotationForOrientation( SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0)); Loading Loading
services/core/java/com/android/server/wm/DisplayRotation.java +17 −27 Original line number Diff line number Diff line Loading @@ -1920,40 +1920,30 @@ public class DisplayRotation { mDeviceStateEnum = newState; return; } final DeviceStateController.DeviceStateEnum oldState = mDeviceStateEnum; mDeviceStateEnum = newState; handleDeviceStateChangeForHalfFoldOverride(oldState, newState); // Alert the activity of possible new bounds. UiThread.getHandler().removeCallbacks(mActivityBoundsUpdateCallback); UiThread.getHandler().postDelayed(mActivityBoundsUpdateCallback, FOLDING_RECOMPUTE_CONFIG_DELAY_MS); } private void handleDeviceStateChangeForHalfFoldOverride( DeviceStateController.DeviceStateEnum oldState, DeviceStateController.DeviceStateEnum newState) { if (!mAllowHalfFoldAutoRotationOverride) return; final boolean switchingToHalfFolded = newState == DeviceStateController.DeviceStateEnum.HALF_FOLDED && mDeviceStateEnum != DeviceStateController.DeviceStateEnum.HALF_FOLDED; if (switchingToHalfFolded) { // The device has transitioned to HALF_FOLDED state: save the current rotation // and update the device rotation. if (newState == DeviceStateController.DeviceStateEnum.HALF_FOLDED && mDeviceStateEnum != DeviceStateController.DeviceStateEnum.HALF_FOLDED) { // The device has transitioned to HALF_FOLDED state: save the current rotation and // update the device rotation. mDisplayContent.getRotationReversionController().beforeOverrideApplied( REVERSION_TYPE_HALF_FOLD); mHalfFoldSavedRotation = mRotation; mDeviceStateEnum = newState; // Now mFoldState is set to HALF_FOLDED, the overrideFrozenRotation function will // return true, so rotation is unlocked. mService.updateRotation(false /* alwaysSendConfiguration */, false /* forceRelayout */); } else { mInHalfFoldTransition = true; } mDeviceStateEnum = newState; // Tell the device to update its orientation. mService.updateRotation(false /* alwaysSendConfiguration */, false /* forceRelayout */); } // Alert the activity of possible new bounds. UiThread.getHandler().removeCallbacks(mActivityBoundsUpdateCallback); UiThread.getHandler().postDelayed(mActivityBoundsUpdateCallback, FOLDING_RECOMPUTE_CONFIG_DELAY_MS); } boolean shouldIgnoreSensorRotation() { return mShouldIgnoreSensorRotation; Loading
services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +1 −16 Original line number Diff line number Diff line Loading @@ -53,7 +53,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import android.app.WindowConfiguration; import android.content.ContentResolver; Loading Loading @@ -1161,20 +1160,6 @@ public class DisplayRotationTests { SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0)); } @Test public void testHalfFoldOverrideDisabled_halfFolded_rotationOverrideIsNotApplied() throws Exception { mBuilder.setSupportHalfFoldAutoRotateOverride(false); mBuilder.build(); configureDisplayRotation(SCREEN_ORIENTATION_LANDSCAPE, false, false); enableOrientationSensor(); mTarget.foldStateChanged(DeviceStateController.DeviceStateEnum.OPEN); freezeRotation(Surface.ROTATION_270); mTarget.foldStateChanged(DeviceStateController.DeviceStateEnum.HALF_FOLDED); verify(mMockDisplayRotationReversionController, never()).beforeOverrideApplied(anyInt()); } @Test public void sensorRotation_locked_halfFolded_configOff_rotationUnchanged() throws Exception { mBuilder.setIsFoldable(true); Loading @@ -1197,7 +1182,7 @@ public class DisplayRotationTests { // ... half-fold -> still no rotation mTarget.foldStateChanged(DeviceStateController.DeviceStateEnum.HALF_FOLDED); assertTrue(waitForUiHandler()); verify(sMockWm, never()).updateRotation(false, false); verify(sMockWm).updateRotation(false, false); assertTrue(waitForUiHandler()); assertEquals(Surface.ROTATION_270, mTarget.rotationForOrientation( SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0)); Loading