Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72e5ed92 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Only recompute new config if rotation is changed from settings

It was true because the settings were mixed with the other settings
in PhoneWindowManager that may contain keyboard state change. Since
the settings observer of rotation is extracted to only listen rotation
related changes, it no longer needs to always compute new display
configuration that is either a wasteful invocation or may disturb the
display info by some intermediate states, such as launching app in
different orientation.

Bug: 298331183
Test: AppConfigurationTests#testFixedOrientationWhenRotating
Change-Id: I80abecf55074f10999387ad1c2c7f14ff11c403c
parent ed35afbc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -948,7 +948,7 @@ public class DisplayRotation {
        mDisplayWindowSettings.setUserRotation(mDisplayContent, userRotationMode,
                userRotation);
        if (changed) {
            mService.updateRotation(true /* alwaysSendConfiguration */,
            mService.updateRotation(false /* alwaysSendConfiguration */,
                    false /* forceRelayout */);
        }
    }
@@ -2127,7 +2127,7 @@ public class DisplayRotation {
        @Override
        public void onChange(boolean selfChange) {
            if (updateSettings()) {
                mService.updateRotation(true /* alwaysSendConfiguration */,
                mService.updateRotation(false /* alwaysSendConfiguration */,
                        false /* forceRelayout */);
            }
        }
+4 −0
Original line number Diff line number Diff line
@@ -583,6 +583,7 @@ public class DisplayRotationTests {

        enableOrientationSensor();

        clearInvocations(sMockWm);
        mOrientationSensorListener.onSensorChanged(createSensorEvent(Surface.ROTATION_90));
        assertTrue(waitForUiHandler());

@@ -627,6 +628,7 @@ public class DisplayRotationTests {
        when(mDisplayRotationImmersiveAppCompatPolicyMock.isRotationLockEnforced(
                Surface.ROTATION_90)).thenReturn(false);

        clearInvocations(sMockWm);
        // And then ActivityRecord.setRequestedOrientation calls onSetRequestedOrientation.
        mTarget.onSetRequestedOrientation();

@@ -864,6 +866,7 @@ public class DisplayRotationTests {
        assertEquals(Surface.ROTATION_270, mTarget.rotationForOrientation(
                SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0));

        clearInvocations(sMockWm);
        // ... until half-fold
        mTarget.foldStateChanged(DeviceStateController.DeviceState.HALF_FOLDED);
        assertTrue(waitForUiHandler());
@@ -899,6 +902,7 @@ public class DisplayRotationTests {
        assertEquals(Surface.ROTATION_270, mTarget.rotationForOrientation(
                SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0));

        clearInvocations(sMockWm);
        // ... half-fold -> still no rotation
        mTarget.foldStateChanged(DeviceStateController.DeviceState.HALF_FOLDED);
        assertTrue(waitForUiHandler());