summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rupesh Bansal <brup@google.com> 2023-04-14 08:30:33 +0000
committer Rupesh Bansal <brup@google.com> 2023-04-14 09:53:01 +0000
commit51d5a47903a063e25b5c73b1356e5ee9f775be1d (patch)
tree0b1e14484d63a12323d1119d71007423b32298ea
parent844c5aec4826d6e12e6f25546a2cdd5b73205f2c (diff)
Add a lock independent check for internal display while logging manual
brightness events. Test: Manually verified the device is working as expected Bug: 277715436 Change-Id: I9dbf5872b98b118def25c3dbbfe4a4d5f8af949a
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java12
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController2.java12
2 files changed, 17 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 5e3990ac7167..43082c1f1f6f 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -514,6 +514,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
private boolean mIsEnabled;
private boolean mIsInTransition;
+ private boolean mIsDisplayInternal;
// The id of the thermal brightness throttling policy that should be used.
private String mThermalBrightnessThrottlingDataId;
@@ -553,6 +554,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mDisplayStatsId = mUniqueDisplayId.hashCode();
mIsEnabled = logicalDisplay.isEnabledLocked();
mIsInTransition = logicalDisplay.isInTransitionLocked();
+ mIsDisplayInternal = logicalDisplay.getPrimaryDisplayDeviceLocked()
+ .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL;
mHandler = new DisplayControllerHandler(handler.getLooper());
mLastBrightnessEvent = new BrightnessEvent(mDisplayId);
mTempBrightnessEvent = new BrightnessEvent(mDisplayId);
@@ -892,6 +895,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
final boolean isEnabled = mLogicalDisplay.isEnabledLocked();
final boolean isInTransition = mLogicalDisplay.isInTransitionLocked();
+ final boolean isDisplayInternal = mLogicalDisplay.getPrimaryDisplayDeviceLocked() != null
+ && mLogicalDisplay.getPrimaryDisplayDeviceLocked()
+ .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL;
final String thermalBrightnessThrottlingDataId =
mLogicalDisplay.getThermalBrightnessThrottlingDataIdLocked();
mHandler.postAtTime(() -> {
@@ -924,7 +930,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mIsEnabled = isEnabled;
mIsInTransition = isInTransition;
}
-
+ mIsDisplayInternal = isDisplayInternal;
if (changed) {
updatePowerState();
}
@@ -3074,9 +3080,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
event.getThermalMax() == PowerManager.BRIGHTNESS_MAX
? -1f : convertToNits(event.getThermalMax());
- if (mLogicalDisplay.getPrimaryDisplayDeviceLocked() != null
- && mLogicalDisplay.getPrimaryDisplayDeviceLocked()
- .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL) {
+ if (mIsDisplayInternal) {
FrameworkStatsLog.write(FrameworkStatsLog.DISPLAY_BRIGHTNESS_CHANGED,
convertToNits(event.getInitialBrightness()),
convertToNits(event.getBrightness()),
diff --git a/services/core/java/com/android/server/display/DisplayPowerController2.java b/services/core/java/com/android/server/display/DisplayPowerController2.java
index 23e606c028ac..7339874e7bfa 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController2.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController2.java
@@ -399,6 +399,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
private boolean mIsEnabled;
private boolean mIsInTransition;
+ private boolean mIsDisplayInternal;
// The id of the thermal brightness throttling policy that should be used.
private String mThermalBrightnessThrottlingDataId;
@@ -431,6 +432,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
.getDisplayDeviceConfig();
mIsEnabled = logicalDisplay.isEnabledLocked();
mIsInTransition = logicalDisplay.isInTransitionLocked();
+ mIsDisplayInternal = logicalDisplay.getPrimaryDisplayDeviceLocked()
+ .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL;
mWakelockController = mInjector.getWakelockController(mDisplayId, callbacks);
mDisplayPowerProximityStateController = mInjector.getDisplayPowerProximityStateController(
mWakelockController, mDisplayDeviceConfig, mHandler.getLooper(),
@@ -708,6 +711,9 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
final boolean isEnabled = mLogicalDisplay.isEnabledLocked();
final boolean isInTransition = mLogicalDisplay.isInTransitionLocked();
+ final boolean isDisplayInternal = mLogicalDisplay.getPrimaryDisplayDeviceLocked() != null
+ && mLogicalDisplay.getPrimaryDisplayDeviceLocked()
+ .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL;
final String thermalBrightnessThrottlingDataId =
mLogicalDisplay.getThermalBrightnessThrottlingDataIdLocked();
@@ -742,6 +748,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
mIsInTransition = isInTransition;
}
+ mIsDisplayInternal = isDisplayInternal;
if (changed) {
updatePowerState();
}
@@ -2217,6 +2224,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
pw.println(" mSkipScreenOnBrightnessRamp=" + mSkipScreenOnBrightnessRamp);
pw.println(" mColorFadeFadesConfig=" + mColorFadeFadesConfig);
pw.println(" mColorFadeEnabled=" + mColorFadeEnabled);
+ pw.println(" mIsDisplayInternal=" + mIsDisplayInternal);
synchronized (mCachedBrightnessInfo) {
pw.println(" mCachedBrightnessInfo.brightness="
+ mCachedBrightnessInfo.brightness.value);
@@ -2434,9 +2442,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
float appliedThermalCapNits =
event.getThermalMax() == PowerManager.BRIGHTNESS_MAX
? -1f : mDisplayBrightnessController.convertToNits(event.getThermalMax());
- if (mLogicalDisplay.getPrimaryDisplayDeviceLocked() != null
- && mLogicalDisplay.getPrimaryDisplayDeviceLocked()
- .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL) {
+ if (mIsDisplayInternal) {
FrameworkStatsLog.write(FrameworkStatsLog.DISPLAY_BRIGHTNESS_CHANGED,
mDisplayBrightnessController.convertToNits(event.getInitialBrightness()),
mDisplayBrightnessController.convertToNits(event.getBrightness()),