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

Commit 4bfcae9a authored by Jeff Brown's avatar Jeff Brown Committed by Android Git Automerger
Browse files

am 77669abb: am 9beccf9f: Merge "Defer display ready until brightness ramp...

am 77669abb: am 9beccf9f: Merge "Defer display ready until brightness ramp completes." into klp-modular-dev

* commit '77669abb':
  Defer display ready until brightness ramp completes.
parents d862ebb6 77669abb
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -390,6 +390,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call

        mScreenBrightnessRampAnimator = new RampAnimator<DisplayPowerState>(
                mPowerState, DisplayPowerState.SCREEN_BRIGHTNESS);
        mScreenBrightnessRampAnimator.setListener(mRampAnimatorListener);

        // Initialize screen state for battery stats.
        try {
@@ -416,6 +417,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        }
    };

    private final RampAnimator.Listener mRampAnimatorListener = new RampAnimator.Listener() {
        @Override
        public void onAnimationEnd() {
            sendUpdatePowerState();
        }
    };

    private void updatePowerState() {
        // Update the power state request.
        final boolean mustNotify;
@@ -602,6 +610,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                && !mScreenOnWasBlocked
                && !mElectronBeamOnAnimator.isStarted()
                && !mElectronBeamOffAnimator.isStarted()
                && !mScreenBrightnessRampAnimator.isAnimating()
                && mPowerState.waitUntilClean(mCleanListener)) {
            synchronized (mLock) {
                if (!mPendingRequestChangedLocked) {
@@ -843,6 +852,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        pw.println("  mScreenOffBecauseOfProximity=" + mScreenOffBecauseOfProximity);
        pw.println("  mUsingScreenAutoBrightness=" + mUsingScreenAutoBrightness);

        pw.println("  mScreenBrightnessRampAnimator.isAnimating()=" +
                mScreenBrightnessRampAnimator.isAnimating());

        if (mElectronBeamOnAnimator != null) {
            pw.println("  mElectronBeamOnAnimator.isStarted()=" +
                    mElectronBeamOnAnimator.isStarted());
+23 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ final class RampAnimator<T> {

    private boolean mFirstTime = true;

    private Listener mListener;

    public RampAnimator(T object, IntProperty<T> property) {
        mObject = object;
        mProperty = property;
@@ -92,6 +94,20 @@ final class RampAnimator<T> {
        return changed;
    }

    /**
     * Returns true if the animation is running.
     */
    public boolean isAnimating() {
        return mAnimating;
    }

    /**
     * Sets a listener to watch for animation events.
     */
    public void setListener(Listener listener) {
        mListener = listener;
    }

    private void postCallback() {
        mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, mCallback, null);
    }
@@ -131,7 +147,14 @@ final class RampAnimator<T> {
                postCallback();
            } else {
                mAnimating = false;
                if (mListener != null) {
                    mListener.onAnimationEnd();
                }
            }
        }
    };

    public interface Listener {
        void onAnimationEnd();
    }
}