Merge "Only load default lightsensor for Brightness Tracker" into tm-qpr-dev am: 10cd7d5904

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

Change-Id: I3f67e881105afbe356a9d8bd717a3c8cd4791b4c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Fiona Campbell
2022-11-07 10:32:19 +00:00
committed by Automerger Merge Worker
2 changed files with 6 additions and 4 deletions

View File

@@ -2598,7 +2598,7 @@ public final class DisplayManagerService extends SystemService {
// initPowerManagement has not yet been called.
return;
}
if (mBrightnessTracker == null) {
if (mBrightnessTracker == null && display.getDisplayIdLocked() == Display.DEFAULT_DISPLAY) {
mBrightnessTracker = new BrightnessTracker(mContext, null);
}

View File

@@ -913,7 +913,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// Initialize all of the brightness tracking state
final float brightness = convertToNits(mPowerState.getScreenBrightness());
if (brightness >= PowerManager.BRIGHTNESS_MIN) {
if (mBrightnessTracker != null && brightness >= PowerManager.BRIGHTNESS_MIN) {
mBrightnessTracker.start(brightness);
}
mBrightnessSettingListener = brightnessValue -> {
@@ -1045,7 +1045,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
}
loadAmbientLightSensor();
if (mBrightnessTracker != null) {
// BrightnessTracker should only use one light sensor, we want to use the light sensor
// from the default display and not e.g. temporary displays when switching layouts.
if (mBrightnessTracker != null && mDisplayId == Display.DEFAULT_DISPLAY) {
mBrightnessTracker.setLightSensor(mLightSensor);
}
@@ -2453,7 +2455,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
boolean hadUserDataPoint) {
final float brightnessInNits = convertToNits(brightness);
if (mPowerRequest.useAutoBrightness && brightnessInNits >= 0.0f
&& mAutomaticBrightnessController != null) {
&& mAutomaticBrightnessController != null && mBrightnessTracker != null) {
// We only want to track changes on devices that can actually map the display backlight
// values into a physical brightness unit since the value provided by the API is in
// nits and not using the arbitrary backlight units.