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

Commit 6167bf23 authored by Linus Tufvesson's avatar Linus Tufvesson
Browse files

Only apply flag when it has been changed

The properies object provided in onPropertiesChanged only contains
flag(s) that have been added/deleted/updated.

Test: atest WmTests:HighRefreshRateBlacklistTest
Bug: 144693310
Change-Id: Ieb5a494c01103141ee97fc1f6507437cb1d9b6b6
parent d04028ce
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -105,9 +105,11 @@ class HighRefreshRateBlacklist {

    private class OnPropertiesChangedListener implements DeviceConfig.OnPropertiesChangedListener {
        public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
            if (properties.getKeyset().contains(KEY_HIGH_REFRESH_RATE_BLACKLIST)) {
                updateBlacklist(
                        properties.getString(KEY_HIGH_REFRESH_RATE_BLACKLIST, null /*default*/));
            }
        }
    }
}
+17 −0
Original line number Diff line number Diff line
@@ -120,6 +120,23 @@ public class HighRefreshRateBlacklistTest {
        assertFalse(mBlacklist.isBlacklisted(APP3));
    }

    @Test
    public void testOverriddenByDeviceConfigUnrelatedFlagChanged() {
        final Resources r = createResources(APP1);
        final FakeDeviceConfig config = new FakeDeviceConfig();
        mBlacklist = new HighRefreshRateBlacklist(r, config);
        config.setBlacklist(APP2 + "," + APP3);
        assertFalse(mBlacklist.isBlacklisted(APP1));
        assertTrue(mBlacklist.isBlacklisted(APP2));
        assertTrue(mBlacklist.isBlacklisted(APP3));

        //  Change an unrelated flag in our namespace and verify that the blacklist is intact
        config.putPropertyAndNotify(DeviceConfig.NAMESPACE_DISPLAY_MANAGER, "someKey", "someValue");
        assertFalse(mBlacklist.isBlacklisted(APP1));
        assertTrue(mBlacklist.isBlacklisted(APP2));
        assertTrue(mBlacklist.isBlacklisted(APP3));
    }

    private Resources createResources(String... defaultBlacklist) {
        Resources r = mock(Resources.class);
        when(r.getStringArray(R.array.config_highRefreshRateBlacklist))