summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author raylinhsu <raylinhsu@google.com> 2021-01-13 13:13:02 +0800
committer android-build-team Robot <android-build-team-robot@google.com> 2021-01-14 23:02:44 +0000
commit364ecec0779d28ef68bcc9601789a1fe0986af0e (patch)
tree4ece00fc17881124dac25bac7491d59a9d47ad23
parent2e21c28280512e3b6862bd8c0af6eaded91c0002 (diff)
DO NOT MERGE Revert "Allow DeviceConfig to change display settings for high zone"
This reverts commit cf55c21064cd6f906ca7e64f66f1cc8e1346fda6. Bug: 176018998 Test: atest DisplayModeDirectorTest Change-Id: Ib576e16257d7903b39efa8015c2af3be8c0d0c40 (cherry picked from commit b14bed88c5aec64fef15b4e727fff4623bb8efe7)
-rw-r--r--core/java/android/hardware/display/DisplayManager.java55
-rw-r--r--services/core/java/com/android/server/display/DisplayModeDirector.java132
-rw-r--r--services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java53
3 files changed, 39 insertions, 201 deletions
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java
index 0fa4ca8a574b..c1ba2094d3cf 100644
--- a/core/java/android/hardware/display/DisplayManager.java
+++ b/core/java/android/hardware/display/DisplayManager.java
@@ -875,76 +875,37 @@ public final class DisplayManager {
public interface DeviceConfig {
/**
- * Key for refresh rate in the low zone defined by thresholds.
+ * Key for refresh rate in the zone defined by thresholds.
*
- * Note that the name and value don't match because they were added before we had a high
- * zone to consider.
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.integer#config_defaultZoneBehavior
*/
- String KEY_REFRESH_RATE_IN_LOW_ZONE = "refresh_rate_in_zone";
+ String KEY_REFRESH_RATE_IN_ZONE = "refresh_rate_in_zone";
/**
- * Key for accessing the low display brightness thresholds for the configured refresh
- * rate zone.
+ * Key for accessing the display brightness thresholds for the configured refresh rate zone.
* The value will be a pair of comma separated integers representing the minimum and maximum
* thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]).
*
- * Note that the name and value don't match because they were added before we had a high
- * zone to consider.
- *
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.array#config_brightnessThresholdsOfPeakRefreshRate
* @hide
*/
- String KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS =
+ String KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS =
"peak_refresh_rate_brightness_thresholds";
/**
- * Key for accessing the low ambient brightness thresholds for the configured refresh
- * rate zone. The value will be a pair of comma separated integers representing the minimum
- * and maximum thresholds of the zone, respectively, in lux.
- *
- * Note that the name and value don't match because they were added before we had a high
- * zone to consider.
- *
- * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
- * @see android.R.array#config_ambientThresholdsOfPeakRefreshRate
- * @hide
- */
- String KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS =
- "peak_refresh_rate_ambient_thresholds";
- /**
- * Key for refresh rate in the high zone defined by thresholds.
- *
- * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
- * @see android.R.integer#config_fixedRefreshRateInHighZone
- */
- String KEY_REFRESH_RATE_IN_HIGH_ZONE = "refresh_rate_in_high_zone";
-
- /**
- * Key for accessing the display brightness thresholds for the configured refresh rate zone.
- * The value will be a pair of comma separated integers representing the minimum and maximum
- * thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]).
- *
- * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
- * @see android.R.array#config_brightnessHighThresholdsOfFixedRefreshRate
- * @hide
- */
- String KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS =
- "fixed_refresh_rate_high_display_brightness_thresholds";
-
- /**
* Key for accessing the ambient brightness thresholds for the configured refresh rate zone.
* The value will be a pair of comma separated integers representing the minimum and maximum
* thresholds of the zone, respectively, in lux.
*
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
- * @see android.R.array#config_ambientHighThresholdsOfFixedRefreshRate
+ * @see android.R.array#config_ambientThresholdsOfPeakRefreshRate
* @hide
*/
- String KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS =
- "fixed_refresh_rate_high_ambient_brightness_thresholds";
+ String KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS =
+ "peak_refresh_rate_ambient_thresholds";
+
/**
* Key for default peak refresh rate
*
diff --git a/services/core/java/com/android/server/display/DisplayModeDirector.java b/services/core/java/com/android/server/display/DisplayModeDirector.java
index 02ee059194ec..2a60839ab702 100644
--- a/services/core/java/com/android/server/display/DisplayModeDirector.java
+++ b/services/core/java/com/android/server/display/DisplayModeDirector.java
@@ -69,8 +69,6 @@ public class DisplayModeDirector {
private static final int MSG_LOW_BRIGHTNESS_THRESHOLDS_CHANGED = 2;
private static final int MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED = 3;
private static final int MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED = 4;
- private static final int MSG_REFRESH_RATE_IN_HIGH_ZONE_CHANGED = 5;
- private static final int MSG_HIGH_BRIGHTNESS_THRESHOLDS_CHANGED = 6;
// Special ID used to indicate that given vote is to be applied globally, rather than to a
// specific display.
@@ -517,6 +515,13 @@ public class DisplayModeDirector {
}
}
+ @VisibleForTesting
+ void updateSettingForHighZone(int refreshRate, int[] brightnessThresholds,
+ int[] ambientThresholds) {
+ mBrightnessObserver.updateThresholdsRefreshRateForHighZone(refreshRate,
+ brightnessThresholds, ambientThresholds);
+ }
+
/**
* Listens for changes refresh rate coordination.
*/
@@ -535,35 +540,11 @@ public class DisplayModeDirector {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
- case MSG_LOW_BRIGHTNESS_THRESHOLDS_CHANGED: {
+ case MSG_LOW_BRIGHTNESS_THRESHOLDS_CHANGED:
Pair<int[], int[]> thresholds = (Pair<int[], int[]>) msg.obj;
mBrightnessObserver.onDeviceConfigLowBrightnessThresholdsChanged(
thresholds.first, thresholds.second);
break;
- }
-
- case MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED: {
- int refreshRateInZone = msg.arg1;
- mBrightnessObserver.onDeviceConfigRefreshRateInLowZoneChanged(
- refreshRateInZone);
- break;
- }
-
- case MSG_HIGH_BRIGHTNESS_THRESHOLDS_CHANGED: {
- Pair<int[], int[]> thresholds = (Pair<int[], int[]>) msg.obj;
-
- mBrightnessObserver.onDeviceConfigHighBrightnessThresholdsChanged(
- thresholds.first, thresholds.second);
-
- break;
- }
-
- case MSG_REFRESH_RATE_IN_HIGH_ZONE_CHANGED: {
- int refreshRateInZone = msg.arg1;
- mBrightnessObserver.onDeviceConfigRefreshRateInHighZoneChanged(
- refreshRateInZone);
- break;
- }
case MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED:
Float defaultPeakRefreshRate = (Float) msg.obj;
@@ -571,6 +552,12 @@ public class DisplayModeDirector {
defaultPeakRefreshRate);
break;
+ case MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED:
+ int refreshRateInZone = msg.arg1;
+ mBrightnessObserver.onDeviceConfigRefreshRateInLowZoneChanged(
+ refreshRateInZone);
+ break;
+
case MSG_REFRESH_RATE_RANGE_CHANGED:
DesiredDisplayModeSpecsListener desiredDisplayModeSpecsListener =
(DesiredDisplayModeSpecsListener) msg.obj;
@@ -1233,6 +1220,13 @@ public class DisplayModeDirector {
mLightSensor, LIGHT_SENSOR_RATE_MS * 1000, mHandler);
}
+ public void updateThresholdsRefreshRateForHighZone(int refreshRate,
+ int[] brightnessThresholds, int[] ambientThresholds) {
+ mRefreshRateInHighZone = refreshRate;
+ mHighDisplayBrightnessThresholds = brightnessThresholds;
+ mHighAmbientBrightnessThresholds = ambientThresholds;
+ }
+
public void observe(SensorManager sensorManager) {
mSensorManager = sensorManager;
final ContentResolver cr = mContext.getContentResolver();
@@ -1252,22 +1246,7 @@ public class DisplayModeDirector {
mLowAmbientBrightnessThresholds = lowAmbientBrightnessThresholds;
}
-
- int[] highDisplayBrightnessThresholds =
- mDeviceConfigDisplaySettings.getHighDisplayBrightnessThresholds();
- int[] highAmbientBrightnessThresholds =
- mDeviceConfigDisplaySettings.getHighAmbientBrightnessThresholds();
-
- if (highDisplayBrightnessThresholds != null && highAmbientBrightnessThresholds != null
- && highDisplayBrightnessThresholds.length
- == highAmbientBrightnessThresholds.length) {
- mHighDisplayBrightnessThresholds = highDisplayBrightnessThresholds;
- mHighAmbientBrightnessThresholds = highAmbientBrightnessThresholds;
- }
-
mRefreshRateInLowZone = mDeviceConfigDisplaySettings.getRefreshRateInLowZone();
- mRefreshRateInHighZone = mDeviceConfigDisplaySettings.getRefreshRateInHighZone();
-
restartObserver();
mDeviceConfigDisplaySettings.startListening();
}
@@ -1314,29 +1293,6 @@ public class DisplayModeDirector {
}
}
- public void onDeviceConfigHighBrightnessThresholdsChanged(int[] displayThresholds,
- int[] ambientThresholds) {
- if (displayThresholds != null && ambientThresholds != null
- && displayThresholds.length == ambientThresholds.length) {
- mHighDisplayBrightnessThresholds = displayThresholds;
- mHighAmbientBrightnessThresholds = ambientThresholds;
- } else {
- // Invalid or empty. Use device default.
- mHighDisplayBrightnessThresholds = mContext.getResources().getIntArray(
- R.array.config_highDisplayBrightnessThresholdsOfFixedRefreshRate);
- mHighAmbientBrightnessThresholds = mContext.getResources().getIntArray(
- R.array.config_highAmbientBrightnessThresholdsOfFixedRefreshRate);
- }
- restartObserver();
- }
-
- public void onDeviceConfigRefreshRateInHighZoneChanged(int refreshRate) {
- if (refreshRate != mRefreshRateInHighZone) {
- mRefreshRateInHighZone = refreshRate;
- restartObserver();
- }
- }
-
public void dumpLocked(PrintWriter pw) {
pw.println(" BrightnessObserver");
pw.println(" mAmbientLux: " + mAmbientLux);
@@ -1712,7 +1668,7 @@ public class DisplayModeDirector {
public int[] getLowDisplayBrightnessThresholds() {
return getIntArrayProperty(
DisplayManager.DeviceConfig.
- KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS);
+ KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS);
}
/*
@@ -1721,7 +1677,7 @@ public class DisplayModeDirector {
public int[] getLowAmbientBrightnessThresholds() {
return getIntArrayProperty(
DisplayManager.DeviceConfig.
- KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS);
+ KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS);
}
public int getRefreshRateInLowZone() {
@@ -1730,37 +1686,7 @@ public class DisplayModeDirector {
int refreshRate = mDeviceConfig.getInt(
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
- DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_LOW_ZONE,
- defaultRefreshRateInZone);
-
- return refreshRate;
- }
-
- /*
- * Return null if no such property or wrong format (not comma separated integers).
- */
- public int[] getHighDisplayBrightnessThresholds() {
- return getIntArrayProperty(
- DisplayManager.DeviceConfig
- .KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS);
- }
-
- /*
- * Return null if no such property or wrong format (not comma separated integers).
- */
- public int[] getHighAmbientBrightnessThresholds() {
- return getIntArrayProperty(
- DisplayManager.DeviceConfig
- .KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS);
- }
-
- public int getRefreshRateInHighZone() {
- int defaultRefreshRateInZone = mContext.getResources().getInteger(
- R.integer.config_fixedRefreshRateInHighZone);
-
- int refreshRate = mDeviceConfig.getInt(
- DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
- DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_HIGH_ZONE,
+ DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_ZONE,
defaultRefreshRateInZone);
return refreshRate;
@@ -1795,16 +1721,6 @@ public class DisplayModeDirector {
.sendToTarget();
mHandler.obtainMessage(MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED, refreshRateInLowZone, 0)
.sendToTarget();
-
- int[] highDisplayBrightnessThresholds = getHighDisplayBrightnessThresholds();
- int[] highAmbientBrightnessThresholds = getHighAmbientBrightnessThresholds();
- int refreshRateInHighZone = getRefreshRateInHighZone();
-
- mHandler.obtainMessage(MSG_HIGH_BRIGHTNESS_THRESHOLDS_CHANGED,
- new Pair<>(highDisplayBrightnessThresholds, highAmbientBrightnessThresholds))
- .sendToTarget();
- mHandler.obtainMessage(MSG_REFRESH_RATE_IN_HIGH_ZONE_CHANGED, refreshRateInHighZone, 0)
- .sendToTarget();
}
private int[] getIntArrayProperty(String prop) {
diff --git a/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java b/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java
index c467ee949aeb..4ee6a553b9d1 100644
--- a/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java
@@ -16,12 +16,9 @@
package com.android.server.display;
-import static android.hardware.display.DisplayManager.DeviceConfig.KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS;
-import static android.hardware.display.DisplayManager.DeviceConfig.KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS;
-import static android.hardware.display.DisplayManager.DeviceConfig.KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS;
-import static android.hardware.display.DisplayManager.DeviceConfig.KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS;
-import static android.hardware.display.DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_HIGH_ZONE;
-import static android.hardware.display.DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_LOW_ZONE;
+import static android.hardware.display.DisplayManager.DeviceConfig.KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS;
+import static android.hardware.display.DisplayManager.DeviceConfig.KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS;
+import static android.hardware.display.DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_ZONE;
import static com.android.server.display.DisplayModeDirector.Vote.PRIORITY_FLICKER;
@@ -454,11 +451,7 @@ public class DisplayModeDirectorTest {
setPeakRefreshRate(90 /*fps*/);
director.getSettingsObserver().setDefaultRefreshRate(90);
director.getBrightnessObserver().setDefaultDisplayState(true);
-
- final FakeDeviceConfig config = mInjector.getDeviceConfig();
- config.setRefreshRateInHighZone(60);
- config.setHighDisplayBrightnessThresholds(new int[] { 255 });
- config.setHighAmbientBrightnessThresholds(new int[] { 8000 });
+ director.updateSettingForHighZone(60, new int[] {255}, new int[] {8000});
Sensor lightSensor = createLightSensor();
SensorManager sensorManager = createMockSensorManager(lightSensor);
@@ -515,7 +508,7 @@ public class DisplayModeDirectorTest {
void setRefreshRateInLowZone(int fps) {
putPropertyAndNotify(
- DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_LOW_ZONE,
+ DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_ZONE,
String.valueOf(fps));
}
@@ -528,7 +521,7 @@ public class DisplayModeDirectorTest {
putPropertyAndNotify(
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
- KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS,
+ KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS,
thresholds);
}
@@ -541,39 +534,7 @@ public class DisplayModeDirectorTest {
putPropertyAndNotify(
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
- KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS,
- thresholds);
- }
-
- void setRefreshRateInHighZone(int fps) {
- putPropertyAndNotify(
- DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_HIGH_ZONE,
- String.valueOf(fps));
- }
-
- void setHighDisplayBrightnessThresholds(int[] brightnessThresholds) {
- String thresholds = toPropertyValue(brightnessThresholds);
-
- if (DEBUG) {
- Slog.e(TAG, "Brightness Thresholds = " + thresholds);
- }
-
- putPropertyAndNotify(
- DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
- KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS,
- thresholds);
- }
-
- void setHighAmbientBrightnessThresholds(int[] ambientThresholds) {
- String thresholds = toPropertyValue(ambientThresholds);
-
- if (DEBUG) {
- Slog.e(TAG, "Ambient Thresholds = " + thresholds);
- }
-
- putPropertyAndNotify(
- DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
- KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS,
+ KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS,
thresholds);
}