Loading core/java/android/hardware/display/BrightnessInfo.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,8 @@ public final class BrightnessInfo implements Parcelable { @IntDef(prefix = {"BRIGHTNESS_MAX_REASON_"}, value = { @IntDef(prefix = {"BRIGHTNESS_MAX_REASON_"}, value = { BRIGHTNESS_MAX_REASON_NONE, BRIGHTNESS_MAX_REASON_NONE, BRIGHTNESS_MAX_REASON_THERMAL BRIGHTNESS_MAX_REASON_THERMAL, BRIGHTNESS_MAX_REASON_POWER_IC }) }) @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) public @interface BrightnessMaxReason {} public @interface BrightnessMaxReason {} Loading @@ -74,6 +75,11 @@ public final class BrightnessInfo implements Parcelable { */ */ public static final int BRIGHTNESS_MAX_REASON_THERMAL = 1; public static final int BRIGHTNESS_MAX_REASON_THERMAL = 1; /** * Maximum brightness is restricted due to power throttling. */ public static final int BRIGHTNESS_MAX_REASON_POWER_IC = 2; /** Brightness */ /** Brightness */ public final float brightness; public final float brightness; Loading Loading @@ -144,6 +150,8 @@ public final class BrightnessInfo implements Parcelable { return "none"; return "none"; case BRIGHTNESS_MAX_REASON_THERMAL: case BRIGHTNESS_MAX_REASON_THERMAL: return "thermal"; return "thermal"; case BRIGHTNESS_MAX_REASON_POWER_IC: return "power IC"; } } return "invalid"; return "invalid"; } } Loading core/java/android/hardware/display/DisplayManager.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -1818,6 +1818,12 @@ public final class DisplayManager { */ */ String KEY_BRIGHTNESS_THROTTLING_DATA = "brightness_throttling_data"; String KEY_BRIGHTNESS_THROTTLING_DATA = "brightness_throttling_data"; /** * Key for the power throttling data as a String formatted, from the display * device config. */ String KEY_POWER_THROTTLING_DATA = "power_throttling_data"; /** /** * Key for new power controller feature flag. If enabled new DisplayPowerController will * Key for new power controller feature flag. If enabled new DisplayPowerController will * be used. * be used. Loading services/core/java/com/android/server/display/DeviceStateToLayoutMap.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -135,7 +135,8 @@ class DeviceStateToLayoutMap { leadDisplayAddress, leadDisplayAddress, d.getBrightnessThrottlingMapId(), d.getBrightnessThrottlingMapId(), d.getRefreshRateZoneId(), d.getRefreshRateZoneId(), d.getRefreshRateThermalThrottlingMapId()); d.getRefreshRateThermalThrottlingMapId(), d.getPowerThrottlingMapId()); } } layout.postProcessLocked(); layout.postProcessLocked(); } } Loading services/core/java/com/android/server/display/DisplayPowerController2.java +12 −7 Original line number Original line Diff line number Diff line Loading @@ -506,7 +506,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal mTag = "DisplayPowerController2[" + mDisplayId + "]"; mTag = "DisplayPowerController2[" + mDisplayId + "]"; mThermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId = logicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId; logicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId; mDisplayDevice = mLogicalDisplay.getPrimaryDisplayDeviceLocked(); mDisplayDevice = mLogicalDisplay.getPrimaryDisplayDeviceLocked(); mUniqueDisplayId = logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId(); mUniqueDisplayId = logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId(); mDisplayStatsId = mUniqueDisplayId.hashCode(); mDisplayStatsId = mUniqueDisplayId.hashCode(); Loading Loading @@ -566,8 +565,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal modeChangeCallback::run, new BrightnessClamperController.DisplayDeviceData( modeChangeCallback::run, new BrightnessClamperController.DisplayDeviceData( mUniqueDisplayId, mUniqueDisplayId, mThermalBrightnessThrottlingDataId, mThermalBrightnessThrottlingDataId, mDisplayDeviceConfig logicalDisplay.getPowerThrottlingDataIdLocked(), ), mContext); mDisplayDeviceConfig), mContext, flags); // Seed the cached brightness // Seed the cached brightness saveBrightnessInfo(getScreenBrightnessSetting()); saveBrightnessInfo(getScreenBrightnessSetting()); mAutomaticBrightnessStrategy = mAutomaticBrightnessStrategy = Loading Loading @@ -821,10 +820,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL; .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL; final String thermalBrightnessThrottlingDataId = final String thermalBrightnessThrottlingDataId = mLogicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId; mLogicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId; final String powerThrottlingDataId = mBrightnessClamperController.onDisplayChanged( mLogicalDisplay.getPowerThrottlingDataIdLocked(); new BrightnessClamperController.DisplayDeviceData(mUniqueDisplayId, mThermalBrightnessThrottlingDataId, config)); mHandler.postAtTime(() -> { mHandler.postAtTime(() -> { boolean changed = false; boolean changed = false; Loading Loading @@ -858,6 +855,14 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } } mIsDisplayInternal = isDisplayInternal; mIsDisplayInternal = isDisplayInternal; // using local variables here, when mBrightnessThrottler is removed, // mThermalBrightnessThrottlingDataId could be removed as well // changed = true will be not needed - clampers are maintaining their state and // will call updatePowerState if needed. mBrightnessClamperController.onDisplayChanged( new BrightnessClamperController.DisplayDeviceData(uniqueId, thermalBrightnessThrottlingDataId, powerThrottlingDataId, config)); if (changed) { if (changed) { updatePowerState(); updatePowerState(); } } Loading services/core/java/com/android/server/display/LogicalDisplay.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -189,6 +189,11 @@ final class LogicalDisplay { @Nullable @Nullable private SurfaceControl.RefreshRateRange mLayoutLimitedRefreshRate; private SurfaceControl.RefreshRateRange mLayoutLimitedRefreshRate; /** * The ID of the power throttling data that should be used. */ private String mPowerThrottlingDataId; /** /** * RefreshRateRange limitation for @Temperature.ThrottlingStatus * RefreshRateRange limitation for @Temperature.ThrottlingStatus */ */ Loading @@ -205,6 +210,7 @@ final class LogicalDisplay { mIsEnabled = true; mIsEnabled = true; mIsInTransition = false; mIsInTransition = false; mThermalBrightnessThrottlingDataId = DisplayDeviceConfig.DEFAULT_ID; mThermalBrightnessThrottlingDataId = DisplayDeviceConfig.DEFAULT_ID; mPowerThrottlingDataId = DisplayDeviceConfig.DEFAULT_ID; mBaseDisplayInfo.thermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId; mBaseDisplayInfo.thermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId; } } Loading Loading @@ -910,6 +916,25 @@ final class LogicalDisplay { } } } } /** * @param powerThrottlingDataId The ID of the brightness throttling data that this * display should use. */ public void setPowerThrottlingDataIdLocked(String powerThrottlingDataId) { if (!Objects.equals(powerThrottlingDataId, mPowerThrottlingDataId)) { mPowerThrottlingDataId = powerThrottlingDataId; mDirty = true; } } /** * Returns powerThrottlingDataId which is the ID of the brightness * throttling data that this display should use. */ public String getPowerThrottlingDataIdLocked() { return mPowerThrottlingDataId; } /** /** * Sets the display of which this display is a follower, regarding brightness or other * Sets the display of which this display is a follower, regarding brightness or other * properties. If set to {@link Layout#NO_LEAD_DISPLAY}, this display does not follow any * properties. If set to {@link Layout#NO_LEAD_DISPLAY}, this display does not follow any Loading Loading @@ -976,6 +1001,7 @@ final class LogicalDisplay { pw.println("mLeadDisplayId=" + mLeadDisplayId); pw.println("mLeadDisplayId=" + mLeadDisplayId); pw.println("mLayoutLimitedRefreshRate=" + mLayoutLimitedRefreshRate); pw.println("mLayoutLimitedRefreshRate=" + mLayoutLimitedRefreshRate); pw.println("mThermalRefreshRateThrottling=" + mThermalRefreshRateThrottling); pw.println("mThermalRefreshRateThrottling=" + mThermalRefreshRateThrottling); pw.println("mPowerThrottlingDataId=" + mPowerThrottlingDataId); } } @Override @Override Loading Loading
core/java/android/hardware/display/BrightnessInfo.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,8 @@ public final class BrightnessInfo implements Parcelable { @IntDef(prefix = {"BRIGHTNESS_MAX_REASON_"}, value = { @IntDef(prefix = {"BRIGHTNESS_MAX_REASON_"}, value = { BRIGHTNESS_MAX_REASON_NONE, BRIGHTNESS_MAX_REASON_NONE, BRIGHTNESS_MAX_REASON_THERMAL BRIGHTNESS_MAX_REASON_THERMAL, BRIGHTNESS_MAX_REASON_POWER_IC }) }) @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) public @interface BrightnessMaxReason {} public @interface BrightnessMaxReason {} Loading @@ -74,6 +75,11 @@ public final class BrightnessInfo implements Parcelable { */ */ public static final int BRIGHTNESS_MAX_REASON_THERMAL = 1; public static final int BRIGHTNESS_MAX_REASON_THERMAL = 1; /** * Maximum brightness is restricted due to power throttling. */ public static final int BRIGHTNESS_MAX_REASON_POWER_IC = 2; /** Brightness */ /** Brightness */ public final float brightness; public final float brightness; Loading Loading @@ -144,6 +150,8 @@ public final class BrightnessInfo implements Parcelable { return "none"; return "none"; case BRIGHTNESS_MAX_REASON_THERMAL: case BRIGHTNESS_MAX_REASON_THERMAL: return "thermal"; return "thermal"; case BRIGHTNESS_MAX_REASON_POWER_IC: return "power IC"; } } return "invalid"; return "invalid"; } } Loading
core/java/android/hardware/display/DisplayManager.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -1818,6 +1818,12 @@ public final class DisplayManager { */ */ String KEY_BRIGHTNESS_THROTTLING_DATA = "brightness_throttling_data"; String KEY_BRIGHTNESS_THROTTLING_DATA = "brightness_throttling_data"; /** * Key for the power throttling data as a String formatted, from the display * device config. */ String KEY_POWER_THROTTLING_DATA = "power_throttling_data"; /** /** * Key for new power controller feature flag. If enabled new DisplayPowerController will * Key for new power controller feature flag. If enabled new DisplayPowerController will * be used. * be used. Loading
services/core/java/com/android/server/display/DeviceStateToLayoutMap.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -135,7 +135,8 @@ class DeviceStateToLayoutMap { leadDisplayAddress, leadDisplayAddress, d.getBrightnessThrottlingMapId(), d.getBrightnessThrottlingMapId(), d.getRefreshRateZoneId(), d.getRefreshRateZoneId(), d.getRefreshRateThermalThrottlingMapId()); d.getRefreshRateThermalThrottlingMapId(), d.getPowerThrottlingMapId()); } } layout.postProcessLocked(); layout.postProcessLocked(); } } Loading
services/core/java/com/android/server/display/DisplayPowerController2.java +12 −7 Original line number Original line Diff line number Diff line Loading @@ -506,7 +506,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal mTag = "DisplayPowerController2[" + mDisplayId + "]"; mTag = "DisplayPowerController2[" + mDisplayId + "]"; mThermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId = logicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId; logicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId; mDisplayDevice = mLogicalDisplay.getPrimaryDisplayDeviceLocked(); mDisplayDevice = mLogicalDisplay.getPrimaryDisplayDeviceLocked(); mUniqueDisplayId = logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId(); mUniqueDisplayId = logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId(); mDisplayStatsId = mUniqueDisplayId.hashCode(); mDisplayStatsId = mUniqueDisplayId.hashCode(); Loading Loading @@ -566,8 +565,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal modeChangeCallback::run, new BrightnessClamperController.DisplayDeviceData( modeChangeCallback::run, new BrightnessClamperController.DisplayDeviceData( mUniqueDisplayId, mUniqueDisplayId, mThermalBrightnessThrottlingDataId, mThermalBrightnessThrottlingDataId, mDisplayDeviceConfig logicalDisplay.getPowerThrottlingDataIdLocked(), ), mContext); mDisplayDeviceConfig), mContext, flags); // Seed the cached brightness // Seed the cached brightness saveBrightnessInfo(getScreenBrightnessSetting()); saveBrightnessInfo(getScreenBrightnessSetting()); mAutomaticBrightnessStrategy = mAutomaticBrightnessStrategy = Loading Loading @@ -821,10 +820,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL; .getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL; final String thermalBrightnessThrottlingDataId = final String thermalBrightnessThrottlingDataId = mLogicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId; mLogicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId; final String powerThrottlingDataId = mBrightnessClamperController.onDisplayChanged( mLogicalDisplay.getPowerThrottlingDataIdLocked(); new BrightnessClamperController.DisplayDeviceData(mUniqueDisplayId, mThermalBrightnessThrottlingDataId, config)); mHandler.postAtTime(() -> { mHandler.postAtTime(() -> { boolean changed = false; boolean changed = false; Loading Loading @@ -858,6 +855,14 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } } mIsDisplayInternal = isDisplayInternal; mIsDisplayInternal = isDisplayInternal; // using local variables here, when mBrightnessThrottler is removed, // mThermalBrightnessThrottlingDataId could be removed as well // changed = true will be not needed - clampers are maintaining their state and // will call updatePowerState if needed. mBrightnessClamperController.onDisplayChanged( new BrightnessClamperController.DisplayDeviceData(uniqueId, thermalBrightnessThrottlingDataId, powerThrottlingDataId, config)); if (changed) { if (changed) { updatePowerState(); updatePowerState(); } } Loading
services/core/java/com/android/server/display/LogicalDisplay.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -189,6 +189,11 @@ final class LogicalDisplay { @Nullable @Nullable private SurfaceControl.RefreshRateRange mLayoutLimitedRefreshRate; private SurfaceControl.RefreshRateRange mLayoutLimitedRefreshRate; /** * The ID of the power throttling data that should be used. */ private String mPowerThrottlingDataId; /** /** * RefreshRateRange limitation for @Temperature.ThrottlingStatus * RefreshRateRange limitation for @Temperature.ThrottlingStatus */ */ Loading @@ -205,6 +210,7 @@ final class LogicalDisplay { mIsEnabled = true; mIsEnabled = true; mIsInTransition = false; mIsInTransition = false; mThermalBrightnessThrottlingDataId = DisplayDeviceConfig.DEFAULT_ID; mThermalBrightnessThrottlingDataId = DisplayDeviceConfig.DEFAULT_ID; mPowerThrottlingDataId = DisplayDeviceConfig.DEFAULT_ID; mBaseDisplayInfo.thermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId; mBaseDisplayInfo.thermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId; } } Loading Loading @@ -910,6 +916,25 @@ final class LogicalDisplay { } } } } /** * @param powerThrottlingDataId The ID of the brightness throttling data that this * display should use. */ public void setPowerThrottlingDataIdLocked(String powerThrottlingDataId) { if (!Objects.equals(powerThrottlingDataId, mPowerThrottlingDataId)) { mPowerThrottlingDataId = powerThrottlingDataId; mDirty = true; } } /** * Returns powerThrottlingDataId which is the ID of the brightness * throttling data that this display should use. */ public String getPowerThrottlingDataIdLocked() { return mPowerThrottlingDataId; } /** /** * Sets the display of which this display is a follower, regarding brightness or other * Sets the display of which this display is a follower, regarding brightness or other * properties. If set to {@link Layout#NO_LEAD_DISPLAY}, this display does not follow any * properties. If set to {@link Layout#NO_LEAD_DISPLAY}, this display does not follow any Loading Loading @@ -976,6 +1001,7 @@ final class LogicalDisplay { pw.println("mLeadDisplayId=" + mLeadDisplayId); pw.println("mLeadDisplayId=" + mLeadDisplayId); pw.println("mLayoutLimitedRefreshRate=" + mLayoutLimitedRefreshRate); pw.println("mLayoutLimitedRefreshRate=" + mLayoutLimitedRefreshRate); pw.println("mThermalRefreshRateThrottling=" + mThermalRefreshRateThrottling); pw.println("mThermalRefreshRateThrottling=" + mThermalRefreshRateThrottling); pw.println("mPowerThrottlingDataId=" + mPowerThrottlingDataId); } } @Override @Override Loading