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

Commit 3d565fa8 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

KeyguardBouncer#isShowing fix

KeyguardBouncer.isShowing should not return
true when the view is hidden.

Change-Id: I111aab356f6fc2367816b2ac132c0c4b140864c3
Fixes: 74583436
Fixes: 76151115
Test: packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java
Test: Swipe up on lock screen
Test: Unlock with fp from AOD, keyguard or bouncer
Test: Unlock from occluded bouncer
parent 5f8939ee
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -60,10 +60,6 @@ public class KeyguardBouncer {
    private final FalsingManager mFalsingManager;
    private final FalsingManager mFalsingManager;
    private final DismissCallbackRegistry mDismissCallbackRegistry;
    private final DismissCallbackRegistry mDismissCallbackRegistry;
    private final Handler mHandler;
    private final Handler mHandler;
    protected KeyguardHostView mKeyguardView;
    protected ViewGroup mRoot;
    private boolean mShowingSoon;
    private int mBouncerPromptReason;
    private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
    private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
            new KeyguardUpdateMonitorCallback() {
            new KeyguardUpdateMonitorCallback() {
                @Override
                @Override
@@ -72,7 +68,13 @@ public class KeyguardBouncer {
                }
                }
            };
            };
    private final Runnable mRemoveViewRunnable = this::removeView;
    private final Runnable mRemoveViewRunnable = this::removeView;

    private int mStatusBarHeight;
    private int mStatusBarHeight;
    private float mExpansion;
    protected KeyguardHostView mKeyguardView;
    protected ViewGroup mRoot;
    private boolean mShowingSoon;
    private int mBouncerPromptReason;


    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
            LockPatternUtils lockPatternUtils, ViewGroup container,
            LockPatternUtils lockPatternUtils, ViewGroup container,
@@ -290,7 +292,8 @@ public class KeyguardBouncer {
    }
    }


    public boolean isShowing() {
    public boolean isShowing() {
        return mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE);
        return (mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE))
                && mExpansion == 0;
    }
    }


    public void prepare() {
    public void prepare() {
@@ -308,6 +311,7 @@ public class KeyguardBouncer {
     * @see StatusBarKeyguardViewManager#onPanelExpansionChanged
     * @see StatusBarKeyguardViewManager#onPanelExpansionChanged
     */
     */
    public void setExpansion(float fraction) {
    public void setExpansion(float fraction) {
        mExpansion = fraction;
        if (mKeyguardView != null) {
        if (mKeyguardView != null) {
            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));
+8 −1
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ public abstract class PanelBar extends FrameLayout {
    public static final String TAG = PanelBar.class.getSimpleName();
    public static final String TAG = PanelBar.class.getSimpleName();
    private static final boolean SPEW = false;
    private static final boolean SPEW = false;
    private boolean mBouncerShowing;
    private boolean mBouncerShowing;
    private boolean mExpanded;


    public static final void LOG(String fmt, Object... args) {
    public static final void LOG(String fmt, Object... args) {
        if (!DEBUG) return;
        if (!DEBUG) return;
@@ -71,10 +72,15 @@ public abstract class PanelBar extends FrameLayout {
                : IMPORTANT_FOR_ACCESSIBILITY_AUTO;
                : IMPORTANT_FOR_ACCESSIBILITY_AUTO;


        setImportantForAccessibility(important);
        setImportantForAccessibility(important);
        updateVisibility();


        if (mPanel != null) mPanel.setImportantForAccessibility(important);
        if (mPanel != null) mPanel.setImportantForAccessibility(important);
    }
    }


    private void updateVisibility() {
        mPanel.setVisibility(mExpanded || mBouncerShowing ? VISIBLE : INVISIBLE);
    }

    public boolean panelEnabled() {
    public boolean panelEnabled() {
        return true;
        return true;
    }
    }
@@ -124,7 +130,8 @@ public abstract class PanelBar extends FrameLayout {
        boolean fullyOpened = false;
        boolean fullyOpened = false;
        if (SPEW) LOG("panelExpansionChanged: start state=%d", mState);
        if (SPEW) LOG("panelExpansionChanged: start state=%d", mState);
        PanelView pv = mPanel;
        PanelView pv = mPanel;
        pv.setVisibility(expanded || mBouncerShowing ? VISIBLE : INVISIBLE);
        mExpanded = expanded;
        updateVisibility();
        // adjust any other panels that may be partially visible
        // adjust any other panels that may be partially visible
        if (expanded) {
        if (expanded) {
            if (mState == STATE_CLOSED) {
            if (mState == STATE_CLOSED) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -150,7 +150,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            mBouncer.setExpansion(expansion);
            mBouncer.setExpansion(expansion);
            if (expansion == 1) {
            if (expansion == 1) {
                mBouncer.onFullyHidden();
                mBouncer.onFullyHidden();
                updateStates();
            } else if (!mBouncer.isShowing()) {
            } else if (!mBouncer.isShowing()) {
                mBouncer.show(true /* resetSecuritySelection */, false /* notifyFalsing */);
                mBouncer.show(true /* resetSecuritySelection */, false /* notifyFalsing */);
            } else if (noLongerTracking) {
            } else if (noLongerTracking) {
@@ -159,6 +158,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                // data.
                // data.
                mBouncer.onFullyShown();
                mBouncer.onFullyShown();
            }
            }
            if (expansion == 0 || expansion == 1) {
                updateStates();
            }
        }
        }
        mLastTracking = tracking;
        mLastTracking = tracking;
    }
    }
+12 −2
Original line number Original line Diff line number Diff line
@@ -238,9 +238,19 @@ public class KeyguardBouncerTest extends SysuiTestCase {
    }
    }


    @Test
    @Test
    public void testIsShowing() {
    public void testIsShowing_animated() {
        Assert.assertFalse("Show wasn't invoked yet", mBouncer.isShowing());
        Assert.assertFalse("Show wasn't invoked yet", mBouncer.isShowing());
        mBouncer.show(true);
        mBouncer.show(true /* reset */);
        Assert.assertTrue("Should be showing", mBouncer.isShowing());
    }

    @Test
    public void testIsShowing_forSwipeUp() {
        mBouncer.setExpansion(1f);
        mBouncer.show(true /* reset */, false /* animated */);
        Assert.assertFalse("Should only be showing after collapsing notification panel",
                mBouncer.isShowing());
        mBouncer.setExpansion(0f);
        Assert.assertTrue("Should be showing", mBouncer.isShowing());
        Assert.assertTrue("Should be showing", mBouncer.isShowing());
    }
    }