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

Commit 41e6346b authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Don't animate burn-in return when it wasn't applied.

The burn-in protection return animation is performed based on the last
offset that was used, but it doesn't mean that such offset is currently
applied. Right after entering ambient mode no offset is applied, so if
we start a return animation using the last applied offset, it will cause
a shake. The animation will first shift from 0, 0 offset to the last
offset and then return again to 0, 0. This CL makes it not apply the
animation in that case.

Bug: 22519478
Change-Id: I5cb750b56e9715c6d9389136071a5e0fbafb047b
parent 78c0a044
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ public class BurnInProtectionHelper implements DisplayManager.DisplayListener,
    /* 1 means increasing, -1 means decreasing */
    private int mYOffsetDirection = 1;

    private int mAppliedBurnInXOffset = 0;
    private int mAppliedBurnInYOffset = 0;

    private final AlarmManager mAlarmManager;
    private final PendingIntent mBurnInProtectionIntent;
    private final DisplayManagerInternal mDisplayManagerInternal;
@@ -139,6 +142,8 @@ public class BurnInProtectionHelper implements DisplayManager.DisplayListener,
                mFirstUpdate = false;
            } else {
                adjustOffsets();
                mAppliedBurnInXOffset = mLastBurnInXOffset;
                mAppliedBurnInYOffset = mLastBurnInYOffset;
                mDisplayManagerInternal.setDisplayOffsets(mDisplay.getDisplayId(),
                        mLastBurnInXOffset, mLastBurnInYOffset);
            }
@@ -258,6 +263,8 @@ public class BurnInProtectionHelper implements DisplayManager.DisplayListener,
    @Override
    public void onAnimationEnd(Animator animator) {
        if (animator == mCenteringAnimator && !mBurnInProtectionActive) {
            mAppliedBurnInXOffset = 0;
            mAppliedBurnInYOffset = 0;
            // No matter how the animation finishes, we want to zero the offsets.
            mDisplayManagerInternal.setDisplayOffsets(mDisplay.getDisplayId(), 0, 0);
        }
@@ -276,7 +283,7 @@ public class BurnInProtectionHelper implements DisplayManager.DisplayListener,
        if (!mBurnInProtectionActive) {
            final float value = (Float) valueAnimator.getAnimatedValue();
            mDisplayManagerInternal.setDisplayOffsets(mDisplay.getDisplayId(),
                    (int) (mLastBurnInXOffset * value), (int) (mLastBurnInYOffset * value));
                    (int) (mAppliedBurnInXOffset * value), (int) (mAppliedBurnInYOffset * value));
        }
    }
}