@@ -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 ) {
0 commit comments