Loading core/java/android/hardware/display/DisplayManager.java +47 −8 Original line number Diff line number Diff line Loading @@ -875,37 +875,76 @@ public final class DisplayManager { public interface DeviceConfig { /** * Key for refresh rate in the zone defined by thresholds. * Key for refresh rate in the low 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_ZONE = "refresh_rate_in_zone"; String KEY_REFRESH_RATE_IN_LOW_ZONE = "refresh_rate_in_zone"; /** * Key for accessing the display brightness thresholds for the configured refresh rate zone. * Key for accessing the low 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_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS = String KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS = "peak_refresh_rate_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. * 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_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS = 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 * @hide */ String KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS = "fixed_refresh_rate_high_ambient_brightness_thresholds"; /** * Key for default peak refresh rate * Loading services/core/java/com/android/server/display/DisplayModeDirector.java +108 −24 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ 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. Loading Loading @@ -515,13 +517,6 @@ public class DisplayModeDirector { } } @VisibleForTesting void updateSettingForHighZone(int refreshRate, int[] brightnessThresholds, int[] ambientThresholds) { mBrightnessObserver.updateThresholdsRefreshRateForHighZone(refreshRate, brightnessThresholds, ambientThresholds); } /** * Listens for changes refresh rate coordination. */ Loading @@ -540,23 +535,41 @@ 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); case MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED: Float defaultPeakRefreshRate = (Float) msg.obj; mSettingsObserver.onDeviceConfigDefaultPeakRefreshRateChanged( defaultPeakRefreshRate); break; } case MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED: case MSG_REFRESH_RATE_IN_HIGH_ZONE_CHANGED: { int refreshRateInZone = msg.arg1; mBrightnessObserver.onDeviceConfigRefreshRateInLowZoneChanged( mBrightnessObserver.onDeviceConfigRefreshRateInHighZoneChanged( refreshRateInZone); break; } case MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED: Float defaultPeakRefreshRate = (Float) msg.obj; mSettingsObserver.onDeviceConfigDefaultPeakRefreshRateChanged( defaultPeakRefreshRate); break; case MSG_REFRESH_RATE_RANGE_CHANGED: DesiredDisplayModeSpecsListener desiredDisplayModeSpecsListener = Loading Loading @@ -1220,13 +1233,6 @@ 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(); Loading @@ -1246,7 +1252,22 @@ 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(); } Loading Loading @@ -1293,6 +1314,29 @@ 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); Loading Loading @@ -1668,7 +1712,7 @@ public class DisplayModeDirector { public int[] getLowDisplayBrightnessThresholds() { return getIntArrayProperty( DisplayManager.DeviceConfig. KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS); KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS); } /* Loading @@ -1677,7 +1721,7 @@ public class DisplayModeDirector { public int[] getLowAmbientBrightnessThresholds() { return getIntArrayProperty( DisplayManager.DeviceConfig. KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS); KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS); } public int getRefreshRateInLowZone() { Loading @@ -1686,7 +1730,37 @@ public class DisplayModeDirector { int refreshRate = mDeviceConfig.getInt( DeviceConfig.NAMESPACE_DISPLAY_MANAGER, DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_ZONE, 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, defaultRefreshRateInZone); return refreshRate; Loading Loading @@ -1721,6 +1795,16 @@ 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) { Loading services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java +46 −7 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.server.display; 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 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 com.android.server.display.DisplayModeDirector.Vote.PRIORITY_FLICKER; Loading Loading @@ -451,7 +454,11 @@ public class DisplayModeDirectorTest { setPeakRefreshRate(90 /*fps*/); director.getSettingsObserver().setDefaultRefreshRate(90); director.getBrightnessObserver().setDefaultDisplayState(true); director.updateSettingForHighZone(60, new int[] {255}, new int[] {8000}); final FakeDeviceConfig config = mInjector.getDeviceConfig(); config.setRefreshRateInHighZone(60); config.setHighDisplayBrightnessThresholds(new int[] { 255 }); config.setHighAmbientBrightnessThresholds(new int[] { 8000 }); Sensor lightSensor = createLightSensor(); SensorManager sensorManager = createMockSensorManager(lightSensor); Loading Loading @@ -508,7 +515,7 @@ public class DisplayModeDirectorTest { void setRefreshRateInLowZone(int fps) { putPropertyAndNotify( DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_ZONE, DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_LOW_ZONE, String.valueOf(fps)); } Loading @@ -521,7 +528,7 @@ public class DisplayModeDirectorTest { putPropertyAndNotify( DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS, KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS, thresholds); } Loading @@ -534,7 +541,39 @@ public class DisplayModeDirectorTest { putPropertyAndNotify( DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS, 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, thresholds); } Loading Loading
core/java/android/hardware/display/DisplayManager.java +47 −8 Original line number Diff line number Diff line Loading @@ -875,37 +875,76 @@ public final class DisplayManager { public interface DeviceConfig { /** * Key for refresh rate in the zone defined by thresholds. * Key for refresh rate in the low 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_ZONE = "refresh_rate_in_zone"; String KEY_REFRESH_RATE_IN_LOW_ZONE = "refresh_rate_in_zone"; /** * Key for accessing the display brightness thresholds for the configured refresh rate zone. * Key for accessing the low 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_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS = String KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS = "peak_refresh_rate_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. * 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_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS = 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 * @hide */ String KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS = "fixed_refresh_rate_high_ambient_brightness_thresholds"; /** * Key for default peak refresh rate * Loading
services/core/java/com/android/server/display/DisplayModeDirector.java +108 −24 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ 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. Loading Loading @@ -515,13 +517,6 @@ public class DisplayModeDirector { } } @VisibleForTesting void updateSettingForHighZone(int refreshRate, int[] brightnessThresholds, int[] ambientThresholds) { mBrightnessObserver.updateThresholdsRefreshRateForHighZone(refreshRate, brightnessThresholds, ambientThresholds); } /** * Listens for changes refresh rate coordination. */ Loading @@ -540,23 +535,41 @@ 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); case MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED: Float defaultPeakRefreshRate = (Float) msg.obj; mSettingsObserver.onDeviceConfigDefaultPeakRefreshRateChanged( defaultPeakRefreshRate); break; } case MSG_REFRESH_RATE_IN_LOW_ZONE_CHANGED: case MSG_REFRESH_RATE_IN_HIGH_ZONE_CHANGED: { int refreshRateInZone = msg.arg1; mBrightnessObserver.onDeviceConfigRefreshRateInLowZoneChanged( mBrightnessObserver.onDeviceConfigRefreshRateInHighZoneChanged( refreshRateInZone); break; } case MSG_DEFAULT_PEAK_REFRESH_RATE_CHANGED: Float defaultPeakRefreshRate = (Float) msg.obj; mSettingsObserver.onDeviceConfigDefaultPeakRefreshRateChanged( defaultPeakRefreshRate); break; case MSG_REFRESH_RATE_RANGE_CHANGED: DesiredDisplayModeSpecsListener desiredDisplayModeSpecsListener = Loading Loading @@ -1220,13 +1233,6 @@ 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(); Loading @@ -1246,7 +1252,22 @@ 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(); } Loading Loading @@ -1293,6 +1314,29 @@ 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); Loading Loading @@ -1668,7 +1712,7 @@ public class DisplayModeDirector { public int[] getLowDisplayBrightnessThresholds() { return getIntArrayProperty( DisplayManager.DeviceConfig. KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS); KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS); } /* Loading @@ -1677,7 +1721,7 @@ public class DisplayModeDirector { public int[] getLowAmbientBrightnessThresholds() { return getIntArrayProperty( DisplayManager.DeviceConfig. KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS); KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS); } public int getRefreshRateInLowZone() { Loading @@ -1686,7 +1730,37 @@ public class DisplayModeDirector { int refreshRate = mDeviceConfig.getInt( DeviceConfig.NAMESPACE_DISPLAY_MANAGER, DisplayManager.DeviceConfig.KEY_REFRESH_RATE_IN_ZONE, 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, defaultRefreshRateInZone); return refreshRate; Loading Loading @@ -1721,6 +1795,16 @@ 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) { Loading
services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java +46 −7 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.server.display; 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 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 com.android.server.display.DisplayModeDirector.Vote.PRIORITY_FLICKER; Loading Loading @@ -451,7 +454,11 @@ public class DisplayModeDirectorTest { setPeakRefreshRate(90 /*fps*/); director.getSettingsObserver().setDefaultRefreshRate(90); director.getBrightnessObserver().setDefaultDisplayState(true); director.updateSettingForHighZone(60, new int[] {255}, new int[] {8000}); final FakeDeviceConfig config = mInjector.getDeviceConfig(); config.setRefreshRateInHighZone(60); config.setHighDisplayBrightnessThresholds(new int[] { 255 }); config.setHighAmbientBrightnessThresholds(new int[] { 8000 }); Sensor lightSensor = createLightSensor(); SensorManager sensorManager = createMockSensorManager(lightSensor); Loading Loading @@ -508,7 +515,7 @@ public class DisplayModeDirectorTest { void setRefreshRateInLowZone(int fps) { putPropertyAndNotify( DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_ZONE, DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_REFRESH_RATE_IN_LOW_ZONE, String.valueOf(fps)); } Loading @@ -521,7 +528,7 @@ public class DisplayModeDirectorTest { putPropertyAndNotify( DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS, KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS, thresholds); } Loading @@ -534,7 +541,39 @@ public class DisplayModeDirectorTest { putPropertyAndNotify( DeviceConfig.NAMESPACE_DISPLAY_MANAGER, KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS, 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, thresholds); } Loading