Merge "Only apply flag when it has been changed"

This commit is contained in:
Linus Tufvesson
2019-11-25 16:26:24 +00:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 2 deletions

View File

@@ -105,8 +105,10 @@ class HighRefreshRateBlacklist {
private class OnPropertiesChangedListener implements DeviceConfig.OnPropertiesChangedListener {
public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
updateBlacklist(
properties.getString(KEY_HIGH_REFRESH_RATE_BLACKLIST, null /*default*/));
if (properties.getKeyset().contains(KEY_HIGH_REFRESH_RATE_BLACKLIST)) {
updateBlacklist(
properties.getString(KEY_HIGH_REFRESH_RATE_BLACKLIST, null /*default*/));
}
}
}
}

View File

@@ -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))