Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30b6c196 authored by Rupesh Bansal's avatar Rupesh Bansal Committed by Android (Google) Code Review
Browse files

Merge "Add a lock independent check for internal display while logging manual...

Merge "Add a lock independent check for internal display while logging manual brightness events." into udc-dev
parents 5eefdf69 51d5a479
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -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()),
+9 −3
Original line number Diff line number Diff line
@@ -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()),