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

Commit 51f3d51f authored by Aaron Liu's avatar Aaron Liu
Browse files

Make getCurrentController async friendly.

Ensure that getCurrentController does not have a return type. If the
view controller is cached, then the callback will be immediately called,
otherwise, we inflate the view on a bg thread.

Fixes: 276924513
Fixes: 277039068
Test: simpin, simpuk, pin, password, pattern views.
Test: no security method
Test: atest android.security.identity.cts.UserAuthTest
Test: unit tests
Change-Id: I85e60cfc6fd5a71eb00a44405620ac650867b481
parent 8dd16441
Loading
Loading
Loading
Loading
+39 −50
Original line number Diff line number Diff line
@@ -453,7 +453,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        showPrimarySecurityScreen(true);
        mAdminSecondaryLockScreenController.hide();
        if (mCurrentSecurityMode != SecurityMode.None) {
            getCurrentSecurityController().onPause();
            getCurrentSecurityController(controller -> controller.onPause());
        }
        mView.onPause();
        mView.clearFocus();
@@ -507,14 +507,15 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
            if (reason != PROMPT_REASON_NONE) {
                Log.i(TAG, "Strong auth required, reason: " + reason);
            }
            getCurrentSecurityController().showPromptReason(reason);
            getCurrentSecurityController(controller -> controller.showPromptReason(reason));
        }
    }

    /** Set message of bouncer title. */
    public void showMessage(CharSequence message, ColorStateList colorState, boolean animated) {
        if (mCurrentSecurityMode != SecurityMode.None) {
            getCurrentSecurityController().showMessage(message, colorState, animated);
            getCurrentSecurityController(
                    controller -> controller.showMessage(message, colorState, animated));
        }
    }

@@ -629,7 +630,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
            }
            SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED, state);

            getCurrentSecurityController().onResume(reason);

            getCurrentSecurityController(controller -> controller.onResume(reason));
        }
        mView.onResume(
                mSecurityModel.getSecurityMode(KeyguardUpdateMonitor.getCurrentUser()),
@@ -669,7 +671,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        if (mCurrentSecurityMode != SecurityMode.None) {
            setAlpha(1f);
            mView.startAppearAnimation(mCurrentSecurityMode);
            getCurrentSecurityController().startAppearAnimation();
            getCurrentSecurityController(controller -> controller.startAppearAnimation());
        }
    }

@@ -679,24 +681,23 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
    }

    public boolean startDisappearAnimation(Runnable onFinishRunnable) {
        boolean didRunAnimation = false;

        if (mCurrentSecurityMode != SecurityMode.None) {
            mView.startDisappearAnimation(mCurrentSecurityMode);
            didRunAnimation = getCurrentSecurityController().startDisappearAnimation(
            getCurrentSecurityController(
                    controller -> {
                        boolean didRunAnimation = controller.startDisappearAnimation(
                                onFinishRunnable);
        }

                        if (!didRunAnimation && onFinishRunnable != null) {
                            onFinishRunnable.run();
                        }

        return didRunAnimation;
                    });
        }
        return true;
    }

    public void onStartingToHide() {
        if (mCurrentSecurityMode != SecurityMode.None) {
            getCurrentSecurityController().onStartingToHide();
            getCurrentSecurityController(controller -> controller.onStartingToHide());
        }
    }

@@ -804,8 +805,9 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        return finish;
    }

    @Override
    public boolean needsInput() {
        return getCurrentSecurityController().needsInput();
        return false;
    }

    /**
@@ -933,22 +935,19 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
            return;
        }

        KeyguardInputViewController<KeyguardInputView> oldView = getCurrentSecurityController();
        getCurrentSecurityController(oldView -> oldView.onPause());

        // Emulate Activity life cycle
        if (oldView != null) {
            oldView.onPause();
        }
        mCurrentSecurityMode = securityMode;

        KeyguardInputViewController<KeyguardInputView> newView = changeSecurityMode(securityMode);
        if (newView != null) {
        getCurrentSecurityController(
                newView -> {
                    newView.onResume(KeyguardSecurityView.VIEW_REVEALED);
                    mSecurityViewFlipperController.show(newView);
                    configureMode();
        }

                    mKeyguardSecurityCallback.onSecurityModeChanged(
                            securityMode, newView != null && newView.needsInput());

                });
    }

    /**
@@ -1028,15 +1027,11 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        }
    }

    private KeyguardInputViewController<KeyguardInputView> getCurrentSecurityController() {
        return mSecurityViewFlipperController
                .getSecurityView(mCurrentSecurityMode, mKeyguardSecurityCallback);
    }

    private KeyguardInputViewController<KeyguardInputView> changeSecurityMode(
            SecurityMode securityMode) {
        mCurrentSecurityMode = securityMode;
        return getCurrentSecurityController();
    private void getCurrentSecurityController(
            KeyguardSecurityViewFlipperController.OnViewInflatedCallback onViewInflatedCallback) {
        mSecurityViewFlipperController
                .getSecurityView(mCurrentSecurityMode, mKeyguardSecurityCallback,
                        onViewInflatedCallback);
    }

    /**
@@ -1086,28 +1081,22 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
    }

    private void reloadColors() {
        reinflateViewFlipper(() -> mView.reloadColors());
        reinflateViewFlipper(controller -> mView.reloadColors());
    }

    /** Handles density or font scale changes. */
    private void onDensityOrFontScaleChanged() {
        reinflateViewFlipper(() -> mView.onDensityOrFontScaleChanged());
        reinflateViewFlipper(controller -> mView.onDensityOrFontScaleChanged());
    }

    /**
     * Reinflate the view flipper child view.
     */
    public void reinflateViewFlipper(
            KeyguardSecurityViewFlipperController.OnViewInflatedListener onViewInflatedListener) {
            KeyguardSecurityViewFlipperController.OnViewInflatedCallback onViewInflatedListener) {
        mSecurityViewFlipperController.clearViews();
        if (mFeatureFlags.isEnabled(Flags.ASYNC_INFLATE_BOUNCER)) {
        mSecurityViewFlipperController.asynchronouslyInflateView(mCurrentSecurityMode,
                mKeyguardSecurityCallback, onViewInflatedListener);
        } else {
            mSecurityViewFlipperController.getSecurityView(mCurrentSecurityMode,
                    mKeyguardSecurityCallback);
            onViewInflatedListener.onViewInflated();
        }
    }

    /**
+11 −64
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.keyguard.dagger.KeyguardBouncerScope;
import com.android.systemui.R;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.util.ViewController;

import java.util.ArrayList;
@@ -54,23 +53,19 @@ public class KeyguardSecurityViewFlipperController
    private final Factory mKeyguardSecurityViewControllerFactory;
    private final FeatureFlags mFeatureFlags;

    private final ViewMediatorCallback mViewMediatorCallback;

    @Inject
    protected KeyguardSecurityViewFlipperController(KeyguardSecurityViewFlipper view,
            LayoutInflater layoutInflater,
            AsyncLayoutInflater asyncLayoutInflater,
            KeyguardInputViewController.Factory keyguardSecurityViewControllerFactory,
            EmergencyButtonController.Factory emergencyButtonControllerFactory,
            FeatureFlags featureFlags,
            ViewMediatorCallback viewMediatorCallback) {
            FeatureFlags featureFlags) {
        super(view);
        mKeyguardSecurityViewControllerFactory = keyguardSecurityViewControllerFactory;
        mLayoutInflater = layoutInflater;
        mEmergencyButtonControllerFactory = emergencyButtonControllerFactory;
        mAsyncLayoutInflater = asyncLayoutInflater;
        mFeatureFlags = featureFlags;
        mViewMediatorCallback = viewMediatorCallback;
    }

    @Override
@@ -97,40 +92,17 @@ public class KeyguardSecurityViewFlipperController


    @VisibleForTesting
    KeyguardInputViewController<KeyguardInputView> getSecurityView(SecurityMode securityMode,
            KeyguardSecurityCallback keyguardSecurityCallback) {
        KeyguardInputViewController<KeyguardInputView> childController = null;
    void getSecurityView(SecurityMode securityMode,
            KeyguardSecurityCallback keyguardSecurityCallback,
            OnViewInflatedCallback onViewInflatedCallback) {
        for (KeyguardInputViewController<KeyguardInputView> child : mChildren) {
            if (child.getSecurityMode() == securityMode) {
                childController = child;
                break;
            }
        }

        if (!mFeatureFlags.isEnabled(Flags.ASYNC_INFLATE_BOUNCER) && childController == null
                && securityMode != SecurityMode.None && securityMode != SecurityMode.Invalid) {
            int layoutId = getLayoutIdFor(securityMode);
            KeyguardInputView view = null;
            if (layoutId != 0) {
                if (DEBUG) Log.v(TAG, "inflating on main thread id = " + layoutId);
                view = (KeyguardInputView) mLayoutInflater.inflate(
                        layoutId, mView, false);
                mView.addView(view);
                childController = mKeyguardSecurityViewControllerFactory.create(
                        view, securityMode, keyguardSecurityCallback);
                childController.init();

                mChildren.add(childController);
                onViewInflatedCallback.onViewInflated(child);
                return;
            }
        }

        if (childController == null) {
            childController = new NullKeyguardInputViewController(
                    securityMode, keyguardSecurityCallback,
                    mEmergencyButtonControllerFactory.create(null));
        }

        return childController;
        asynchronouslyInflateView(securityMode, keyguardSecurityCallback, onViewInflatedCallback);
    }

    /**
@@ -143,7 +115,7 @@ public class KeyguardSecurityViewFlipperController
     */
    public void asynchronouslyInflateView(SecurityMode securityMode,
            KeyguardSecurityCallback keyguardSecurityCallback,
            @Nullable OnViewInflatedListener onViewInflatedListener) {
            @Nullable OnViewInflatedCallback onViewInflatedListener) {
        int layoutId = getLayoutIdFor(securityMode);
        if (layoutId != 0) {
            if (DEBUG) Log.v(TAG, "inflating on bg thread id = " + layoutId);
@@ -156,9 +128,8 @@ public class KeyguardSecurityViewFlipperController
                                        keyguardSecurityCallback);
                        childController.init();
                        mChildren.add(childController);
                        mViewMediatorCallback.setNeedsInput(childController.needsInput());
                        if (onViewInflatedListener != null) {
                            onViewInflatedListener.onViewInflated();
                            onViewInflatedListener.onViewInflated(childController);
                        }
                    });
        }
@@ -184,33 +155,9 @@ public class KeyguardSecurityViewFlipperController
        }
    }

    private static class NullKeyguardInputViewController
            extends KeyguardInputViewController<KeyguardInputView> {
        protected NullKeyguardInputViewController(SecurityMode securityMode,
                KeyguardSecurityCallback keyguardSecurityCallback,
                EmergencyButtonController emergencyButtonController) {
            super(null, securityMode, keyguardSecurityCallback, emergencyButtonController,
                    null);
        }

        @Override
        public boolean needsInput() {
            return false;
        }

        @Override
        public void onStartingToHide() {
        }

        @Override
        protected int getInitialMessageResId() {
            return 0;
        }
    }

    /** Listener to when view has finished inflation. */
    public interface OnViewInflatedListener {
    public interface OnViewInflatedCallback {
        /** Notifies that view has been inflated */
        void onViewInflated();
        void onViewInflated(KeyguardInputViewController<KeyguardInputView> controller);
    }
}
+64 −66
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.keyguard;

import static android.view.WindowInsets.Type.ime;

import static com.android.keyguard.KeyguardSecurityContainer.MODE_DEFAULT;
import static com.android.keyguard.KeyguardSecurityContainer.MODE_ONE_HANDED;

@@ -29,9 +27,9 @@ import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -163,6 +161,10 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
    @Captor
    private ArgumentCaptor<KeyguardSecurityContainer.SwipeListener> mSwipeListenerArgumentCaptor;

    @Captor
    private ArgumentCaptor<KeyguardSecurityViewFlipperController.OnViewInflatedCallback>
            mOnViewInflatedCallbackArgumentCaptor;

    private KeyguardSecurityContainerController mKeyguardSecurityContainerController;
    private KeyguardPasswordViewController mKeyguardPasswordViewController;
    private KeyguardPasswordView mKeyguardPasswordView;
@@ -183,8 +185,6 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
        when(mAdminSecondaryLockScreenControllerFactory.create(any(KeyguardSecurityCallback.class)))
                .thenReturn(mAdminSecondaryLockScreenController);
        when(mSecurityViewFlipper.getWindowInsetsController()).thenReturn(mWindowInsetsController);
        when(mKeyguardSecurityViewFlipperController.getSecurityView(any(SecurityMode.class),
                any(KeyguardSecurityCallback.class))).thenReturn(mInputViewController);
        mKeyguardPasswordView = spy((KeyguardPasswordView) LayoutInflater.from(mContext).inflate(
                R.layout.keyguard_password_view, null));
        when(mKeyguardPasswordView.getRootView()).thenReturn(mSecurityViewFlipper);
@@ -228,28 +228,18 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
            mKeyguardSecurityContainerController.showSecurityScreen(mode);
            if (mode == SecurityMode.Invalid) {
                verify(mKeyguardSecurityViewFlipperController, never()).getSecurityView(
                        any(SecurityMode.class), any(KeyguardSecurityCallback.class));
                        any(SecurityMode.class), any(KeyguardSecurityCallback.class), any(
                                KeyguardSecurityViewFlipperController.OnViewInflatedCallback.class)
                );
            } else {
                verify(mKeyguardSecurityViewFlipperController).getSecurityView(
                        eq(mode), any(KeyguardSecurityCallback.class));
                        eq(mode), any(KeyguardSecurityCallback.class), any(
                                KeyguardSecurityViewFlipperController.OnViewInflatedCallback.class)
                );
            }
        }
    }

    @Test
    public void startDisappearAnimation_animatesKeyboard() {
        when(mKeyguardSecurityModel.getSecurityMode(anyInt())).thenReturn(
                SecurityMode.Password);
        when(mKeyguardSecurityViewFlipperController.getSecurityView(
                eq(SecurityMode.Password), any(KeyguardSecurityCallback.class)))
                .thenReturn((KeyguardInputViewController) mKeyguardPasswordViewController);
        mKeyguardSecurityContainerController.showSecurityScreen(SecurityMode.Password);

        mKeyguardSecurityContainerController.startDisappearAnimation(null);
        verify(mWindowInsetsController).controlWindowInsetsAnimation(
                eq(ime()), anyLong(), any(), any(), any());
    }

    @Test
    public void onResourcesUpdate_callsThroughOnRotationChange() {
        clearInvocations(mView);
@@ -298,9 +288,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
    @Test
    public void showSecurityScreen_oneHandedMode_flagDisabled_noOneHandedMode() {
        mTestableResources.addOverride(R.bool.can_use_one_handed_bouncer, false);
        when(mKeyguardSecurityViewFlipperController.getSecurityView(
                eq(SecurityMode.Pattern), any(KeyguardSecurityCallback.class)))
                .thenReturn((KeyguardInputViewController) mKeyguardPasswordViewController);
        setupGetSecurityView(SecurityMode.Pattern);

        mKeyguardSecurityContainerController.showSecurityScreen(SecurityMode.Pattern);
        verify(mView).initMode(eq(MODE_DEFAULT), eq(mGlobalSettings), eq(mFalsingManager),
@@ -312,11 +300,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
    @Test
    public void showSecurityScreen_oneHandedMode_flagEnabled_oneHandedMode() {
        mTestableResources.addOverride(R.bool.can_use_one_handed_bouncer, true);
        when(mKeyguardSecurityViewFlipperController.getSecurityView(
                eq(SecurityMode.Pattern), any(KeyguardSecurityCallback.class)))
                .thenReturn((KeyguardInputViewController) mKeyguardPasswordViewController);

        mKeyguardSecurityContainerController.showSecurityScreen(SecurityMode.Pattern);
        setupGetSecurityView(SecurityMode.Pattern);
        verify(mView).initMode(eq(MODE_ONE_HANDED), eq(mGlobalSettings), eq(mFalsingManager),
                eq(mUserSwitcherController),
                any(KeyguardSecurityContainer.UserSwitcherViewMode.UserSwitcherCallback.class),
@@ -326,9 +310,8 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
    @Test
    public void showSecurityScreen_twoHandedMode_flagEnabled_noOneHandedMode() {
        mTestableResources.addOverride(R.bool.can_use_one_handed_bouncer, true);
        setupGetSecurityView();
        setupGetSecurityView(SecurityMode.Password);

        mKeyguardSecurityContainerController.showSecurityScreen(SecurityMode.Password);
        verify(mView).initMode(eq(MODE_DEFAULT), eq(mGlobalSettings), eq(mFalsingManager),
                eq(mUserSwitcherController),
                any(KeyguardSecurityContainer.UserSwitcherViewMode.UserSwitcherCallback.class),
@@ -340,15 +323,14 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
        ArgumentCaptor<KeyguardSecurityContainer.UserSwitcherViewMode.UserSwitcherCallback>
                captor = ArgumentCaptor.forClass(
                KeyguardSecurityContainer.UserSwitcherViewMode.UserSwitcherCallback.class);
        setupGetSecurityView(SecurityMode.Password);

        setupGetSecurityView();

        mKeyguardSecurityContainerController.showSecurityScreen(SecurityMode.Password);
        verify(mView).initMode(anyInt(), any(GlobalSettings.class), any(FalsingManager.class),
                any(UserSwitcherController.class),
                captor.capture(),
                eq(mFalsingA11yDelegate));
        captor.getValue().showUnlockToContinueMessage();
        getViewControllerImmediately();
        verify(mKeyguardPasswordViewControllerMock).showMessage(
                /* message= */ getContext().getString(R.string.keyguard_unlock_to_continue),
                /* colorState= */ null,
@@ -455,7 +437,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
        KeyguardSecurityContainer.SwipeListener registeredSwipeListener =
                getRegisteredSwipeListener();
        when(mKeyguardUpdateMonitor.isFaceDetectionRunning()).thenReturn(false);
        setupGetSecurityView();
        setupGetSecurityView(SecurityMode.Password);

        registeredSwipeListener.onSwipeUp();

@@ -481,9 +463,11 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
                getRegisteredSwipeListener();
        when(mKeyguardUpdateMonitor.requestFaceAuth(FaceAuthApiRequestReason.SWIPE_UP_ON_BOUNCER))
                .thenReturn(true);
        setupGetSecurityView();
        setupGetSecurityView(SecurityMode.Password);

        clearInvocations(mKeyguardSecurityViewFlipperController);
        registeredSwipeListener.onSwipeUp();
        getViewControllerImmediately();

        verify(mKeyguardPasswordViewControllerMock).showMessage(/* message= */
                null, /* colorState= */ null, /* animated= */ true);
@@ -495,7 +479,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
                getRegisteredSwipeListener();
        when(mKeyguardUpdateMonitor.requestFaceAuth(FaceAuthApiRequestReason.SWIPE_UP_ON_BOUNCER))
                .thenReturn(false);
        setupGetSecurityView();
        setupGetSecurityView(SecurityMode.Password);

        registeredSwipeListener.onSwipeUp();

@@ -514,10 +498,15 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {

        configurationListenerArgumentCaptor.getValue().onDensityOrFontScaleChanged();

        verify(mView).onDensityOrFontScaleChanged();
        verify(mKeyguardSecurityViewFlipperController).clearViews();
        verify(mKeyguardSecurityViewFlipperController).getSecurityView(eq(SecurityMode.PIN),
                any(KeyguardSecurityCallback.class));
        verify(mKeyguardSecurityViewFlipperController).asynchronouslyInflateView(
                eq(SecurityMode.PIN),
                any(KeyguardSecurityCallback.class),
                mOnViewInflatedCallbackArgumentCaptor.capture());

        mOnViewInflatedCallbackArgumentCaptor.getValue().onViewInflated(mInputViewController);

        verify(mView).onDensityOrFontScaleChanged();
    }

    @Test
@@ -531,12 +520,17 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {

        configurationListenerArgumentCaptor.getValue().onThemeChanged();

        verify(mView).reloadColors();
        verify(mKeyguardSecurityViewFlipperController).clearViews();
        verify(mKeyguardSecurityViewFlipperController).getSecurityView(eq(SecurityMode.PIN),
                any(KeyguardSecurityCallback.class));
        verify(mKeyguardSecurityViewFlipperController).asynchronouslyInflateView(
                eq(SecurityMode.PIN),
                any(KeyguardSecurityCallback.class),
                mOnViewInflatedCallbackArgumentCaptor.capture());

        mOnViewInflatedCallbackArgumentCaptor.getValue().onViewInflated(mInputViewController);

        verify(mView).reset();
        verify(mKeyguardSecurityViewFlipperController).reset();
        verify(mView).reloadColors();
    }

    @Test
@@ -550,10 +544,15 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {

        configurationListenerArgumentCaptor.getValue().onUiModeChanged();

        verify(mView).reloadColors();
        verify(mKeyguardSecurityViewFlipperController).clearViews();
        verify(mKeyguardSecurityViewFlipperController).getSecurityView(eq(SecurityMode.PIN),
                any(KeyguardSecurityCallback.class));
        verify(mKeyguardSecurityViewFlipperController).asynchronouslyInflateView(
                eq(SecurityMode.PIN),
                any(KeyguardSecurityCallback.class),
                mOnViewInflatedCallbackArgumentCaptor.capture());

        mOnViewInflatedCallbackArgumentCaptor.getValue().onViewInflated(mInputViewController);

        verify(mView).reloadColors();
    }

    @Test
@@ -616,6 +615,11 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
    @Test
    public void testOnStartingToHide() {
        mKeyguardSecurityContainerController.onStartingToHide();
        verify(mKeyguardSecurityViewFlipperController).getSecurityView(any(SecurityMode.class),
                any(KeyguardSecurityCallback.class),
                mOnViewInflatedCallbackArgumentCaptor.capture());

        mOnViewInflatedCallbackArgumentCaptor.getValue().onViewInflated(mInputViewController);
        verify(mInputViewController).onStartingToHide();
    }

@@ -675,26 +679,17 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
        verify(mView).updatePositionByTouchX(1.0f);
    }


    @Test
    public void testReinflateViewFlipper() {
        mKeyguardSecurityContainerController.reinflateViewFlipper(() -> {});
        verify(mKeyguardSecurityViewFlipperController).clearViews();
        verify(mKeyguardSecurityViewFlipperController).getSecurityView(any(SecurityMode.class),
                any(KeyguardSecurityCallback.class));
    }

    @Test
    public void testReinflateViewFlipper_asyncBouncerFlagOn() {
        when(mFeatureFlags.isEnabled(Flags.ASYNC_INFLATE_BOUNCER)).thenReturn(true);
        KeyguardSecurityViewFlipperController.OnViewInflatedListener onViewInflatedListener =
                () -> {
        KeyguardSecurityViewFlipperController.OnViewInflatedCallback onViewInflatedCallback =
                controller -> {
                };
        mKeyguardSecurityContainerController.reinflateViewFlipper(onViewInflatedListener);
        mKeyguardSecurityContainerController.reinflateViewFlipper(onViewInflatedCallback);
        verify(mKeyguardSecurityViewFlipperController).clearViews();
        verify(mKeyguardSecurityViewFlipperController).asynchronouslyInflateView(
                any(SecurityMode.class),
                any(KeyguardSecurityCallback.class), eq(onViewInflatedListener));
                any(KeyguardSecurityCallback.class), eq(onViewInflatedCallback));
    }

    @Test
@@ -717,14 +712,17 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
        return mSwipeListenerArgumentCaptor.getValue();
    }

    private void attachView() {
        mKeyguardSecurityContainerController.onViewAttached();
        verify(mKeyguardUpdateMonitor).registerCallback(mKeyguardUpdateMonitorCallback.capture());
    private void setupGetSecurityView(SecurityMode securityMode) {
        mKeyguardSecurityContainerController.showSecurityScreen(securityMode);
        getViewControllerImmediately();
    }

    private void setupGetSecurityView() {
        when(mKeyguardSecurityViewFlipperController.getSecurityView(
                any(), any(KeyguardSecurityCallback.class)))
                .thenReturn((KeyguardInputViewController) mKeyguardPasswordViewControllerMock);
    private void getViewControllerImmediately() {
        verify(mKeyguardSecurityViewFlipperController, atLeastOnce()).getSecurityView(
                any(SecurityMode.class), any(),
                mOnViewInflatedCallbackArgumentCaptor.capture());
        mOnViewInflatedCallbackArgumentCaptor.getValue().onViewInflated(
                (KeyguardInputViewController) mKeyguardPasswordViewControllerMock);

    }
}
+20 −11

File changed.

Preview size limit exceeded, changes collapsed.