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

Commit d970da4c authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Always go through StatusBarKeyguardViewManager for altBouncer updates"...

Merge "Always go through StatusBarKeyguardViewManager for altBouncer updates" into udc-dev am: d0f9c7c0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22789959



Change-Id: Ie15e075c289db9ae7a21319faa73974c36c2b018
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents fac977cf d0f9c7c0
Loading
Loading
Loading
Loading
+10 −14
Original line number Original line Diff line number Diff line
@@ -41,17 +41,6 @@ constructor(
    var receivedDownTouch = false
    var receivedDownTouch = false
    val isVisible: Flow<Boolean> = bouncerRepository.alternateBouncerVisible
    val isVisible: Flow<Boolean> = bouncerRepository.alternateBouncerVisible


    private val keyguardStateControllerCallback: KeyguardStateController.Callback =
        object : KeyguardStateController.Callback {
            override fun onUnlockedChanged() {
                maybeHide()
            }
        }

    init {
        keyguardStateController.addCallback(keyguardStateControllerCallback)
    }

    /**
    /**
     * Sets the correct bouncer states to show the alternate bouncer if it can show.
     * Sets the correct bouncer states to show the alternate bouncer if it can show.
     *
     *
@@ -102,11 +91,18 @@ constructor(
        return (systemClock.uptimeMillis() - bouncerRepository.lastAlternateBouncerVisibleTime) >
        return (systemClock.uptimeMillis() - bouncerRepository.lastAlternateBouncerVisibleTime) >
            MIN_VISIBILITY_DURATION_UNTIL_TOUCHES_DISMISS_ALTERNATE_BOUNCER_MS
            MIN_VISIBILITY_DURATION_UNTIL_TOUCHES_DISMISS_ALTERNATE_BOUNCER_MS
    }
    }

    /**
    private fun maybeHide() {
     * Should only be called through StatusBarKeyguardViewManager which propagates the source of
     * truth to other concerned controllers. Will hide the alternate bouncer if it's no longer
     * allowed to show.
     *
     * @return true if the alternate bouncer was newly hidden, else false.
     */
    fun maybeHide(): Boolean {
        if (isVisibleState() && !canShowAlternateBouncerForFingerprint()) {
        if (isVisibleState() && !canShowAlternateBouncerForFingerprint()) {
            hide()
            return hide()
        }
        }
        return false
    }
    }


    companion object {
    companion object {
+10 −1
Original line number Original line Diff line number Diff line
@@ -136,7 +136,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    private final DreamOverlayStateController mDreamOverlayStateController;
    private final DreamOverlayStateController mDreamOverlayStateController;
    @Nullable
    @Nullable
    private final FoldAodAnimationController mFoldAodAnimationController;
    private final FoldAodAnimationController mFoldAodAnimationController;
    private KeyguardMessageAreaController<AuthKeyguardMessageArea> mKeyguardMessageAreaController;
    KeyguardMessageAreaController<AuthKeyguardMessageArea> mKeyguardMessageAreaController;
    private final PrimaryBouncerCallbackInteractor mPrimaryBouncerCallbackInteractor;
    private final PrimaryBouncerCallbackInteractor mPrimaryBouncerCallbackInteractor;
    private final PrimaryBouncerInteractor mPrimaryBouncerInteractor;
    private final PrimaryBouncerInteractor mPrimaryBouncerInteractor;
    private final AlternateBouncerInteractor mAlternateBouncerInteractor;
    private final AlternateBouncerInteractor mAlternateBouncerInteractor;
@@ -430,6 +430,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            mDockManager.addListener(mDockEventListener);
            mDockManager.addListener(mDockEventListener);
            mIsDocked = mDockManager.isDocked();
            mIsDocked = mDockManager.isDocked();
        }
        }
        mKeyguardStateController.addCallback(mKeyguardStateControllerCallback);
    }
    }


    /** Register a callback, to be invoked by the Predictive Back system. */
    /** Register a callback, to be invoked by the Predictive Back system. */
@@ -1564,6 +1565,14 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                || mode == KeyguardSecurityModel.SecurityMode.SimPuk;
                || mode == KeyguardSecurityModel.SecurityMode.SimPuk;
    }
    }


    private KeyguardStateController.Callback mKeyguardStateControllerCallback =
            new KeyguardStateController.Callback() {
        @Override
        public void onUnlockedChanged() {
            updateAlternateBouncerShowing(mAlternateBouncerInteractor.maybeHide());
        }
    };

    /**
    /**
     * Delegate used to send show and hide events to an alternate authentication method instead of
     * Delegate used to send show and hide events to an alternate authentication method instead of
     * the regular pin/pattern/password bouncer.
     * the regular pin/pattern/password bouncer.
+26 −1
Original line number Original line Diff line number Diff line
@@ -84,6 +84,7 @@ import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.unfold.SysUIUnfoldComponent;
import com.android.systemui.unfold.SysUIUnfoldComponent;


import com.google.common.truth.Truth;
import com.google.common.truth.Truth;
@@ -151,13 +152,15 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
    private WindowOnBackInvokedDispatcher mOnBackInvokedDispatcher;
    private WindowOnBackInvokedDispatcher mOnBackInvokedDispatcher;
    @Captor
    @Captor
    private ArgumentCaptor<OnBackInvokedCallback> mBackCallbackCaptor;
    private ArgumentCaptor<OnBackInvokedCallback> mBackCallbackCaptor;
    @Captor
    private ArgumentCaptor<KeyguardStateController.Callback> mKeyguardStateControllerCallback;




    @Before
    @Before
    public void setUp() {
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
        when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea);
        when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea);
        when(mKeyguardMessageAreaFactory.create(any(KeyguardMessageArea.class)))
        when(mKeyguardMessageAreaFactory.create(any()))
                .thenReturn(mKeyguardMessageAreaController);
                .thenReturn(mKeyguardMessageAreaController);
        when(mBouncerView.getDelegate()).thenReturn(mBouncerViewDelegate);
        when(mBouncerView.getDelegate()).thenReturn(mBouncerViewDelegate);
        when(mBouncerViewDelegate.getBackCallback()).thenReturn(mBouncerViewDelegateBackCallback);
        when(mBouncerViewDelegate.getBackCallback()).thenReturn(mBouncerViewDelegateBackCallback);
@@ -909,4 +912,26 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
        // THEN the alternateBouncer doesn't hide
        // THEN the alternateBouncer doesn't hide
        verify(mAlternateBouncerInteractor, never()).hide();
        verify(mAlternateBouncerInteractor, never()).hide();
    }
    }

    @Test
    public void onDeviceUnlocked_hideAlternateBouncerAndClearMessageArea() {
        reset(mKeyguardUpdateMonitor);
        reset(mKeyguardMessageAreaController);

        // GIVEN keyguard state controller callback is registered
        verify(mKeyguardStateController).addCallback(mKeyguardStateControllerCallback.capture());

        // GIVEN alternate bouncer state = not visible
        when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(false);

        // WHEN the device is unlocked
        mKeyguardStateControllerCallback.getValue().onUnlockedChanged();

        // THEN the false visibility state is propagated to the keyguardUpdateMonitor
        verify(mKeyguardUpdateMonitor).setAlternateBouncerShowing(eq(false));

        // THEN message area visibility updated to FALSE with empty message
        verify(mKeyguardMessageAreaController).setIsVisible(eq(false));
        verify(mKeyguardMessageAreaController).setMessage(eq(""));
    }
}
}