summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Fiona Campbell <flc@google.com> 2022-11-07 09:54:20 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-11-07 09:54:20 +0000
commit4b68a4d73c8b78b99e75aa2dfa7c3de87203ea37 (patch)
treead4bdb4dbcff7d3494e6ec12e38374d22a057987
parent94f9574f29e5f6134ae1b7d0aeffee2b9edff439 (diff)
parent074e15708401536d5d166af0ec1a7e313bad1622 (diff)
Merge "Only load default lightsensor for Brightness Tracker"
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerService.java3
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java8
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController2.java8
3 files changed, 12 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index e907ebfa6471..9c1fc6011ca3 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -2620,7 +2620,8 @@ 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);
}
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 1f643d7dfe55..838bb53f0b86 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -927,7 +927,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 -> {
@@ -1059,7 +1059,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);
}
@@ -2485,7 +2487,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.
diff --git a/services/core/java/com/android/server/display/DisplayPowerController2.java b/services/core/java/com/android/server/display/DisplayPowerController2.java
index 3c1bf0b8c6aa..d076b262d5fe 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController2.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController2.java
@@ -903,7 +903,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
// 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 -> {
@@ -1035,7 +1035,9 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
}
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);
}
@@ -2439,7 +2441,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
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.