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

Commit 2961e855 authored by Michael Wright's avatar Michael Wright Committed by Automerger Merge Worker
Browse files

Merge "Invoke BrightnessSetting callbacks even with identical brightness."...

Merge "Invoke BrightnessSetting callbacks even with identical brightness." into tm-dev am: aabe27b7 am: fd51081e am: 941264d5

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



Change-Id: I5fadd49e1bdcd764964096556e3e39fa346ad763
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents d94c2b72 941264d5
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -102,13 +102,15 @@ public class BrightnessSetting {
            return;
        }
        synchronized (mSyncRoot) {
            if (brightness == mBrightness) {
                return;
            }

            mBrightness = brightness;
            // If the brightness is the same, we still need to update any listeners as the act of
            // setting the brightness alone has side effects, like clearing any temporary
            // brightness. We can skip persisting to disk, however, since it hasn't actually
            // changed.
            if (brightness != mBrightness) {
                mPersistentDataStore.setBrightness(mLogicalDisplay.getPrimaryDisplayDeviceLocked(),
                        brightness);
            }
            mBrightness = brightness;
            int toSend = Float.floatToIntBits(mBrightness);
            Message msg = mHandler.obtainMessage(MSG_BRIGHTNESS_CHANGED, toSend, 0);
            mHandler.sendMessage(msg);
+1 −1
Original line number Diff line number Diff line
@@ -3349,7 +3349,7 @@ public final class DisplayManagerService extends SystemService {
                synchronized (mSyncRoot) {
                    DisplayPowerController dpc = mDisplayPowerControllers.get(displayId);
                    if (dpc != null) {
                        dpc.putScreenBrightnessSetting(brightness);
                        dpc.setBrightness(brightness);
                    }
                    mPersistentDataStore.saveIfNeeded();
                }
+10 −9
Original line number Diff line number Diff line
@@ -1345,7 +1345,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                if (mAppliedAutoBrightness && !autoBrightnessAdjustmentChanged) {
                    slowChange = true; // slowly adapt to auto-brightness
                }
                updateScreenBrightnessSetting = true;
                updateScreenBrightnessSetting = mCurrentScreenBrightnessSetting != brightnessState;
                mAppliedAutoBrightness = true;
                mBrightnessReasonTemp.setReason(BrightnessReason.REASON_AUTOMATIC);
            } else {
@@ -1415,7 +1415,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            // before applying the low power or dim transformations so that the slider
            // accurately represents the full possible range, even if they range changes what
            // it means in absolute terms.
            putScreenBrightnessSetting(brightnessState, /* updateCurrent */ true);
            updateScreenBrightnessSetting(brightnessState);
        }

        // Apply dimming by at least some minimum amount when user activity
@@ -2288,17 +2288,18 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        return clampScreenBrightnessForVr(brightnessFloat);
    }

    void putScreenBrightnessSetting(float brightnessValue) {
        putScreenBrightnessSetting(brightnessValue, false);
    void setBrightness(float brightnessValue) {
        // Update the setting, which will eventually call back into DPC to have us actually update
        // the display with the new value.
        mBrightnessSetting.setBrightness(brightnessValue);
    }

    private void putScreenBrightnessSetting(float brightnessValue, boolean updateCurrent) {
        if (!isValidBrightnessValue(brightnessValue)) {
    private void updateScreenBrightnessSetting(float brightnessValue) {
        if (!isValidBrightnessValue(brightnessValue)
                || brightnessValue == mCurrentScreenBrightnessSetting) {
            return;
        }
        if (updateCurrent) {
        setCurrentScreenBrightness(brightnessValue);
        }
        mBrightnessSetting.setBrightness(brightnessValue);
    }