Merge changes from topic "device_config_for_display_90" into qt-r1-dev

* changes:
  DO NOT MERGE Move device config key high_refresh_rate_blacklist to display_manager
  DO NOT MERGE Allow DeviceConfig to change display settings
  DO NOT MERGE DeviceConfig: Add Name space and keys for Display Manager
This commit is contained in:
Long Ling
2019-08-21 19:35:12 +00:00
committed by Android (Google) Code Review
5 changed files with 307 additions and 83 deletions

View File

@@ -820,4 +820,51 @@ public final class DisplayManager {
*/ */
void onDisplayChanged(int displayId); void onDisplayChanged(int displayId);
} }
/**
* Interface for accessing keys belonging to {@link
* android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER}.
* @hide
*/
public interface DeviceConfig {
/**
* Key for accessing the 60 hz only regions.
*
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.array#config_brightnessThresholdsOfPeakRefreshRate
* @hide
*/
String KEY_PEAK_REFRESH_RATE_BRIGHTNESS_THRESHOLDS =
"peak_refresh_rate_brightness_thresholds";
/**
* Key for accessing the 60 hz only regions.
*
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.array#config_brightnessThresholdsOfPeakRefreshRate
* @hide
*/
String KEY_PEAK_REFRESH_RATE_AMBIENT_THRESHOLDS = "peak_refresh_rate_ambient_thresholds";
/**
* Key for default peak refresh rate
*
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.integer#config_defaultPeakRefreshRate
* @hide
*/
String KEY_PEAK_REFRESH_RATE_DEFAULT = "peak_refresh_rate_default";
/**
* 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
* higher refresh rates.
*
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.array#config_highRefreshRateBlacklist
* @hide
*/
String KEY_HIGH_REFRESH_RATE_BLACKLIST = "high_refresh_rate_blacklist";
}
} }

View File

@@ -135,6 +135,14 @@ public final class DeviceConfig {
@SystemApi @SystemApi
public static final String NAMESPACE_DEX_BOOT = "dex_boot"; public static final String NAMESPACE_DEX_BOOT = "dex_boot";
/**
* Namespace for display manager related features. The names to access the properties in this
* namespace should be defined in {@link android.hardware.display.DisplayManager}.
*
* @hide
*/
public static final String NAMESPACE_DISPLAY_MANAGER = "display_manager";
/** /**
* Namespace for all Game Driver features. * Namespace for all Game Driver features.
* *
@@ -350,15 +358,6 @@ public final class DeviceConfig {
*/ */
String KEY_SYSTEM_GESTURE_EXCLUSION_LOG_DEBOUNCE_MILLIS = String KEY_SYSTEM_GESTURE_EXCLUSION_LOG_DEBOUNCE_MILLIS =
"system_gesture_exclusion_log_debounce_millis"; "system_gesture_exclusion_log_debounce_millis";
/**
* Key for controlling which packages are explicitly blocked from running at refresh rates
* higher than 60hz.
*
* @see android.provider.DeviceConfig#NAMESPACE_WINDOW_MANAGER
* @hide
*/
String KEY_HIGH_REFRESH_RATE_BLACKLIST = "high_refresh_rate_blacklist";
} }
private static final Object sLock = new Object(); private static final Object sLock = new Object();

View File

@@ -38,13 +38,16 @@ import android.os.Message;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.provider.DeviceConfig;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Pair;
import android.util.Slog; import android.util.Slog;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.Display; import android.view.Display;
import android.view.DisplayInfo; import android.view.DisplayInfo;
import com.android.internal.os.BackgroundThread;
import com.android.internal.R; import com.android.internal.R;
import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory; import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory;
import com.android.server.display.whitebalance.AmbientFilter; import com.android.server.display.whitebalance.AmbientFilter;
@@ -64,6 +67,8 @@ public class DisplayModeDirector {
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static final int MSG_ALLOWED_MODES_CHANGED = 1; private static final int MSG_ALLOWED_MODES_CHANGED = 1;
private static final int MSG_BRIGHTNESS_THRESHOLDS_CHANGED = 2;
private static final int MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED = 3;
// Special ID used to indicate that given vote is to be applied globally, rather than to a // Special ID used to indicate that given vote is to be applied globally, rather than to a
// specific display. // specific display.
@@ -91,6 +96,7 @@ public class DisplayModeDirector {
private final DisplayObserver mDisplayObserver; private final DisplayObserver mDisplayObserver;
private final BrightnessObserver mBrightnessObserver; private final BrightnessObserver mBrightnessObserver;
private final DeviceConfigDisplaySettings mDeviceConfigDisplaySettings;
private Listener mListener; private Listener mListener;
public DisplayModeDirector(@NonNull Context context, @NonNull Handler handler) { public DisplayModeDirector(@NonNull Context context, @NonNull Handler handler) {
@@ -103,7 +109,7 @@ public class DisplayModeDirector {
mSettingsObserver = new SettingsObserver(context, handler); mSettingsObserver = new SettingsObserver(context, handler);
mDisplayObserver = new DisplayObserver(context, handler); mDisplayObserver = new DisplayObserver(context, handler);
mBrightnessObserver = new BrightnessObserver(context, handler); mBrightnessObserver = new BrightnessObserver(context, handler);
mDeviceConfigDisplaySettings = new DeviceConfigDisplaySettings();
} }
/** /**
@@ -405,7 +411,7 @@ public class DisplayModeDirector {
void onAllowedDisplayModesChanged(); void onAllowedDisplayModesChanged();
} }
private static final class DisplayModeDirectorHandler extends Handler { private final class DisplayModeDirectorHandler extends Handler {
DisplayModeDirectorHandler(Looper looper) { DisplayModeDirectorHandler(Looper looper) {
super(looper, null, true /*async*/); super(looper, null, true /*async*/);
} }
@@ -417,6 +423,23 @@ public class DisplayModeDirector {
Listener listener = (Listener) msg.obj; Listener listener = (Listener) msg.obj;
listener.onAllowedDisplayModesChanged(); listener.onAllowedDisplayModesChanged();
break; break;
case MSG_BRIGHTNESS_THRESHOLDS_CHANGED:
Pair<int[], int[]> thresholds = (Pair<int[], int[]>) msg.obj;
if (thresholds != null) {
mBrightnessObserver.onDeviceConfigThresholdsChanged(
thresholds.first, thresholds.second);
} else {
mBrightnessObserver.onDeviceConfigThresholdsChanged(null, null);
}
break;
case MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED:
Float defaultPeakRefreshRate = (Float) msg.obj;
mSettingsObserver.onDeviceConfigDefaultPeakRefreshRateChanged(
defaultPeakRefreshRate);
break;
} }
} }
} }
@@ -508,7 +531,7 @@ public class DisplayModeDirector {
Settings.Global.getUriFor(Settings.Global.LOW_POWER_MODE); Settings.Global.getUriFor(Settings.Global.LOW_POWER_MODE);
private final Context mContext; private final Context mContext;
private final float mDefaultPeakRefreshRate; private float mDefaultPeakRefreshRate;
SettingsObserver(@NonNull Context context, @NonNull Handler handler) { SettingsObserver(@NonNull Context context, @NonNull Handler handler) {
super(handler); super(handler);
@@ -523,12 +546,33 @@ public class DisplayModeDirector {
UserHandle.USER_SYSTEM); UserHandle.USER_SYSTEM);
cr.registerContentObserver(mLowPowerModeSetting, false /*notifyDescendants*/, this, cr.registerContentObserver(mLowPowerModeSetting, false /*notifyDescendants*/, this,
UserHandle.USER_SYSTEM); UserHandle.USER_SYSTEM);
Float deviceConfigDefaultPeakRefresh =
mDeviceConfigDisplaySettings.getDefaultPeakRefreshRate();
if (deviceConfigDefaultPeakRefresh != null) {
mDefaultPeakRefreshRate = deviceConfigDefaultPeakRefresh;
}
synchronized (mLock) { synchronized (mLock) {
updateRefreshRateSettingLocked(); updateRefreshRateSettingLocked();
updateLowPowerModeSettingLocked(); updateLowPowerModeSettingLocked();
} }
} }
public void onDeviceConfigDefaultPeakRefreshRateChanged(Float defaultPeakRefreshRate) {
if (defaultPeakRefreshRate == null) {
defaultPeakRefreshRate = (float) mContext.getResources().getInteger(
R.integer.config_defaultPeakRefreshRate);
}
if (mDefaultPeakRefreshRate != defaultPeakRefreshRate) {
synchronized (mLock) {
mDefaultPeakRefreshRate = defaultPeakRefreshRate;
updateRefreshRateSettingLocked();
}
}
}
@Override @Override
public void onChange(boolean selfChange, Uri uri, int userId) { public void onChange(boolean selfChange, Uri uri, int userId) {
synchronized (mLock) { synchronized (mLock) {
@@ -720,8 +764,8 @@ public class DisplayModeDirector {
Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS); Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS);
private final static int LIGHT_SENSOR_RATE_MS = 250; private final static int LIGHT_SENSOR_RATE_MS = 250;
private final int[] mDisplayBrightnessThresholds; private int[] mDisplayBrightnessThresholds;
private final int[] mAmbientBrightnessThresholds; private int[] mAmbientBrightnessThresholds;
// valid threshold if any item from the array >= 0 // valid threshold if any item from the array >= 0
private boolean mShouldObserveDisplayChange; private boolean mShouldObserveDisplayChange;
private boolean mShouldObserveAmbientChange; private boolean mShouldObserveAmbientChange;
@@ -734,10 +778,11 @@ public class DisplayModeDirector {
private AmbientFilter mAmbientFilter; private AmbientFilter mAmbientFilter;
private final Context mContext; private final Context mContext;
private ScreenStateReceiver mScreenStateReceiver; private final ScreenStateReceiver mScreenStateReceiver;
// Enable light sensor only when screen is on, peak refresh rate enabled and low power mode // Enable light sensor only when mShouldObserveAmbientChange is true, screen is on, peak
// off. After initialization, these states will be updated from the same handler thread. // refresh rate enabled and low power mode off. After initialization, these states will
// be updated from the same handler thread.
private boolean mScreenOn = false; private boolean mScreenOn = false;
private boolean mPeakRefreshRateEnabled = false; private boolean mPeakRefreshRateEnabled = false;
private boolean mLowPowerModeEnabled = false; private boolean mLowPowerModeEnabled = false;
@@ -745,83 +790,63 @@ public class DisplayModeDirector {
BrightnessObserver(Context context, Handler handler) { BrightnessObserver(Context context, Handler handler) {
super(handler); super(handler);
mContext = context; mContext = context;
mScreenStateReceiver = new ScreenStateReceiver(mContext);
mDisplayBrightnessThresholds = context.getResources().getIntArray( mDisplayBrightnessThresholds = context.getResources().getIntArray(
R.array.config_brightnessThresholdsOfPeakRefreshRate); R.array.config_brightnessThresholdsOfPeakRefreshRate);
mAmbientBrightnessThresholds = context.getResources().getIntArray( mAmbientBrightnessThresholds = context.getResources().getIntArray(
R.array.config_ambientThresholdsOfPeakRefreshRate); R.array.config_ambientThresholdsOfPeakRefreshRate);
if (mDisplayBrightnessThresholds.length != mAmbientBrightnessThresholds.length) { if (mDisplayBrightnessThresholds.length != mAmbientBrightnessThresholds.length) {
throw new RuntimeException("display brightness threshold array and ambient " throw new RuntimeException("display brightness threshold array and ambient "
+ "brightness threshold array have different length"); + "brightness threshold array have different length");
} }
mShouldObserveDisplayChange = checkShouldObserve(mDisplayBrightnessThresholds);
mShouldObserveAmbientChange = checkShouldObserve(mAmbientBrightnessThresholds);
} }
public void observe(SensorManager sensorManager) { public void observe(SensorManager sensorManager) {
if (mShouldObserveDisplayChange) { mSensorManager = sensorManager;
final ContentResolver cr = mContext.getContentResolver(); // DeviceConfig is accessible after system ready.
cr.registerContentObserver(mDisplayBrightnessSetting, int[] brightnessThresholds = mDeviceConfigDisplaySettings.getBrightnessThresholds();
false /*notifyDescendants*/, this, UserHandle.USER_SYSTEM); int[] ambientThresholds = mDeviceConfigDisplaySettings.getAmbientThresholds();
}
if (brightnessThresholds != null && ambientThresholds != null
if (mShouldObserveAmbientChange) { && brightnessThresholds.length == ambientThresholds.length) {
Resources resources = mContext.getResources(); mDisplayBrightnessThresholds = brightnessThresholds;
String lightSensorType = resources.getString( mAmbientBrightnessThresholds = ambientThresholds;
com.android.internal.R.string.config_displayLightSensorType);
Sensor lightSensor = null;
if (!TextUtils.isEmpty(lightSensorType)) {
List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ALL);
for (int i = 0; i < sensors.size(); i++) {
Sensor sensor = sensors.get(i);
if (lightSensorType.equals(sensor.getStringType())) {
lightSensor = sensor;
break;
}
}
}
if (lightSensor == null) {
lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
}
if (lightSensor != null) {
final Resources res = mContext.getResources();
mAmbientFilter = DisplayWhiteBalanceFactory.createBrightnessFilter(res);
mSensorManager = sensorManager;
mLightSensor = lightSensor;
// Intent.ACTION_SCREEN_ON is not sticky. Check current screen status.
if (mContext.getSystemService(PowerManager.class).isInteractive()) {
onScreenOn(true);
}
mScreenStateReceiver = new ScreenStateReceiver(mContext);
}
}
if (mShouldObserveDisplayChange || mShouldObserveAmbientChange) {
synchronized (mLock) {
onBrightnessChangedLocked();
}
} }
restartObserver();
mDeviceConfigDisplaySettings.startListening();
} }
public void onPeakRefreshRateEnabled(boolean b) { public void onPeakRefreshRateEnabled(boolean b) {
if (mShouldObserveAmbientChange && mPeakRefreshRateEnabled != b) { if (mPeakRefreshRateEnabled != b) {
mPeakRefreshRateEnabled = b; mPeakRefreshRateEnabled = b;
updateSensorStatus(); updateSensorStatus();
} }
} }
public void onLowPowerModeEnabled(boolean b) { public void onLowPowerModeEnabled(boolean b) {
if (mShouldObserveAmbientChange && mLowPowerModeEnabled != b) { if (mLowPowerModeEnabled != b) {
mLowPowerModeEnabled = b; mLowPowerModeEnabled = b;
updateSensorStatus(); updateSensorStatus();
} }
} }
public void onDeviceConfigThresholdsChanged(int[] brightnessThresholds,
int[] ambientThresholds) {
if (brightnessThresholds != null && ambientThresholds != null
&& brightnessThresholds.length == ambientThresholds.length) {
mDisplayBrightnessThresholds = brightnessThresholds;
mAmbientBrightnessThresholds = ambientThresholds;
} else {
// Invalid or empty. Use device default.
mDisplayBrightnessThresholds = mContext.getResources().getIntArray(
R.array.config_brightnessThresholdsOfPeakRefreshRate);
mAmbientBrightnessThresholds = mContext.getResources().getIntArray(
R.array.config_ambientThresholdsOfPeakRefreshRate);
}
restartObserver();
}
public void dumpLocked(PrintWriter pw) { public void dumpLocked(PrintWriter pw) {
pw.println(" BrightnessObserver"); pw.println(" BrightnessObserver");
@@ -841,6 +866,67 @@ public class DisplayModeDirector {
} }
} }
private void restartObserver() {
mShouldObserveDisplayChange = checkShouldObserve(mDisplayBrightnessThresholds);
mShouldObserveAmbientChange = checkShouldObserve(mAmbientBrightnessThresholds);
final ContentResolver cr = mContext.getContentResolver();
if (mShouldObserveDisplayChange) {
// Content Service does not check if an listener has already been registered.
// To ensure only one listener is registered, force an unregistration first.
cr.unregisterContentObserver(this);
cr.registerContentObserver(mDisplayBrightnessSetting,
false /*notifyDescendants*/, this, UserHandle.USER_SYSTEM);
} else {
cr.unregisterContentObserver(this);
}
if (mShouldObserveAmbientChange) {
Resources resources = mContext.getResources();
String lightSensorType = resources.getString(
com.android.internal.R.string.config_displayLightSensorType);
Sensor lightSensor = null;
if (!TextUtils.isEmpty(lightSensorType)) {
List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
for (int i = 0; i < sensors.size(); i++) {
Sensor sensor = sensors.get(i);
if (lightSensorType.equals(sensor.getStringType())) {
lightSensor = sensor;
break;
}
}
}
if (lightSensor == null) {
lightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
}
if (lightSensor != null) {
final Resources res = mContext.getResources();
mAmbientFilter = DisplayWhiteBalanceFactory.createBrightnessFilter(res);
mLightSensor = lightSensor;
// Intent.ACTION_SCREEN_ON is not sticky. Check current screen status.
if (mContext.getSystemService(PowerManager.class).isInteractive()) {
onScreenOn(true);
}
mScreenStateReceiver.register();
}
} else {
mAmbientFilter = null;
mLightSensor = null;
mScreenStateReceiver.unregister();
}
updateSensorStatus();
synchronized (mLock) {
onBrightnessChangedLocked();
}
}
/** /**
* Checks to see if at least one value is positive, in which case it is necessary to listen * Checks to see if at least one value is positive, in which case it is necessary to listen
* to value changes. * to value changes.
@@ -904,7 +990,8 @@ public class DisplayModeDirector {
return; return;
} }
if (mScreenOn && !mLowPowerModeEnabled && mPeakRefreshRateEnabled) { if (mShouldObserveAmbientChange && mScreenOn && !mLowPowerModeEnabled
&& mPeakRefreshRateEnabled) {
mSensorManager.registerListener(mLightSensorListener, mSensorManager.registerListener(mLightSensorListener,
mLightSensor, LIGHT_SENSOR_RATE_MS * 1000, mHandler); mLightSensor, LIGHT_SENSOR_RATE_MS * 1000, mHandler);
} else { } else {
@@ -993,18 +1080,109 @@ public class DisplayModeDirector {
}; };
private final class ScreenStateReceiver extends BroadcastReceiver { private final class ScreenStateReceiver extends BroadcastReceiver {
final Context mContext;
public ScreenStateReceiver(Context context) { public ScreenStateReceiver(Context context) {
IntentFilter filter = new IntentFilter(); mContext = context;
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
context.registerReceiver(this, filter, null, mHandler);
} }
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
onScreenOn(Intent.ACTION_SCREEN_ON.equals(intent.getAction())); onScreenOn(Intent.ACTION_SCREEN_ON.equals(intent.getAction()));
} }
public void register() {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
mContext.registerReceiver(this, filter, null, mHandler);
}
public void unregister() {
mContext.unregisterReceiver(this);
}
} }
} }
private class DeviceConfigDisplaySettings implements DeviceConfig.OnPropertiesChangedListener {
public DeviceConfigDisplaySettings() {
}
public void startListening() {
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
BackgroundThread.getExecutor(), this);
}
/*
* Return null if no such property or wrong format (not comma separated integers).
*/
public int[] getBrightnessThresholds() {
return getIntArrayProperty(
DisplayManager.DeviceConfig.KEY_PEAK_REFRESH_RATE_BRIGHTNESS_THRESHOLDS);
}
/*
* Return null if no such property or wrong format (not comma separated integers).
*/
public int[] getAmbientThresholds() {
return getIntArrayProperty(
DisplayManager.DeviceConfig.KEY_PEAK_REFRESH_RATE_AMBIENT_THRESHOLDS);
}
/*
* Return null if no such property
*/
public Float getDefaultPeakRefreshRate() {
float defaultPeakRefreshRate = DeviceConfig.getFloat(
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
DisplayManager.DeviceConfig.KEY_PEAK_REFRESH_RATE_DEFAULT, -1);
if (defaultPeakRefreshRate == -1) {
return null;
}
return defaultPeakRefreshRate;
}
@Override
public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
int[] brightnessThresholds = getBrightnessThresholds();
int[] ambientThresholds = getAmbientThresholds();
Float defaultPeakRefreshRate = getDefaultPeakRefreshRate();
mHandler.obtainMessage(MSG_BRIGHTNESS_THRESHOLDS_CHANGED,
new Pair<int[], int[]>(brightnessThresholds, ambientThresholds))
.sendToTarget();
mHandler.obtainMessage(MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED,
defaultPeakRefreshRate).sendToTarget();
}
private int[] getIntArrayProperty(String prop) {
String strArray = DeviceConfig.getString(DeviceConfig.NAMESPACE_DISPLAY_MANAGER, prop,
null);
if (strArray != null) {
return parseIntArray(strArray);
}
return null;
}
private int[] parseIntArray(@NonNull String strArray) {
String[] items = strArray.split(",");
int[] array = new int[items.length];
try {
for (int i = 0; i < array.length; i++) {
array[i] = Integer.parseInt(items[i]);
}
} catch (NumberFormatException e) {
Slog.e(TAG, "Incorrect format for array: '" + strArray + "'", e);
array = null;
}
return array;
}
}
} }

View File

@@ -16,7 +16,7 @@
package com.android.server.wm; package com.android.server.wm;
import static android.provider.DeviceConfig.WindowManager.KEY_HIGH_REFRESH_RATE_BLACKLIST; import static android.hardware.display.DisplayManager.DeviceConfig.KEY_HIGH_REFRESH_RATE_BLACKLIST;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
@@ -58,9 +58,9 @@ class HighRefreshRateBlacklist {
@VisibleForTesting @VisibleForTesting
HighRefreshRateBlacklist(Resources r, DeviceConfigInterface deviceConfig) { HighRefreshRateBlacklist(Resources r, DeviceConfigInterface deviceConfig) {
mDefaultBlacklist = r.getStringArray(R.array.config_highRefreshRateBlacklist); mDefaultBlacklist = r.getStringArray(R.array.config_highRefreshRateBlacklist);
deviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_WINDOW_MANAGER, deviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
BackgroundThread.getExecutor(), new OnPropertyChangedListener()); BackgroundThread.getExecutor(), new OnPropertyChangedListener());
final String property = deviceConfig.getProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, final String property = deviceConfig.getProperty(DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
KEY_HIGH_REFRESH_RATE_BLACKLIST); KEY_HIGH_REFRESH_RATE_BLACKLIST);
updateBlacklist(property); updateBlacklist(property);
} }

View File

@@ -16,7 +16,7 @@
package com.android.server.wm; package com.android.server.wm;
import static android.provider.DeviceConfig.WindowManager.KEY_HIGH_REFRESH_RATE_BLACKLIST; import static android.hardware.display.DisplayManager.DeviceConfig.KEY_HIGH_REFRESH_RATE_BLACKLIST;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@@ -126,9 +126,9 @@ public class HighRefreshRateBlacklistTest {
@Override @Override
public String getProperty(String namespace, String name) { public String getProperty(String namespace, String name) {
if (!DeviceConfig.NAMESPACE_WINDOW_MANAGER.equals(namespace) if (!DeviceConfig.NAMESPACE_DISPLAY_MANAGER.equals(namespace)
|| !KEY_HIGH_REFRESH_RATE_BLACKLIST.equals(name)) { || !KEY_HIGH_REFRESH_RATE_BLACKLIST.equals(name)) {
throw new IllegalArgumentException("Only things in NAMESPACE_WINDOW_MANAGER " throw new IllegalArgumentException("Only things in NAMESPACE_DISPLAY_MANAGER "
+ "supported."); + "supported.");
} }
return mBlacklist; return mBlacklist;
@@ -138,8 +138,8 @@ public class HighRefreshRateBlacklistTest {
public void addOnPropertyChangedListener(String namespace, Executor executor, public void addOnPropertyChangedListener(String namespace, Executor executor,
DeviceConfig.OnPropertyChangedListener listener) { DeviceConfig.OnPropertyChangedListener listener) {
if (!DeviceConfig.NAMESPACE_WINDOW_MANAGER.equals(namespace)) { if (!DeviceConfig.NAMESPACE_DISPLAY_MANAGER.equals(namespace)) {
throw new IllegalArgumentException("Only things in NAMESPACE_WINDOW_MANAGER " throw new IllegalArgumentException("Only things in NAMESPACE_DISPLAY_MANAGER "
+ "supported."); + "supported.");
} }
mListeners.add(new Pair<>(listener, executor)); mListeners.add(new Pair<>(listener, executor));
@@ -153,7 +153,7 @@ public class HighRefreshRateBlacklistTest {
final Executor executor = listenerInfo.second; final Executor executor = listenerInfo.second;
final DeviceConfig.OnPropertyChangedListener listener = listenerInfo.first; final DeviceConfig.OnPropertyChangedListener listener = listenerInfo.first;
executor.execute(() -> { executor.execute(() -> {
listener.onPropertyChanged(DeviceConfig.NAMESPACE_WINDOW_MANAGER, listener.onPropertyChanged(DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
KEY_HIGH_REFRESH_RATE_BLACKLIST, blacklist); KEY_HIGH_REFRESH_RATE_BLACKLIST, blacklist);
latch.countDown(); latch.countDown();
}); });