From d66df0deb4462b1345291b8513383d0d4b638034 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 6 Sep 2022 15:23:20 -0600 Subject: [PATCH] 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 --- .../com/android/server/wm/DisplayContent.java | 18 ------------------ .../android/server/wm/ActivityRecordTests.java | 1 + .../wm/ActivityTaskManagerServiceTests.java | 5 +---- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 720b08285f174..ca02e7d9cca58 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -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; diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index bbd7695fc8cd7..95e9f20011d00 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -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 diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java index 20b1120d7d3e9..2fccd64bcecac 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java @@ -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());