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

Commit d66df0de authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove unnecessary calculation of display configuration

Since hierarchy unifying, ideally the configuration is already
synced if there is no orientation change. These code still remain
because the display config change from decor window relies on it:

Since [1] and [2], the height of navigation bar is no longer read
from resources. The height can be changed according to the layout
parameter. That may cause the display not to compute the latest
configuration when display density or navigation mode is changed.
And the display config change will happen at random timing when
calling updateOrientation (usually from resuming activity).

But after [3] and [4], the new display config can be sent if the
decor insets provider windows are changed. So now these code
are redundant, especially the computeScreenConfiguration is not a
cheap method, and it will be called twice from resumeTopActivity,
which adds extra unnecessary latency (20%).

[1]: If8ec79b3cb3b989eed578c44e8749b13fd2e8592
[2]: I04af809b5ff1ea43772a41d36ed6d97fb80ee02e
[3]: If966bcc8125300d47d5cd631f7db17ff027e5261
[4]: If6c28a89939372e6362b92f469ef7d793e8ec215

Bug: 234585256
Bug: 159103089
Test: CtsWindowManagerDeviceTestCases
Change-Id: Id7b7f4f7a647edd51b4d3255131eb2052f403784
parent 96fd9fad
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -1614,24 +1614,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
            config = new Configuration();
            computeScreenConfiguration(config);
        } else if (!(mTransitionController.isCollecting(this)
                // If waiting for a remote display change, don't prematurely update configuration.
                || mRemoteDisplayChangeController.isWaitingForRemoteDisplayChange())) {
            // No obvious action we need to take, but if our current state mismatches the
            // activity manager's, update it, disregarding font scale, which should remain set
            // to the value of the previous configuration.
            // Here we're calling Configuration#unset() instead of setToDefaults() because we
            // need to keep override configs clear of non-empty values (e.g. fontSize).
            final Configuration currentConfig = getRequestedOverrideConfiguration();
            mTmpConfiguration.unset();
            mTmpConfiguration.updateFrom(currentConfig);
            computeScreenConfiguration(mTmpConfiguration);
            if (currentConfig.diff(mTmpConfiguration) != 0) {
                mWaitingForConfig = true;
                setLayoutNeeded();
                mDisplayRotation.prepareNormalRotationAnimation();
                config = new Configuration(mTmpConfiguration);
            }
        }

        return config;
+1 −0
Original line number Diff line number Diff line
@@ -2993,6 +2993,7 @@ public class ActivityRecordTests extends WindowTestsBase {
        // Add a decor insets provider window.
        final WindowState navbar = createNavBarWithProvidedInsets(squareDisplay);
        squareDisplay.getDisplayPolicy().updateDecorInsetsInfoIfNeeded(navbar);
        squareDisplay.sendNewConfiguration();
        final Task task = new TaskBuilder(mSupervisor).setDisplay(squareDisplay).build();

        // create a fixed portrait activity
+1 −4
Original line number Diff line number Diff line
@@ -220,10 +220,7 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase {
        // Check that changes are reported
        Configuration c = new Configuration(newDisp1.getRequestedOverrideConfiguration());
        c.windowConfiguration.setBounds(new Rect(0, 0, 1000, 1300));
        newDisp1.onRequestedOverrideConfigurationChanged(c);
        mAtm.mRootWindowContainer.ensureVisibilityAndConfig(null /* starting */,
                newDisp1.mDisplayId, false /* markFrozenIfConfigChanged */,
                false /* deferResume */);
        newDisp1.performDisplayOverrideConfigUpdate(c);
        assertEquals(0, added.size());
        assertEquals(1, changed.size());
        assertEquals(0, removed.size());