From f214666bbb97aaee691ef2c30fba1f7a4a2df614 Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Fri, 9 Jun 2023 15:19:06 +0000 Subject: Avoid 60ms QS inflations on UI thread after density changes Before the change, density was always considered as "interesting" change from InterestingConfigChanges. After, it depends whether the flag CONFIG_DENSITY is provided or not. To keep the default behaviour as before, the flag is kept in the default set. Note that it's unknown why density was handled differently from other config fields instead of just using CONFIG_DENSITY. Bug: 286511842 Test: adb shell wm density 300 during a perfetto trace: 60ms main thread inflations from QS fragment are gone. Change-Id: I7aed4dda853af80981fcaa7c80f6afff64a0c60f --- .../settingslib/applications/InterestingConfigChanges.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/InterestingConfigChanges.java b/packages/SettingsLib/src/com/android/settingslib/applications/InterestingConfigChanges.java index 64a0781c4643..5d520ce5d81f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/InterestingConfigChanges.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/InterestingConfigChanges.java @@ -28,11 +28,11 @@ import android.content.res.Resources; public class InterestingConfigChanges { private final Configuration mLastConfiguration = new Configuration(); private final int mFlags; - private int mLastDensity; public InterestingConfigChanges() { this(ActivityInfo.CONFIG_LOCALE | ActivityInfo.CONFIG_LAYOUT_DIRECTION - | ActivityInfo.CONFIG_UI_MODE | ActivityInfo.CONFIG_ASSETS_PATHS); + | ActivityInfo.CONFIG_UI_MODE | ActivityInfo.CONFIG_ASSETS_PATHS + | ActivityInfo.CONFIG_DENSITY); } public InterestingConfigChanges(int flags) { @@ -50,11 +50,6 @@ public class InterestingConfigChanges { public boolean applyNewConfig(Resources res) { int configChanges = mLastConfiguration.updateFrom( Configuration.generateDelta(mLastConfiguration, res.getConfiguration())); - boolean densityChanged = mLastDensity != res.getDisplayMetrics().densityDpi; - if (densityChanged || (configChanges & (mFlags)) != 0) { - mLastDensity = res.getDisplayMetrics().densityDpi; - return true; - } - return false; + return (configChanges & (mFlags)) != 0; } } -- cgit v1.2.3-59-g8ed1b