BrightnessChangeEvent works for increasing brightness am: 0ce5c2dca6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23215298

Change-Id: Ie81774055040733fa3b6a8eeec832f8a5e8c5d45
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Fiona Campbell
2023-05-13 10:57:41 +00:00
committed by Automerger Merge Worker
3 changed files with 10 additions and 11 deletions

View File

@@ -1454,7 +1454,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
// Skip the animation when the screen is off or suspended. // Skip the animation when the screen is off or suspended.
boolean brightnessAdjusted = false; boolean brightnessAdjusted = false;
final boolean brightnessIsTemporary = final boolean brightnessIsTemporary =
(mBrightnessReason.getReason() == BrightnessReason.REASON_TEMPORARY) (mBrightnessReasonTemp.getReason() == BrightnessReason.REASON_TEMPORARY)
|| mAutomaticBrightnessStrategy || mAutomaticBrightnessStrategy
.isTemporaryAutoBrightnessAdjustmentApplied(); .isTemporaryAutoBrightnessAdjustmentApplied();
if (!mPendingScreenOff) { if (!mPendingScreenOff) {
@@ -2159,11 +2159,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
}, mClock.uptimeMillis()); }, mClock.uptimeMillis());
} }
private float getAutoBrightnessAdjustmentSetting() {
final float adj = Settings.System.getFloatForUser(mContext.getContentResolver(),
Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f, UserHandle.USER_CURRENT);
return Float.isNaN(adj) ? 0.0f : clampAutoBrightnessAdjustment(adj);
}
@Override @Override
public float getScreenBrightnessSetting() { public float getScreenBrightnessSetting() {
@@ -2436,9 +2431,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
} }
} }
private static float clampAutoBrightnessAdjustment(float value) {
return MathUtils.constrain(value, -1.0f, 1.0f);
}
private void noteScreenState(int screenState) { private void noteScreenState(int screenState) {
// Log screen state change with display id // Log screen state change with display id

View File

@@ -41,6 +41,13 @@ public final class BrightnessUtils {
PowerManager.BRIGHTNESS_MAX); PowerManager.BRIGHTNESS_MAX);
} }
/**
* Clamps the brightness value in the maximum and the minimum brightness adjustment range
*/
public static float clampBrightnessAdjustment(float value) {
return MathUtils.constrain(value, -1.0f, 1.0f);
}
/** /**
* A utility to construct the DisplayBrightnessState * A utility to construct the DisplayBrightnessState
*/ */

View File

@@ -202,7 +202,7 @@ public class AutomaticBrightnessStrategy {
final float adj = Settings.System.getFloatForUser(mContext.getContentResolver(), final float adj = Settings.System.getFloatForUser(mContext.getContentResolver(),
Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f, UserHandle.USER_CURRENT); Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f, UserHandle.USER_CURRENT);
mPendingAutoBrightnessAdjustment = Float.isNaN(adj) ? Float.NaN mPendingAutoBrightnessAdjustment = Float.isNaN(adj) ? Float.NaN
: BrightnessUtils.clampAbsoluteBrightness(adj); : BrightnessUtils.clampBrightnessAdjustment(adj);
if (userSwitch) { if (userSwitch) {
processPendingAutoBrightnessAdjustments(); processPendingAutoBrightnessAdjustments();
} }
@@ -402,6 +402,6 @@ public class AutomaticBrightnessStrategy {
private float getAutoBrightnessAdjustmentSetting() { private float getAutoBrightnessAdjustmentSetting() {
final float adj = Settings.System.getFloatForUser(mContext.getContentResolver(), final float adj = Settings.System.getFloatForUser(mContext.getContentResolver(),
Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f, UserHandle.USER_CURRENT); Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f, UserHandle.USER_CURRENT);
return Float.isNaN(adj) ? 0.0f : BrightnessUtils.clampAbsoluteBrightness(adj); return Float.isNaN(adj) ? 0.0f : BrightnessUtils.clampBrightnessAdjustment(adj);
} }
} }