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

Commit f214666b authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

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
parent 7a113ba4
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -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;
    }
}