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

Commit 2560c3b2 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Don't put layout round and direction in override configuration

Only the size and aspect ratio bits of screen layout should be set
in override configuration for size compatibility mode.

Bug: 112288258
Test: atest ActivityRecordTests#testSizeCompatMode_FixedScreenLayoutSizeBits
Test: manual - Assume a size compat mode activity without declaring to
      handle layout direction. When switching "Force RTL layout direction"
      from quick settings, the activity should be relaunched.

Change-Id: I2239257ac79712fcafc0bb5ae046f392cf0a3b09
parent ddc0fa51
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2751,7 +2751,9 @@ final class ActivityRecord extends ConfigurationContainer {
                final Configuration srcConfig = task.getConfiguration();
                overrideConfig.colorMode = srcConfig.colorMode;
                overrideConfig.densityDpi = srcConfig.densityDpi;
                overrideConfig.screenLayout = srcConfig.screenLayout;
                overrideConfig.screenLayout = srcConfig.screenLayout
                        & (Configuration.SCREENLAYOUT_LONG_MASK
                                | Configuration.SCREENLAYOUT_SIZE_MASK);
                // The smallest screen width is the short side of screen bounds. Because the bounds
                // and density won't be changed, smallestScreenWidthDp is also fixed.
                overrideConfig.smallestScreenWidthDp = srcConfig.smallestScreenWidthDp;
+26 −2
Original line number Diff line number Diff line
@@ -406,7 +406,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
    }

    @Test
    public void testFixedScreenConfigurationWhenMovingToDisplay() {
    public void testSizeCompatMode_FixedScreenConfigurationWhenMovingToDisplay() {
        // Initialize different bounds on a new display.
        final ActivityDisplay newDisplay = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
        newDisplay.setBounds(0, 0, 1000, 2000);
@@ -431,7 +431,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
    }

    @Test
    public void testFixedScreenBoundsWhenDisplaySizeChanged() {
    public void testSizeCompatMode_FixedScreenBoundsWhenDisplaySizeChanged() {
        when(mActivity.mAppWindowToken.getOrientationIgnoreVisibility()).thenReturn(
                ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        mTask.getWindowConfiguration().setAppBounds(mStack.getDisplay().getBounds());
@@ -446,4 +446,28 @@ public class ActivityRecordTests extends ActivityTestsBase {

        assertEquals(originalBounds, mActivity.getBounds());
    }

    @Test
    public void testSizeCompatMode_FixedScreenLayoutSizeBits() {
        final int fixedScreenLayout = Configuration.SCREENLAYOUT_LONG_NO
                | Configuration.SCREENLAYOUT_SIZE_NORMAL;
        mTask.getConfiguration().screenLayout = fixedScreenLayout
                | Configuration.SCREENLAYOUT_LAYOUTDIR_LTR;
        mTask.getWindowConfiguration().setAppBounds(mStack.getDisplay().getBounds());
        mActivity.info.resizeMode = ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
        mActivity.info.maxAspectRatio = 1.5f;
        ensureActivityConfiguration();

        // The initial configuration should inherit from parent.
        assertEquals(mTask.getConfiguration().screenLayout,
                mActivity.getConfiguration().screenLayout);

        mTask.getConfiguration().screenLayout = Configuration.SCREENLAYOUT_LAYOUTDIR_RTL
                | Configuration.SCREENLAYOUT_LONG_YES | Configuration.SCREENLAYOUT_SIZE_LARGE;
        mActivity.onConfigurationChanged(mTask.getConfiguration());

        // The size and aspect ratio bits don't change, but the layout direction should be updated.
        assertEquals(fixedScreenLayout | Configuration.SCREENLAYOUT_LAYOUTDIR_RTL,
                mActivity.getConfiguration().screenLayout);
    }
}