Update language to comply with Android's inclusive language guidance
1. Rename HighRefreshRateBlacklist to HighRefreshRateDenylist 2. Remove crazy from DisplayContent See https://source.android.com/setup/contribute/respectful-code for reference Bug: 162536543 Test: atest HighRefreshRateDenylistTest RefreshRatePolicyTest Change-Id: Id41a370916448173f5928c91b15219cbaf36f691
This commit is contained in:
@@ -941,6 +941,7 @@ public final class DisplayManager {
|
||||
*/
|
||||
String KEY_PEAK_REFRESH_RATE_DEFAULT = "peak_refresh_rate_default";
|
||||
|
||||
// TODO(b/162536543): rename it once it is proved not harmful for users.
|
||||
/**
|
||||
* Key for controlling which packages are explicitly blocked from running at refresh rates
|
||||
* higher than 60hz. An app may be added to this list if they exhibit performance issues at
|
||||
|
||||
@@ -649,7 +649,7 @@ public class DisplayPolicy {
|
||||
|
||||
mRefreshRatePolicy = new RefreshRatePolicy(mService,
|
||||
mDisplayContent.getDisplayInfo(),
|
||||
mService.mHighRefreshRateBlacklist);
|
||||
mService.mHighRefreshRateDenylist);
|
||||
|
||||
mGestureNavigationSettingsObserver = new GestureNavigationSettingsObserver(mHandler,
|
||||
mContext, () -> {
|
||||
|
||||
@@ -34,62 +34,62 @@ import java.io.PrintWriter;
|
||||
/**
|
||||
* A Denylist for packages that should force the display out of high refresh rate.
|
||||
*/
|
||||
class HighRefreshRateBlacklist {
|
||||
class HighRefreshRateDenylist {
|
||||
|
||||
private final ArraySet<String> mBlacklistedPackages = new ArraySet<>();
|
||||
private final ArraySet<String> mDenylistedPackages = new ArraySet<>();
|
||||
@NonNull
|
||||
private final String[] mDefaultBlacklist;
|
||||
private final String[] mDefaultDenylist;
|
||||
private final Object mLock = new Object();
|
||||
|
||||
private DeviceConfigInterface mDeviceConfig;
|
||||
private OnPropertiesChangedListener mListener = new OnPropertiesChangedListener();
|
||||
|
||||
static HighRefreshRateBlacklist create(@NonNull Resources r) {
|
||||
return new HighRefreshRateBlacklist(r, DeviceConfigInterface.REAL);
|
||||
static HighRefreshRateDenylist create(@NonNull Resources r) {
|
||||
return new HighRefreshRateDenylist(r, DeviceConfigInterface.REAL);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
HighRefreshRateBlacklist(Resources r, DeviceConfigInterface deviceConfig) {
|
||||
mDefaultBlacklist = r.getStringArray(R.array.config_highRefreshRateBlacklist);
|
||||
HighRefreshRateDenylist(Resources r, DeviceConfigInterface deviceConfig) {
|
||||
mDefaultDenylist = r.getStringArray(R.array.config_highRefreshRateBlacklist);
|
||||
mDeviceConfig = deviceConfig;
|
||||
mDeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
|
||||
BackgroundThread.getExecutor(), mListener);
|
||||
final String property = mDeviceConfig.getProperty(DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
|
||||
KEY_HIGH_REFRESH_RATE_BLACKLIST);
|
||||
updateBlacklist(property);
|
||||
updateDenylist(property);
|
||||
}
|
||||
|
||||
private void updateBlacklist(@Nullable String property) {
|
||||
private void updateDenylist(@Nullable String property) {
|
||||
synchronized (mLock) {
|
||||
mBlacklistedPackages.clear();
|
||||
mDenylistedPackages.clear();
|
||||
if (property != null) {
|
||||
String[] packages = property.split(",");
|
||||
for (String pkg : packages) {
|
||||
String pkgName = pkg.trim();
|
||||
if (!pkgName.isEmpty()) {
|
||||
mBlacklistedPackages.add(pkgName);
|
||||
mDenylistedPackages.add(pkgName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If there's no config, or the config has been deleted, fallback to the device's
|
||||
// default denylist
|
||||
for (String pkg : mDefaultBlacklist) {
|
||||
mBlacklistedPackages.add(pkg);
|
||||
for (String pkg : mDefaultDenylist) {
|
||||
mDenylistedPackages.add(pkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isBlacklisted(String packageName) {
|
||||
boolean isDenylisted(String packageName) {
|
||||
synchronized (mLock) {
|
||||
return mBlacklistedPackages.contains(packageName);
|
||||
return mDenylistedPackages.contains(packageName);
|
||||
}
|
||||
}
|
||||
void dump(PrintWriter pw) {
|
||||
pw.println("High Refresh Rate Blacklist");
|
||||
pw.println("High Refresh Rate Denylist");
|
||||
pw.println(" Packages:");
|
||||
synchronized (mLock) {
|
||||
for (String pkg : mBlacklistedPackages) {
|
||||
for (String pkg : mDenylistedPackages) {
|
||||
pw.println(" " + pkg);
|
||||
}
|
||||
}
|
||||
@@ -100,13 +100,13 @@ class HighRefreshRateBlacklist {
|
||||
void dispose() {
|
||||
mDeviceConfig.removeOnPropertiesChangedListener(mListener);
|
||||
mDeviceConfig = null;
|
||||
mBlacklistedPackages.clear();
|
||||
mDenylistedPackages.clear();
|
||||
}
|
||||
|
||||
private class OnPropertiesChangedListener implements DeviceConfig.OnPropertiesChangedListener {
|
||||
public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
|
||||
if (properties.getKeyset().contains(KEY_HIGH_REFRESH_RATE_BLACKLIST)) {
|
||||
updateBlacklist(
|
||||
updateDenylist(
|
||||
properties.getString(KEY_HIGH_REFRESH_RATE_BLACKLIST, null /*default*/));
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class RefreshRatePolicy {
|
||||
|
||||
private final int mLowRefreshRateId;
|
||||
private final ArraySet<String> mNonHighRefreshRatePackages = new ArraySet<>();
|
||||
private final HighRefreshRateBlacklist mHighRefreshRateBlacklist;
|
||||
private final HighRefreshRateDenylist mHighRefreshRateDenylist;
|
||||
private final WindowManagerService mWmService;
|
||||
|
||||
/**
|
||||
@@ -55,9 +55,9 @@ class RefreshRatePolicy {
|
||||
static final int LAYER_PRIORITY_NOT_FOCUSED_WITH_MODE = 2;
|
||||
|
||||
RefreshRatePolicy(WindowManagerService wmService, DisplayInfo displayInfo,
|
||||
HighRefreshRateBlacklist blacklist) {
|
||||
HighRefreshRateDenylist denylist) {
|
||||
mLowRefreshRateId = findLowRefreshRateModeId(displayInfo);
|
||||
mHighRefreshRateBlacklist = blacklist;
|
||||
mHighRefreshRateDenylist = denylist;
|
||||
mWmService = wmService;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class RefreshRatePolicy {
|
||||
}
|
||||
|
||||
// If app is denylisted using higher refresh rate, return default (lower) refresh rate
|
||||
if (mHighRefreshRateBlacklist.isBlacklisted(packageName)) {
|
||||
if (mHighRefreshRateDenylist.isDenylisted(packageName)) {
|
||||
return mLowRefreshRateId;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1005,7 +1005,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
final Configuration mTempConfiguration = new Configuration();
|
||||
|
||||
final HighRefreshRateBlacklist mHighRefreshRateBlacklist;
|
||||
final HighRefreshRateDenylist mHighRefreshRateDenylist;
|
||||
|
||||
// If true, only the core apps and services are being launched because the device
|
||||
// is in a special boot mode, such as being encrypted or waiting for a decryption password.
|
||||
@@ -1302,7 +1302,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
this, mInputManager, mActivityTaskManager, mH.getLooper());
|
||||
mDragDropController = new DragDropController(this, mH.getLooper());
|
||||
|
||||
mHighRefreshRateBlacklist = HighRefreshRateBlacklist.create(context.getResources());
|
||||
mHighRefreshRateDenylist = HighRefreshRateDenylist.create(context.getResources());
|
||||
|
||||
mConstants = new WindowManagerConstants(this, DeviceConfigInterface.REAL);
|
||||
mConstants.start(new HandlerExecutor(mH));
|
||||
@@ -5939,7 +5939,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
private void dumpHighRefreshRateBlacklist(PrintWriter pw) {
|
||||
pw.println("WINDOW MANAGER HIGH REFRESH RATE BLACKLIST (dumpsys window refresh)");
|
||||
mHighRefreshRateBlacklist.dump(pw);
|
||||
mHighRefreshRateDenylist.dump(pw);
|
||||
}
|
||||
|
||||
private void dumpTraceStatus(PrintWriter pw) {
|
||||
|
||||
@@ -40,107 +40,107 @@ import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Build/Install/Run:
|
||||
* atest WmTests:HighRefreshRateBlacklistTest
|
||||
* atest WmTests:HighRefreshRateDenylistTest
|
||||
*/
|
||||
@SmallTest
|
||||
@Presubmit
|
||||
public class HighRefreshRateBlacklistTest {
|
||||
public class HighRefreshRateDenylistTest {
|
||||
private static final String APP1 = "com.android.sample1";
|
||||
private static final String APP2 = "com.android.sample2";
|
||||
private static final String APP3 = "com.android.sample3";
|
||||
|
||||
private HighRefreshRateBlacklist mBlacklist;
|
||||
private HighRefreshRateDenylist mDenylist;
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mBlacklist.dispose();
|
||||
mDenylist.dispose();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultBlacklist() {
|
||||
public void testDefaultDenylist() {
|
||||
final Resources r = createResources(APP1, APP2);
|
||||
mBlacklist = new HighRefreshRateBlacklist(r, new FakeDeviceConfig());
|
||||
mDenylist = new HighRefreshRateDenylist(r, new FakeDeviceConfig());
|
||||
|
||||
assertTrue(mBlacklist.isBlacklisted(APP1));
|
||||
assertTrue(mBlacklist.isBlacklisted(APP2));
|
||||
assertFalse(mBlacklist.isBlacklisted(APP3));
|
||||
assertTrue(mDenylist.isDenylisted(APP1));
|
||||
assertTrue(mDenylist.isDenylisted(APP2));
|
||||
assertFalse(mDenylist.isDenylisted(APP3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoDefaultBlacklist() {
|
||||
public void testNoDefaultDenylist() {
|
||||
final Resources r = createResources();
|
||||
mBlacklist = new HighRefreshRateBlacklist(r, new FakeDeviceConfig());
|
||||
mDenylist = new HighRefreshRateDenylist(r, new FakeDeviceConfig());
|
||||
|
||||
assertFalse(mBlacklist.isBlacklisted(APP1));
|
||||
assertFalse(mDenylist.isDenylisted(APP1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultBlacklistIsOverriddenByDeviceConfig() {
|
||||
public void testDefaultDenylistIsOverriddenByDeviceConfig() {
|
||||
final Resources r = createResources(APP1);
|
||||
final FakeDeviceConfig config = new FakeDeviceConfig();
|
||||
config.setBlacklist(APP2 + "," + APP3);
|
||||
mBlacklist = new HighRefreshRateBlacklist(r, config);
|
||||
config.setDenylist(APP2 + "," + APP3);
|
||||
mDenylist = new HighRefreshRateDenylist(r, config);
|
||||
|
||||
assertFalse(mBlacklist.isBlacklisted(APP1));
|
||||
assertTrue(mBlacklist.isBlacklisted(APP2));
|
||||
assertTrue(mBlacklist.isBlacklisted(APP3));
|
||||
assertFalse(mDenylist.isDenylisted(APP1));
|
||||
assertTrue(mDenylist.isDenylisted(APP2));
|
||||
assertTrue(mDenylist.isDenylisted(APP3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultBlacklistIsOverriddenByEmptyDeviceConfig() {
|
||||
public void testDefaultDenylistIsOverriddenByEmptyDeviceConfig() {
|
||||
final Resources r = createResources(APP1);
|
||||
final FakeDeviceConfig config = new FakeDeviceConfig();
|
||||
config.setBlacklist("");
|
||||
mBlacklist = new HighRefreshRateBlacklist(r, config);
|
||||
config.setDenylist("");
|
||||
mDenylist = new HighRefreshRateDenylist(r, config);
|
||||
|
||||
assertFalse(mBlacklist.isBlacklisted(APP1));
|
||||
assertFalse(mDenylist.isDenylisted(APP1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultBlacklistIsOverriddenByDeviceConfigUpdate() {
|
||||
public void testDefaultDenylistIsOverriddenByDeviceConfigUpdate() {
|
||||
final Resources r = createResources(APP1);
|
||||
final FakeDeviceConfig config = new FakeDeviceConfig();
|
||||
mBlacklist = new HighRefreshRateBlacklist(r, config);
|
||||
mDenylist = new HighRefreshRateDenylist(r, config);
|
||||
|
||||
// First check that the default denylist is in effect
|
||||
assertTrue(mBlacklist.isBlacklisted(APP1));
|
||||
assertFalse(mBlacklist.isBlacklisted(APP2));
|
||||
assertFalse(mBlacklist.isBlacklisted(APP3));
|
||||
assertTrue(mDenylist.isDenylisted(APP1));
|
||||
assertFalse(mDenylist.isDenylisted(APP2));
|
||||
assertFalse(mDenylist.isDenylisted(APP3));
|
||||
|
||||
// Then confirm that the DeviceConfig list has propagated and taken effect.
|
||||
config.setBlacklist(APP2 + "," + APP3);
|
||||
assertFalse(mBlacklist.isBlacklisted(APP1));
|
||||
assertTrue(mBlacklist.isBlacklisted(APP2));
|
||||
assertTrue(mBlacklist.isBlacklisted(APP3));
|
||||
config.setDenylist(APP2 + "," + APP3);
|
||||
assertFalse(mDenylist.isDenylisted(APP1));
|
||||
assertTrue(mDenylist.isDenylisted(APP2));
|
||||
assertTrue(mDenylist.isDenylisted(APP3));
|
||||
|
||||
// Finally make sure we go back to the default list if the DeviceConfig gets deleted.
|
||||
config.setBlacklist(null);
|
||||
assertTrue(mBlacklist.isBlacklisted(APP1));
|
||||
assertFalse(mBlacklist.isBlacklisted(APP2));
|
||||
assertFalse(mBlacklist.isBlacklisted(APP3));
|
||||
config.setDenylist(null);
|
||||
assertTrue(mDenylist.isDenylisted(APP1));
|
||||
assertFalse(mDenylist.isDenylisted(APP2));
|
||||
assertFalse(mDenylist.isDenylisted(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));
|
||||
mDenylist = new HighRefreshRateDenylist(r, config);
|
||||
config.setDenylist(APP2 + "," + APP3);
|
||||
assertFalse(mDenylist.isDenylisted(APP1));
|
||||
assertTrue(mDenylist.isDenylisted(APP2));
|
||||
assertTrue(mDenylist.isDenylisted(APP3));
|
||||
|
||||
// Change an unrelated flag in our namespace and verify that the denylist is intact
|
||||
config.putPropertyAndNotify(DeviceConfig.NAMESPACE_DISPLAY_MANAGER, "someKey", "someValue");
|
||||
assertFalse(mBlacklist.isBlacklisted(APP1));
|
||||
assertTrue(mBlacklist.isBlacklisted(APP2));
|
||||
assertTrue(mBlacklist.isBlacklisted(APP3));
|
||||
assertFalse(mDenylist.isDenylisted(APP1));
|
||||
assertTrue(mDenylist.isDenylisted(APP2));
|
||||
assertTrue(mDenylist.isDenylisted(APP3));
|
||||
}
|
||||
|
||||
private Resources createResources(String... defaultBlacklist) {
|
||||
private Resources createResources(String... defaultDenylist) {
|
||||
Resources r = mock(Resources.class);
|
||||
when(r.getStringArray(R.array.config_highRefreshRateBlacklist))
|
||||
.thenReturn(defaultBlacklist);
|
||||
.thenReturn(defaultDenylist);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -160,9 +160,9 @@ public class HighRefreshRateBlacklistTest {
|
||||
super.addOnPropertiesChangedListener(namespace, executor, listener);
|
||||
}
|
||||
|
||||
void setBlacklist(String blacklist) {
|
||||
void setDenylist(String denylist) {
|
||||
putPropertyAndNotify(DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
|
||||
KEY_HIGH_REFRESH_RATE_BLACKLIST, blacklist);
|
||||
KEY_HIGH_REFRESH_RATE_BLACKLIST, denylist);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class RefreshRatePolicyTest extends WindowTestsBase {
|
||||
private static final int LOW_MODE_ID = 3;
|
||||
|
||||
private RefreshRatePolicy mPolicy;
|
||||
private HighRefreshRateBlacklist mBlacklist = mock(HighRefreshRateBlacklist.class);
|
||||
private HighRefreshRateDenylist mDenylist = mock(HighRefreshRateDenylist.class);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -61,7 +61,7 @@ public class RefreshRatePolicyTest extends WindowTestsBase {
|
||||
defaultMode.getPhysicalWidth(), defaultMode.getPhysicalHeight(), 60),
|
||||
};
|
||||
di.defaultModeId = 1;
|
||||
mPolicy = new RefreshRatePolicy(mWm, di, mBlacklist);
|
||||
mPolicy = new RefreshRatePolicy(mWm, di, mDenylist);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +81,7 @@ public class RefreshRatePolicyTest extends WindowTestsBase {
|
||||
final WindowState blacklistedWindow = createWindow(null, TYPE_BASE_APPLICATION,
|
||||
"blacklistedWindow");
|
||||
blacklistedWindow.mAttrs.packageName = "com.android.test";
|
||||
when(mBlacklist.isBlacklisted("com.android.test")).thenReturn(true);
|
||||
when(mDenylist.isDenylisted("com.android.test")).thenReturn(true);
|
||||
assertEquals(LOW_MODE_ID, mPolicy.getPreferredModeId(blacklistedWindow));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class RefreshRatePolicyTest extends WindowTestsBase {
|
||||
final WindowState overrideWindow = createWindow(null, TYPE_BASE_APPLICATION,
|
||||
"overrideWindow");
|
||||
overrideWindow.mAttrs.preferredDisplayModeId = LOW_MODE_ID;
|
||||
when(mBlacklist.isBlacklisted("com.android.test")).thenReturn(true);
|
||||
when(mDenylist.isDenylisted("com.android.test")).thenReturn(true);
|
||||
assertEquals(LOW_MODE_ID, mPolicy.getPreferredModeId(overrideWindow));
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ public class SystemServicesTestRule implements TestRule {
|
||||
// HighRefreshRateBlacklist with DeviceConfig. We need to undo that here to avoid
|
||||
// leaking mWmService.
|
||||
mWmService.mConstants.dispose();
|
||||
mWmService.mHighRefreshRateBlacklist.dispose();
|
||||
mWmService.mHighRefreshRateDenylist.dispose();
|
||||
|
||||
// This makes sure the posted messages without delay are processed, e.g.
|
||||
// DisplayPolicy#release, WindowManagerService#setAnimationScale.
|
||||
|
||||
Reference in New Issue
Block a user