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

Commit 10f89b08 authored by Piotr Wilczyński's avatar Piotr Wilczyński Committed by Android (Google) Code Review
Browse files

Merge "Provide the current auto-brightness levels in DisplayOffloadSession" into main

parents 80a235b2 32fba93b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -751,6 +751,13 @@ public abstract class DisplayManagerInternal {
         */
        boolean blockScreenOn(Runnable unblocker);

        /** Get the current brightness levels used to determine automatic brightness based on lux
         * levels. */
        float[] getCurrentAutoBrightnessLevels();

        /** Get the current lux levels used to determine automatic brightness. */
        float[] getCurrentAutoBrightnessLuxLevels();

        /** Returns whether displayoffload supports the given display state. */
        static boolean isSupportedOffloadState(int displayState) {
            return Display.isSuspendedState(displayState);
+13 −11
Original line number Diff line number Diff line
@@ -403,7 +403,8 @@ public class AutomaticBrightnessController {
                    | (!mAmbientLuxValid ? BrightnessEvent.FLAG_INVALID_LUX : 0)
                    | (mDisplayPolicy == DisplayPowerRequest.POLICY_DOZE
                        ? BrightnessEvent.FLAG_DOZE_SCALE : 0)
                    | (isInIdleMode() ? BrightnessEvent.FLAG_IDLE_CURVE : 0));
                    | (getMode() == AUTO_BRIGHTNESS_MODE_IDLE
                        ? BrightnessEvent.FLAG_IDLE_CURVE : 0));
        }

        if (!mAmbientLuxValid) {
@@ -514,7 +515,8 @@ public class AutomaticBrightnessController {
        if (mLoggingEnabled) {
            Slog.d(TAG, "Display policy transitioning from " + oldPolicy + " to " + policy);
        }
        if (!isInteractivePolicy(policy) && isInteractivePolicy(oldPolicy) && !isInIdleMode()) {
        if (!isInteractivePolicy(policy) && isInteractivePolicy(oldPolicy)
                && getMode() != AUTO_BRIGHTNESS_MODE_IDLE) {
            mHandler.sendEmptyMessageDelayed(MSG_INVALIDATE_CURRENT_SHORT_TERM_MODEL,
                    mCurrentBrightnessMapper.getShortTermModelTimeout());
        } else if (isInteractivePolicy(policy) && !isInteractivePolicy(oldPolicy)) {
@@ -555,7 +557,7 @@ public class AutomaticBrightnessController {
            boolean shouldResetShortTermModel) {
        if (mBrightnessMappingStrategyMap.get(AUTO_BRIGHTNESS_MODE_DEFAULT)
                .setBrightnessConfiguration(configuration)) {
            if (!isInIdleMode() && shouldResetShortTermModel) {
            if (getMode() != AUTO_BRIGHTNESS_MODE_IDLE && shouldResetShortTermModel) {
                resetShortTermModel();
            }
            return true;
@@ -563,8 +565,9 @@ public class AutomaticBrightnessController {
        return false;
    }

    public boolean isInIdleMode() {
        return mCurrentBrightnessMapper.getMode() == AUTO_BRIGHTNESS_MODE_IDLE;
    @AutomaticBrightnessController.AutomaticBrightnessMode
    public int getMode() {
        return mCurrentBrightnessMapper.getMode();
    }

    public void dump(PrintWriter pw) {
@@ -620,8 +623,7 @@ public class AutomaticBrightnessController {
        pw.println("  mPendingForegroundAppPackageName=" + mPendingForegroundAppPackageName);
        pw.println("  mForegroundAppCategory=" + mForegroundAppCategory);
        pw.println("  mPendingForegroundAppCategory=" + mPendingForegroundAppCategory);
        pw.println("  Current mode="
                + autoBrightnessModeToString(mCurrentBrightnessMapper.getMode()));
        pw.println("  Current mode=" + autoBrightnessModeToString(getMode()));

        pw.println();
        for (int i = 0; i < mBrightnessMappingStrategyMap.size(); i++) {
@@ -743,7 +745,7 @@ public class AutomaticBrightnessController {
            lux = 0;
        }
        mAmbientLux = lux;
        if (isInIdleMode()) {
        if (getMode() == AUTO_BRIGHTNESS_MODE_IDLE) {
            mAmbientBrighteningThreshold =
                    mAmbientBrightnessThresholdsIdle.getBrighteningThreshold(lux);
            mAmbientDarkeningThreshold =
@@ -835,7 +837,7 @@ public class AutomaticBrightnessController {
            }
            earliestValidTime = mAmbientLightRingBuffer.getTime(i);
        }
        return earliestValidTime + (isInIdleMode()
        return earliestValidTime + (getMode() == AUTO_BRIGHTNESS_MODE_IDLE
                ? mBrighteningLightDebounceConfigIdle : mBrighteningLightDebounceConfig);
    }

@@ -848,7 +850,7 @@ public class AutomaticBrightnessController {
            }
            earliestValidTime = mAmbientLightRingBuffer.getTime(i);
        }
        return earliestValidTime + (isInIdleMode()
        return earliestValidTime + (getMode() == AUTO_BRIGHTNESS_MODE_IDLE
                ? mDarkeningLightDebounceConfigIdle : mDarkeningLightDebounceConfig);
    }

@@ -973,7 +975,7 @@ public class AutomaticBrightnessController {
                mPreThresholdBrightness = mScreenAutoBrightness;
            }
            mScreenAutoBrightness = newScreenAutoBrightness;
            if (isInIdleMode()) {
            if (getMode() == AUTO_BRIGHTNESS_MODE_IDLE) {
                mScreenBrighteningThreshold = clampScreenBrightness(
                        mScreenBrightnessThresholdsIdle.getBrighteningThreshold(
                                newScreenAutoBrightness));
+10 −0
Original line number Diff line number Diff line
@@ -65,6 +65,16 @@ public class DisplayOffloadSessionImpl implements DisplayManagerInternal.Display
        return true;
    }

    @Override
    public float[] getCurrentAutoBrightnessLevels() {
        return mDisplayPowerController.getCurrentAutoBrightnessLevels();
    }

    @Override
    public float[] getCurrentAutoBrightnessLuxLevels() {
        return mDisplayPowerController.getCurrentAutoBrightnessLuxLevels();
    }

    /**
     * Start the offload session. The method returns if the session is already active.
     * @return Whether the session was started successfully
+16 −3
Original line number Diff line number Diff line
@@ -1119,7 +1119,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                DisplayPowerState.SCREEN_BRIGHTNESS_FLOAT,
                DisplayPowerState.SCREEN_SDR_BRIGHTNESS_FLOAT);
        setAnimatorRampSpeeds(mAutomaticBrightnessController != null
                && mAutomaticBrightnessController.isInIdleMode());
                && mAutomaticBrightnessController.getMode() == AUTO_BRIGHTNESS_MODE_IDLE);
        mScreenBrightnessRampAnimator.setListener(mRampAnimatorListener);

        noteScreenState(mPowerState.getScreenState());
@@ -1990,7 +1990,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    boolean isIncreasing = animateValue > currentBrightness;
                    final float rampSpeed;
                    final boolean idle = mAutomaticBrightnessController != null
                            && mAutomaticBrightnessController.isInIdleMode();
                            && mAutomaticBrightnessController.getMode()
                            == AUTO_BRIGHTNESS_MODE_IDLE;
                    if (isIncreasing && slowChange) {
                        rampSpeed = idle ? mBrightnessRampRateSlowIncreaseIdle
                                : mBrightnessRampRateSlowIncrease;
@@ -2213,6 +2214,18 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        // The old DPC is no longer supported
    }

    @Override
    public float[] getCurrentAutoBrightnessLevels() {
        // The old DPC is no longer supported
        return new float[0];
    }

    @Override
    public float[] getCurrentAutoBrightnessLuxLevels() {
        // The old DPC is no longer supported
        return new float[0];
    }

    @Override
    public BrightnessInfo getBrightnessInfo() {
        synchronized (mCachedBrightnessInfo) {
@@ -2898,7 +2911,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        // or the nits is invalid.
        if (brightnessIsTemporary
                || mAutomaticBrightnessController == null
                || mAutomaticBrightnessController.isInIdleMode()
                || mAutomaticBrightnessController.getMode() == AUTO_BRIGHTNESS_MODE_IDLE
                || !autobrightnessEnabled
                || mBrightnessTracker == null
                || !mUseAutoBrightness
+17 −4
Original line number Diff line number Diff line
@@ -951,7 +951,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
                DisplayPowerState.SCREEN_BRIGHTNESS_FLOAT,
                DisplayPowerState.SCREEN_SDR_BRIGHTNESS_FLOAT);
        setAnimatorRampSpeeds(mAutomaticBrightnessController != null
                && mAutomaticBrightnessController.isInIdleMode());
                && mAutomaticBrightnessController.getMode() == AUTO_BRIGHTNESS_MODE_IDLE);
        mScreenBrightnessRampAnimator.setListener(mRampAnimatorListener);

        noteScreenState(mPowerState.getScreenState());
@@ -1365,7 +1365,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal

        // Switch to doze auto-brightness mode if needed
        if (mFlags.areAutoBrightnessModesEnabled() && mAutomaticBrightnessController != null
                && !mAutomaticBrightnessController.isInIdleMode()) {
                && mAutomaticBrightnessController.getMode() != AUTO_BRIGHTNESS_MODE_IDLE) {
            setAutomaticScreenBrightnessMode(Display.isDozeState(state)
                    ? AUTO_BRIGHTNESS_MODE_DOZE : AUTO_BRIGHTNESS_MODE_DEFAULT);
        }
@@ -1654,7 +1654,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
                    boolean isIncreasing = animateValue > currentBrightness;
                    final float rampSpeed;
                    final boolean idle = mAutomaticBrightnessController != null
                            && mAutomaticBrightnessController.isInIdleMode();
                            && mAutomaticBrightnessController.getMode()
                            == AUTO_BRIGHTNESS_MODE_IDLE;
                    if (isIncreasing && slowChange) {
                        rampSpeed = idle ? mBrightnessRampRateSlowIncreaseIdle
                                : mBrightnessRampRateSlowIncrease;
@@ -1885,6 +1886,18 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
        mHandler.sendMessageAtTime(msg, mClock.uptimeMillis());
    }

    @Override
    public float[] getCurrentAutoBrightnessLevels() {
        return mDisplayDeviceConfig.getAutoBrightnessBrighteningLevels(
                mAutomaticBrightnessController.getMode());
    }

    @Override
    public float[] getCurrentAutoBrightnessLuxLevels() {
        return mDisplayDeviceConfig.getAutoBrightnessBrighteningLevelsLux(
                mAutomaticBrightnessController.getMode());
    }

    @Override
    public BrightnessInfo getBrightnessInfo() {
        synchronized (mCachedBrightnessInfo) {
@@ -2460,7 +2473,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
        // or the nits is invalid.
        if (brightnessIsTemporary
                || mAutomaticBrightnessController == null
                || mAutomaticBrightnessController.isInIdleMode()
                || mAutomaticBrightnessController.getMode() == AUTO_BRIGHTNESS_MODE_IDLE
                || !autobrightnessEnabled
                || mBrightnessTracker == null
                || !shouldUseAutoBrightness
Loading