Skip to content

Commit 364ecec

Browse files
raylinhsuandroid-build-team Robot
authored andcommitted
DO NOT MERGE Revert "Allow DeviceConfig to change display settings for high zone"
This reverts commit cf55c21. Bug: 176018998 Test: atest DisplayModeDirectorTest Change-Id: Ib576e16257d7903b39efa8015c2af3be8c0d0c40 (cherry picked from commit b14bed8)
1 parent 2e21c28 commit 364ecec

3 files changed

Lines changed: 39 additions & 201 deletions

File tree

core/java/android/hardware/display/DisplayManager.java

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -875,76 +875,37 @@ public interface DisplayListener {
875875
public interface DeviceConfig {
876876

877877
/**
878-
* Key for refresh rate in the low zone defined by thresholds.
878+
* Key for refresh rate in the zone defined by thresholds.
879879
*
880-
* Note that the name and value don't match because they were added before we had a high
881-
* zone to consider.
882880
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
883881
* @see android.R.integer#config_defaultZoneBehavior
884882
*/
885-
String KEY_REFRESH_RATE_IN_LOW_ZONE = "refresh_rate_in_zone";
883+
String KEY_REFRESH_RATE_IN_ZONE = "refresh_rate_in_zone";
886884

887885
/**
888-
* Key for accessing the low display brightness thresholds for the configured refresh
889-
* rate zone.
886+
* Key for accessing the display brightness thresholds for the configured refresh rate zone.
890887
* The value will be a pair of comma separated integers representing the minimum and maximum
891888
* thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]).
892889
*
893-
* Note that the name and value don't match because they were added before we had a high
894-
* zone to consider.
895-
*
896890
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
897891
* @see android.R.array#config_brightnessThresholdsOfPeakRefreshRate
898892
* @hide
899893
*/
900-
String KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS =
894+
String KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS =
901895
"peak_refresh_rate_brightness_thresholds";
902896

903-
/**
904-
* Key for accessing the low ambient brightness thresholds for the configured refresh
905-
* rate zone. The value will be a pair of comma separated integers representing the minimum
906-
* and maximum thresholds of the zone, respectively, in lux.
907-
*
908-
* Note that the name and value don't match because they were added before we had a high
909-
* zone to consider.
910-
*
911-
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
912-
* @see android.R.array#config_ambientThresholdsOfPeakRefreshRate
913-
* @hide
914-
*/
915-
String KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS =
916-
"peak_refresh_rate_ambient_thresholds";
917-
/**
918-
* Key for refresh rate in the high zone defined by thresholds.
919-
*
920-
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
921-
* @see android.R.integer#config_fixedRefreshRateInHighZone
922-
*/
923-
String KEY_REFRESH_RATE_IN_HIGH_ZONE = "refresh_rate_in_high_zone";
924-
925-
/**
926-
* Key for accessing the display brightness thresholds for the configured refresh rate zone.
927-
* The value will be a pair of comma separated integers representing the minimum and maximum
928-
* thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]).
929-
*
930-
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
931-
* @see android.R.array#config_brightnessHighThresholdsOfFixedRefreshRate
932-
* @hide
933-
*/
934-
String KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS =
935-
"fixed_refresh_rate_high_display_brightness_thresholds";
936-
937897
/**
938898
* Key for accessing the ambient brightness thresholds for the configured refresh rate zone.
939899
* The value will be a pair of comma separated integers representing the minimum and maximum
940900
* thresholds of the zone, respectively, in lux.
941901
*
942902
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
943-
* @see android.R.array#config_ambientHighThresholdsOfFixedRefreshRate
903+
* @see android.R.array#config_ambientThresholdsOfPeakRefreshRate
944904
* @hide
945905
*/
946-
String KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS =
947-
"fixed_refresh_rate_high_ambient_brightness_thresholds";
906+
String KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS =
907+
"peak_refresh_rate_ambient_thresholds";
908+
948909
/**
949910
* Key for default peak refresh rate
950911
*

services/core/java/com/android/server/display/DisplayModeDirector.java

Lines changed: 24 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ public class DisplayModeDirector {
6969
private static final int MSG_LOW_BRIGHTNESS_THRESHOLDS_CHANGED = 2;
7070
private static final int MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED = 3;
7171
private static final int MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED = 4;
72-
private static final int MSG_REFRESH_RATE_IN_HIGH_ZONE_CHANGED = 5;
73-
private static final int MSG_HIGH_BRIGHTNESS_THRESHOLDS_CHANGED = 6;
7472

7573
// Special ID used to indicate that given vote is to be applied globally, rather than to a
7674
// specific display.
@@ -517,6 +515,13 @@ DesiredDisplayModeSpecs getDesiredDisplayModeSpecsWithInjectedFpsSettings(
517515
}
518516
}
519517

518+
@VisibleForTesting
519+
void updateSettingForHighZone(int refreshRate, int[] brightnessThresholds,
520+
int[] ambientThresholds) {
521+
mBrightnessObserver.updateThresholdsRefreshRateForHighZone(refreshRate,
522+
brightnessThresholds, ambientThresholds);
523+
}
524+
520525
/**
521526
* Listens for changes refresh rate coordination.
522527
*/
@@ -535,42 +540,24 @@ private final class DisplayModeDirectorHandler extends Handler {
535540
@Override
536541
public void handleMessage(Message msg) {
537542
switch (msg.what) {
538-
case MSG_LOW_BRIGHTNESS_THRESHOLDS_CHANGED: {
543+
case MSG_LOW_BRIGHTNESS_THRESHOLDS_CHANGED:
539544
Pair<int[], int[]> thresholds = (Pair<int[], int[]>) msg.obj;
540545
mBrightnessObserver.onDeviceConfigLowBrightnessThresholdsChanged(
541546
thresholds.first, thresholds.second);
542547
break;
543-
}
544-
545-
case MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED: {
546-
int refreshRateInZone = msg.arg1;
547-
mBrightnessObserver.onDeviceConfigRefreshRateInLowZoneChanged(
548-
refreshRateInZone);
549-
break;
550-
}
551-
552-
case MSG_HIGH_BRIGHTNESS_THRESHOLDS_CHANGED: {
553-
Pair<int[], int[]> thresholds = (Pair<int[], int[]>) msg.obj;
554-
555-
mBrightnessObserver.onDeviceConfigHighBrightnessThresholdsChanged(
556-
thresholds.first, thresholds.second);
557-
558-
break;
559-
}
560-
561-
case MSG_REFRESH_RATE_IN_HIGH_ZONE_CHANGED: {
562-
int refreshRateInZone = msg.arg1;
563-
mBrightnessObserver.onDeviceConfigRefreshRateInHighZoneChanged(
564-
refreshRateInZone);
565-
break;
566-
}
567548

568549
case MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED:
569550
Float defaultPeakRefreshRate = (Float) msg.obj;
570551
mSettingsObserver.onDeviceConfigDefaultPeakRefreshRateChanged(
571552
defaultPeakRefreshRate);
572553
break;
573554

555+
case MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED:
556+
int refreshRateInZone = msg.arg1;
557+
mBrightnessObserver.onDeviceConfigRefreshRateInLowZoneChanged(
558+
refreshRateInZone);
559+
break;
560+
574561
case MSG_REFRESH_RATE_RANGE_CHANGED:
575562
DesiredDisplayModeSpecsListener desiredDisplayModeSpecsListener =
576563
(DesiredDisplayModeSpecsListener) msg.obj;
@@ -1233,6 +1220,13 @@ public void registerLightSensor(SensorManager sensorManager, Sensor lightSensor)
12331220
mLightSensor, LIGHT_SENSOR_RATE_MS * 1000, mHandler);
12341221
}
12351222

1223+
public void updateThresholdsRefreshRateForHighZone(int refreshRate,
1224+
int[] brightnessThresholds, int[] ambientThresholds) {
1225+
mRefreshRateInHighZone = refreshRate;
1226+
mHighDisplayBrightnessThresholds = brightnessThresholds;
1227+
mHighAmbientBrightnessThresholds = ambientThresholds;
1228+
}
1229+
12361230
public void observe(SensorManager sensorManager) {
12371231
mSensorManager = sensorManager;
12381232
final ContentResolver cr = mContext.getContentResolver();
@@ -1252,22 +1246,7 @@ public void observe(SensorManager sensorManager) {
12521246
mLowAmbientBrightnessThresholds = lowAmbientBrightnessThresholds;
12531247
}
12541248

1255-
1256-
int[] highDisplayBrightnessThresholds =
1257-
mDeviceConfigDisplaySettings.getHighDisplayBrightnessThresholds();
1258-
int[] highAmbientBrightnessThresholds =
1259-
mDeviceConfigDisplaySettings.getHighAmbientBrightnessThresholds();
1260-
1261-
if (highDisplayBrightnessThresholds != null && highAmbientBrightnessThresholds != null
1262-
&& highDisplayBrightnessThresholds.length
1263-
== highAmbientBrightnessThresholds.length) {
1264-
mHighDisplayBrightnessThresholds = highDisplayBrightnessThresholds;
1265-
mHighAmbientBrightnessThresholds = highAmbientBrightnessThresholds;
1266-
}
1267-
12681249
mRefreshRateInLowZone = mDeviceConfigDisplaySettings.getRefreshRateInLowZone();
1269-
mRefreshRateInHighZone = mDeviceConfigDisplaySettings.getRefreshRateInHighZone();
1270-
12711250
restartObserver();
12721251
mDeviceConfigDisplaySettings.startListening();
12731252
}
@@ -1314,29 +1293,6 @@ public void onDeviceConfigRefreshRateInLowZoneChanged(int refreshRate) {
13141293
}
13151294
}
13161295

1317-
public void onDeviceConfigHighBrightnessThresholdsChanged(int[] displayThresholds,
1318-
int[] ambientThresholds) {
1319-
if (displayThresholds != null && ambientThresholds != null
1320-
&& displayThresholds.length == ambientThresholds.length) {
1321-
mHighDisplayBrightnessThresholds = displayThresholds;
1322-
mHighAmbientBrightnessThresholds = ambientThresholds;
1323-
} else {
1324-
// Invalid or empty. Use device default.
1325-
mHighDisplayBrightnessThresholds = mContext.getResources().getIntArray(
1326-
R.array.config_highDisplayBrightnessThresholdsOfFixedRefreshRate);
1327-
mHighAmbientBrightnessThresholds = mContext.getResources().getIntArray(
1328-
R.array.config_highAmbientBrightnessThresholdsOfFixedRefreshRate);
1329-
}
1330-
restartObserver();
1331-
}
1332-
1333-
public void onDeviceConfigRefreshRateInHighZoneChanged(int refreshRate) {
1334-
if (refreshRate != mRefreshRateInHighZone) {
1335-
mRefreshRateInHighZone = refreshRate;
1336-
restartObserver();
1337-
}
1338-
}
1339-
13401296
public void dumpLocked(PrintWriter pw) {
13411297
pw.println(" BrightnessObserver");
13421298
pw.println(" mAmbientLux: " + mAmbientLux);
@@ -1712,7 +1668,7 @@ public void startListening() {
17121668
public int[] getLowDisplayBrightnessThresholds() {
17131669
return getIntArrayProperty(
17141670
DisplayManager.DeviceConfig.
1715-
KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS);
1671+
KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS);
17161672
}
17171673

17181674
/*
@@ -1721,7 +1677,7 @@ public int[] getLowDisplayBrightnessThresholds() {
17211677
public int[] getLowAmbientBrightnessThresholds() {
17221678
return getIntArrayProperty(
17231679
DisplayManager.DeviceConfig.
1724-
KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS);
1680+
KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS);
17251681
}
17261682

17271683
public int getRefreshRateInLowZone() {
@@ -1730,37 +1686,7 @@ public int getRefreshRateInLowZone() {
17301686

17311687
int refreshRate = mDeviceConfig.getInt(
17321688
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
1733-
DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_LOW_ZONE,
1734-
defaultRefreshRateInZone);
1735-
1736-
return refreshRate;
1737-
}
1738-
1739-
/*
1740-
* Return null if no such property or wrong format (not comma separated integers).
1741-
*/
1742-
public int[] getHighDisplayBrightnessThresholds() {
1743-
return getIntArrayProperty(
1744-
DisplayManager.DeviceConfig
1745-
.KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS);
1746-
}
1747-
1748-
/*
1749-
* Return null if no such property or wrong format (not comma separated integers).
1750-
*/
1751-
public int[] getHighAmbientBrightnessThresholds() {
1752-
return getIntArrayProperty(
1753-
DisplayManager.DeviceConfig
1754-
.KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS);
1755-
}
1756-
1757-
public int getRefreshRateInHighZone() {
1758-
int defaultRefreshRateInZone = mContext.getResources().getInteger(
1759-
R.integer.config_fixedRefreshRateInHighZone);
1760-
1761-
int refreshRate = mDeviceConfig.getInt(
1762-
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
1763-
DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_HIGH_ZONE,
1689+
DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_ZONE,
17641690
defaultRefreshRateInZone);
17651691

17661692
return refreshRate;
@@ -1795,16 +1721,6 @@ public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
17951721
.sendToTarget();
17961722
mHandler.obtainMessage(MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED, refreshRateInLowZone, 0)
17971723
.sendToTarget();
1798-
1799-
int[] highDisplayBrightnessThresholds = getHighDisplayBrightnessThresholds();
1800-
int[] highAmbientBrightnessThresholds = getHighAmbientBrightnessThresholds();
1801-
int refreshRateInHighZone = getRefreshRateInHighZone();
1802-
1803-
mHandler.obtainMessage(MSG_HIGH_BRIGHTNESS_THRESHOLDS_CHANGED,
1804-
new Pair<>(highDisplayBrightnessThresholds, highAmbientBrightnessThresholds))
1805-
.sendToTarget();
1806-
mHandler.obtainMessage(MSG_REFRESH_RATE_IN_HIGH_ZONE_CHANGED, refreshRateInHighZone, 0)
1807-
.sendToTarget();
18081724
}
18091725

18101726
private int[] getIntArrayProperty(String prop) {

services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616

1717
package com.android.server.display;
1818

19-
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS;
20-
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS;
21-
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS;
22-
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS;
23-
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_HIGH_ZONE;
24-
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_LOW_ZONE;
19+
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS;
20+
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS;
21+
import static android.hardware.display.DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_ZONE;
2522

2623
import static com.android.server.display.DisplayModeDirector.Vote.PRIORITY_FLICKER;
2724

@@ -454,11 +451,7 @@ public void testLockFpsForHighZone() throws Exception {
454451
setPeakRefreshRate(90 /*fps*/);
455452
director.getSettingsObserver().setDefaultRefreshRate(90);
456453
director.getBrightnessObserver().setDefaultDisplayState(true);
457-
458-
final FakeDeviceConfig config = mInjector.getDeviceConfig();
459-
config.setRefreshRateInHighZone(60);
460-
config.setHighDisplayBrightnessThresholds(new int[] { 255 });
461-
config.setHighAmbientBrightnessThresholds(new int[] { 8000 });
454+
director.updateSettingForHighZone(60, new int[] {255}, new int[] {8000});
462455

463456
Sensor lightSensor = createLightSensor();
464457
SensorManager sensorManager = createMockSensorManager(lightSensor);
@@ -515,7 +508,7 @@ public void addOnPropertiesChangedListener(
515508

516509
void setRefreshRateInLowZone(int fps) {
517510
putPropertyAndNotify(
518-
DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_LOW_ZONE,
511+
DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_ZONE,
519512
String.valueOf(fps));
520513
}
521514

@@ -528,7 +521,7 @@ void setLowDisplayBrightnessThresholds(int[] brightnessThresholds) {
528521

529522
putPropertyAndNotify(
530523
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
531-
KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS,
524+
KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS,
532525
thresholds);
533526
}
534527

@@ -541,39 +534,7 @@ void setLowAmbientBrightnessThresholds(int[] ambientThresholds) {
541534

542535
putPropertyAndNotify(
543536
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
544-
KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS,
545-
thresholds);
546-
}
547-
548-
void setRefreshRateInHighZone(int fps) {
549-
putPropertyAndNotify(
550-
DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_HIGH_ZONE,
551-
String.valueOf(fps));
552-
}
553-
554-
void setHighDisplayBrightnessThresholds(int[] brightnessThresholds) {
555-
String thresholds = toPropertyValue(brightnessThresholds);
556-
557-
if (DEBUG) {
558-
Slog.e(TAG, "Brightness Thresholds = " + thresholds);
559-
}
560-
561-
putPropertyAndNotify(
562-
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
563-
KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS,
564-
thresholds);
565-
}
566-
567-
void setHighAmbientBrightnessThresholds(int[] ambientThresholds) {
568-
String thresholds = toPropertyValue(ambientThresholds);
569-
570-
if (DEBUG) {
571-
Slog.e(TAG, "Ambient Thresholds = " + thresholds);
572-
}
573-
574-
putPropertyAndNotify(
575-
DeviceConfig.NAMESPACE_DISPLAY_MANAGER,
576-
KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS,
537+
KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS,
577538
thresholds);
578539
}
579540

0 commit comments

Comments
 (0)