Loading core/res/res/values/config.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -4068,6 +4068,9 @@ for higher refresh rates to be automatically used out of the box --> for higher refresh rates to be automatically used out of the box --> <integer name="config_defaultPeakRefreshRate">60</integer> <integer name="config_defaultPeakRefreshRate">60</integer> <!-- The default brightness threshold that allows to switch to higher refresh rate --> <integer name="config_brightnessThresholdOfPeakRefreshRate">-1</integer> <!-- The type of the light sensor to be used by the display framework for things like <!-- The type of the light sensor to be used by the display framework for things like auto-brightness. If unset, then it just gets the default sensor of type TYPE_LIGHT. --> auto-brightness. If unset, then it just gets the default sensor of type TYPE_LIGHT. --> <string name="config_displayLightSensorType" translatable="false" /> <string name="config_displayLightSensorType" translatable="false" /> Loading core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3767,6 +3767,7 @@ <!-- For high refresh rate displays --> <!-- For high refresh rate displays --> <java-symbol type="integer" name="config_defaultPeakRefreshRate" /> <java-symbol type="integer" name="config_defaultPeakRefreshRate" /> <java-symbol type="integer" name="config_brightnessThresholdOfPeakRefreshRate" /> <!-- For Auto-Brightness --> <!-- For Auto-Brightness --> <java-symbol type="string" name="config_displayLightSensorType" /> <java-symbol type="string" name="config_displayLightSensorType" /> Loading services/core/java/com/android/server/display/DisplayModeDirector.java +31 −1 Original line number Original line Diff line number Diff line Loading @@ -407,7 +407,8 @@ public class DisplayModeDirector { // the other. // the other. public static final int PRIORITY_APP_REQUEST_REFRESH_RATE = 1; public static final int PRIORITY_APP_REQUEST_REFRESH_RATE = 1; public static final int PRIORITY_APP_REQUEST_SIZE = 2; public static final int PRIORITY_APP_REQUEST_SIZE = 2; public static final int PRIORITY_LOW_POWER_MODE = 3; public static final int PRIORITY_LOW_BRIGHTNESS = 3; public static final int PRIORITY_LOW_POWER_MODE = 4; // Whenever a new priority is added, remember to update MIN_PRIORITY and/or MAX_PRIORITY as // Whenever a new priority is added, remember to update MIN_PRIORITY and/or MAX_PRIORITY as // appropriate, as well as priorityToString. // appropriate, as well as priorityToString. Loading Loading @@ -485,15 +486,20 @@ public class DisplayModeDirector { Settings.System.getUriFor(Settings.System.PEAK_REFRESH_RATE); Settings.System.getUriFor(Settings.System.PEAK_REFRESH_RATE); private final Uri mLowPowerModeSetting = private final Uri mLowPowerModeSetting = Settings.Global.getUriFor(Settings.Global.LOW_POWER_MODE); Settings.Global.getUriFor(Settings.Global.LOW_POWER_MODE); private final Uri mBrightnessSetting = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS); private final Context mContext; private final Context mContext; private final float mDefaultPeakRefreshRate; private final float mDefaultPeakRefreshRate; private final int mBrightnessThreshold; SettingsObserver(@NonNull Context context, @NonNull Handler handler) { SettingsObserver(@NonNull Context context, @NonNull Handler handler) { super(handler); super(handler); mContext = context; mContext = context; mDefaultPeakRefreshRate = (float) context.getResources().getInteger( mDefaultPeakRefreshRate = (float) context.getResources().getInteger( R.integer.config_defaultPeakRefreshRate); R.integer.config_defaultPeakRefreshRate); mBrightnessThreshold = context.getResources().getInteger( R.integer.config_brightnessThresholdOfPeakRefreshRate); } } public void observe() { public void observe() { Loading @@ -502,9 +508,14 @@ 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); if (mBrightnessThreshold >= 0) { cr.registerContentObserver(mBrightnessSetting, false /*notifyDescendants*/, this, UserHandle.USER_SYSTEM); } synchronized (mLock) { synchronized (mLock) { updateRefreshRateSettingLocked(); updateRefreshRateSettingLocked(); updateLowPowerModeSettingLocked(); updateLowPowerModeSettingLocked(); updateBrightnessSettingLocked(); } } } } Loading @@ -515,6 +526,8 @@ public class DisplayModeDirector { updateRefreshRateSettingLocked(); updateRefreshRateSettingLocked(); } else if (mLowPowerModeSetting.equals(uri)) { } else if (mLowPowerModeSetting.equals(uri)) { updateLowPowerModeSettingLocked(); updateLowPowerModeSettingLocked(); } else if (mBrightnessThreshold >=0 && mBrightnessSetting.equals(uri)) { updateBrightnessSettingLocked(); } } } } } } Loading @@ -538,6 +551,23 @@ public class DisplayModeDirector { updateVoteLocked(Vote.PRIORITY_USER_SETTING, vote); updateVoteLocked(Vote.PRIORITY_USER_SETTING, vote); } } private void updateBrightnessSettingLocked() { int brightness = Settings.System.getInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, -1); if (brightness < 0) { return; } final Vote vote; if (brightness <= mBrightnessThreshold) { vote = Vote.forRefreshRates(0f, 60f); } else { vote = null; } updateVoteLocked(Vote.PRIORITY_LOW_BRIGHTNESS, vote); } public void dumpLocked(PrintWriter pw) { public void dumpLocked(PrintWriter pw) { pw.println(" SettingsObserver"); pw.println(" SettingsObserver"); pw.println(" mDefaultPeakRefreshRate: " + mDefaultPeakRefreshRate); pw.println(" mDefaultPeakRefreshRate: " + mDefaultPeakRefreshRate); Loading Loading
core/res/res/values/config.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -4068,6 +4068,9 @@ for higher refresh rates to be automatically used out of the box --> for higher refresh rates to be automatically used out of the box --> <integer name="config_defaultPeakRefreshRate">60</integer> <integer name="config_defaultPeakRefreshRate">60</integer> <!-- The default brightness threshold that allows to switch to higher refresh rate --> <integer name="config_brightnessThresholdOfPeakRefreshRate">-1</integer> <!-- The type of the light sensor to be used by the display framework for things like <!-- The type of the light sensor to be used by the display framework for things like auto-brightness. If unset, then it just gets the default sensor of type TYPE_LIGHT. --> auto-brightness. If unset, then it just gets the default sensor of type TYPE_LIGHT. --> <string name="config_displayLightSensorType" translatable="false" /> <string name="config_displayLightSensorType" translatable="false" /> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3767,6 +3767,7 @@ <!-- For high refresh rate displays --> <!-- For high refresh rate displays --> <java-symbol type="integer" name="config_defaultPeakRefreshRate" /> <java-symbol type="integer" name="config_defaultPeakRefreshRate" /> <java-symbol type="integer" name="config_brightnessThresholdOfPeakRefreshRate" /> <!-- For Auto-Brightness --> <!-- For Auto-Brightness --> <java-symbol type="string" name="config_displayLightSensorType" /> <java-symbol type="string" name="config_displayLightSensorType" /> Loading
services/core/java/com/android/server/display/DisplayModeDirector.java +31 −1 Original line number Original line Diff line number Diff line Loading @@ -407,7 +407,8 @@ public class DisplayModeDirector { // the other. // the other. public static final int PRIORITY_APP_REQUEST_REFRESH_RATE = 1; public static final int PRIORITY_APP_REQUEST_REFRESH_RATE = 1; public static final int PRIORITY_APP_REQUEST_SIZE = 2; public static final int PRIORITY_APP_REQUEST_SIZE = 2; public static final int PRIORITY_LOW_POWER_MODE = 3; public static final int PRIORITY_LOW_BRIGHTNESS = 3; public static final int PRIORITY_LOW_POWER_MODE = 4; // Whenever a new priority is added, remember to update MIN_PRIORITY and/or MAX_PRIORITY as // Whenever a new priority is added, remember to update MIN_PRIORITY and/or MAX_PRIORITY as // appropriate, as well as priorityToString. // appropriate, as well as priorityToString. Loading Loading @@ -485,15 +486,20 @@ public class DisplayModeDirector { Settings.System.getUriFor(Settings.System.PEAK_REFRESH_RATE); Settings.System.getUriFor(Settings.System.PEAK_REFRESH_RATE); private final Uri mLowPowerModeSetting = private final Uri mLowPowerModeSetting = Settings.Global.getUriFor(Settings.Global.LOW_POWER_MODE); Settings.Global.getUriFor(Settings.Global.LOW_POWER_MODE); private final Uri mBrightnessSetting = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS); private final Context mContext; private final Context mContext; private final float mDefaultPeakRefreshRate; private final float mDefaultPeakRefreshRate; private final int mBrightnessThreshold; SettingsObserver(@NonNull Context context, @NonNull Handler handler) { SettingsObserver(@NonNull Context context, @NonNull Handler handler) { super(handler); super(handler); mContext = context; mContext = context; mDefaultPeakRefreshRate = (float) context.getResources().getInteger( mDefaultPeakRefreshRate = (float) context.getResources().getInteger( R.integer.config_defaultPeakRefreshRate); R.integer.config_defaultPeakRefreshRate); mBrightnessThreshold = context.getResources().getInteger( R.integer.config_brightnessThresholdOfPeakRefreshRate); } } public void observe() { public void observe() { Loading @@ -502,9 +508,14 @@ 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); if (mBrightnessThreshold >= 0) { cr.registerContentObserver(mBrightnessSetting, false /*notifyDescendants*/, this, UserHandle.USER_SYSTEM); } synchronized (mLock) { synchronized (mLock) { updateRefreshRateSettingLocked(); updateRefreshRateSettingLocked(); updateLowPowerModeSettingLocked(); updateLowPowerModeSettingLocked(); updateBrightnessSettingLocked(); } } } } Loading @@ -515,6 +526,8 @@ public class DisplayModeDirector { updateRefreshRateSettingLocked(); updateRefreshRateSettingLocked(); } else if (mLowPowerModeSetting.equals(uri)) { } else if (mLowPowerModeSetting.equals(uri)) { updateLowPowerModeSettingLocked(); updateLowPowerModeSettingLocked(); } else if (mBrightnessThreshold >=0 && mBrightnessSetting.equals(uri)) { updateBrightnessSettingLocked(); } } } } } } Loading @@ -538,6 +551,23 @@ public class DisplayModeDirector { updateVoteLocked(Vote.PRIORITY_USER_SETTING, vote); updateVoteLocked(Vote.PRIORITY_USER_SETTING, vote); } } private void updateBrightnessSettingLocked() { int brightness = Settings.System.getInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, -1); if (brightness < 0) { return; } final Vote vote; if (brightness <= mBrightnessThreshold) { vote = Vote.forRefreshRates(0f, 60f); } else { vote = null; } updateVoteLocked(Vote.PRIORITY_LOW_BRIGHTNESS, vote); } public void dumpLocked(PrintWriter pw) { public void dumpLocked(PrintWriter pw) { pw.println(" SettingsObserver"); pw.println(" SettingsObserver"); pw.println(" mDefaultPeakRefreshRate: " + mDefaultPeakRefreshRate); pw.println(" mDefaultPeakRefreshRate: " + mDefaultPeakRefreshRate); Loading