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

Commit 28dc9d7d authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Do not show bouncer when fading away

Change-Id: I2d09a84ec7cda04dab3095f16f3c6e3acd425c76
Fixes: 76035580
Test: atest packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java
Test: double tap on notification, dismiss bouncer
Test: swipe up, dismiss bouncer
Test: go to emergency dialer, hit back
Test: fp from lock screen
Test: fp from AOD
parent 3d565fa8
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -75,6 +75,7 @@ public class KeyguardBouncer {
    protected ViewGroup mRoot;
    protected ViewGroup mRoot;
    private boolean mShowingSoon;
    private boolean mShowingSoon;
    private int mBouncerPromptReason;
    private int mBouncerPromptReason;
    private boolean mIsAnimatingAway;


    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
            LockPatternUtils lockPatternUtils, ViewGroup container,
            LockPatternUtils lockPatternUtils, ViewGroup container,
@@ -254,6 +255,7 @@ public class KeyguardBouncer {
            mKeyguardView.cancelDismissAction();
            mKeyguardView.cancelDismissAction();
            mKeyguardView.cleanUp();
            mKeyguardView.cleanUp();
        }
        }
        mIsAnimatingAway = false;
        if (mRoot != null) {
        if (mRoot != null) {
            mRoot.setVisibility(View.INVISIBLE);
            mRoot.setVisibility(View.INVISIBLE);
            if (destroyView) {
            if (destroyView) {
@@ -269,6 +271,7 @@ public class KeyguardBouncer {
     * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}.
     * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}.
     */
     */
    public void startPreHideAnimation(Runnable runnable) {
    public void startPreHideAnimation(Runnable runnable) {
        mIsAnimatingAway = true;
        if (mKeyguardView != null) {
        if (mKeyguardView != null) {
            mKeyguardView.startDisappearAnimation(runnable);
            mKeyguardView.startDisappearAnimation(runnable);
        } else if (runnable != null) {
        } else if (runnable != null) {
@@ -296,6 +299,14 @@ public class KeyguardBouncer {
                && mExpansion == 0;
                && mExpansion == 0;
    }
    }


    /**
     * @return {@code true} when bouncer's pre-hide animation already started but isn't completely
     *         hidden yet, {@code false} otherwise.
     */
    public boolean isAnimatingAway() {
        return mIsAnimatingAway;
    }

    public void prepare() {
    public void prepare() {
        boolean wasInitialized = mRoot != null;
        boolean wasInitialized = mRoot != null;
        ensureView();
        ensureView();
@@ -312,7 +323,7 @@ public class KeyguardBouncer {
     */
     */
    public void setExpansion(float fraction) {
    public void setExpansion(float fraction) {
        mExpansion = fraction;
        mExpansion = fraction;
        if (mKeyguardView != null) {
        if (mKeyguardView != null && !mIsAnimatingAway) {
            float alpha = MathUtils.map(ALPHA_EXPANSION_THRESHOLD, 1, 1, 0, fraction);
            float alpha = MathUtils.map(ALPHA_EXPANSION_THRESHOLD, 1, 1, 0, fraction);
            mKeyguardView.setAlpha(MathUtils.constrain(alpha, 0f, 1f));
            mKeyguardView.setAlpha(MathUtils.constrain(alpha, 0f, 1f));
            mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight());
            mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight());
+1 −1
Original line number Original line Diff line number Diff line
@@ -150,7 +150,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            mBouncer.setExpansion(expansion);
            mBouncer.setExpansion(expansion);
            if (expansion == 1) {
            if (expansion == 1) {
                mBouncer.onFullyHidden();
                mBouncer.onFullyHidden();
            } else if (!mBouncer.isShowing()) {
            } else if (!mBouncer.isShowing() && !mBouncer.isAnimatingAway()) {
                mBouncer.show(true /* resetSecuritySelection */, false /* notifyFalsing */);
                mBouncer.show(true /* resetSecuritySelection */, false /* notifyFalsing */);
            } else if (noLongerTracking) {
            } else if (noLongerTracking) {
                // Notify that falsing manager should stop its session when user stops touching,
                // Notify that falsing manager should stop its session when user stops touching,
+19 −2
Original line number Original line Diff line number Diff line
@@ -22,8 +22,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.calls;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.spy;
@@ -278,6 +276,25 @@ public class KeyguardBouncerTest extends SysuiTestCase {
        verify(mKeyguardHostView, never()).getSecurityMode();
        verify(mKeyguardHostView, never()).getSecurityMode();
    }
    }


    @Test
    public void testIsHiding_preHideOrHide() {
        Assert.assertFalse("Should not be hiding on initial state", mBouncer.isAnimatingAway());
        mBouncer.startPreHideAnimation(null /* runnable */);
        Assert.assertTrue("Should be hiding during pre-hide", mBouncer.isAnimatingAway());
        mBouncer.hide(false /* destroyView */);
        Assert.assertFalse("Should be hidden after hide()", mBouncer.isAnimatingAway());
    }

    @Test
    public void testIsHiding_skipsTranslation() {
        mBouncer.show(false /* reset */);
        reset(mKeyguardHostView);
        mBouncer.startPreHideAnimation(null /* runnable */);
        mBouncer.setExpansion(0.5f);
        verify(mKeyguardHostView, never()).setTranslationY(anyFloat());
        verify(mKeyguardHostView, never()).setAlpha(anyFloat());
    }

    @Test
    @Test
    public void testIsSecure() {
    public void testIsSecure() {
        Assert.assertTrue("Bouncer is secure before inflating views", mBouncer.isSecure());
        Assert.assertTrue("Bouncer is secure before inflating views", mBouncer.isSecure());