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

Commit 526acdc9 authored by Linus Tufvesson's avatar Linus Tufvesson Committed by Android (Google) Code Review
Browse files

Merge "Only apply flag when it has been changed"

parents c77e7fcd 6167bf23
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))