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

Commit 38e75ff4 authored by Lucas Dupin's avatar Lucas Dupin Committed by android-build-merger
Browse files

Merge "Make sure BiometricType is never null" into qt-dev

am: 81ee1fb3

Change-Id: I56c69017ce9b8f39f22743cfc2343b8a2118a051
parents d35a17e6 81ee1fb3
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -367,16 +367,11 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
    @Override
    public void onFinishedGoingToSleep(int why) {
        Trace.beginSection("BiometricUnlockController#onFinishedGoingToSleep");
        if (mPendingAuthenticatedUserId != -1) {

        BiometricSourceType pendingType = mPendingAuthenticatedBioSourceType;
        int pendingUserId = mPendingAuthenticatedUserId;
        if (pendingUserId != -1 && pendingType != null) {
            // Post this to make sure it's executed after the device is fully locked.
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    onBiometricAuthenticated(mPendingAuthenticatedUserId,
                            mPendingAuthenticatedBioSourceType);
                }
            });
            mHandler.post(() -> onBiometricAuthenticated(pendingUserId, pendingType));
        }
        mPendingAuthenticatedUserId = -1;
        mPendingAuthenticatedBioSourceType = null;
+16 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.phone;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.eq;
@@ -71,6 +72,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
    private UnlockMethodCache mUnlockMethodCache;
    @Mock
    private TunerService mTunerService;
    @Mock
    private Handler mHandler;
    private BiometricUnlockController mBiometricUnlockController;

    @Before
@@ -172,12 +175,24 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        verify(mStatusBarKeyguardViewManager, never()).animateCollapsePanels(anyFloat());
    }

    @Test
    public void onFinishedGoingToSleep_authenticatesWhenPending() {
        when(mUpdateMonitor.isGoingToSleep()).thenReturn(true);
        mBiometricUnlockController.onFinishedGoingToSleep(-1);
        verify(mHandler, never()).post(any());

        mBiometricUnlockController.onBiometricAuthenticated(1 /* userId */,
                BiometricSourceType.FACE);
        mBiometricUnlockController.onFinishedGoingToSleep(-1);
        verify(mHandler).post(any());
    }

    private class TestableBiometricUnlockController extends BiometricUnlockController {

        TestableBiometricUnlockController(boolean faceDismissesKeyguard) {
            super(mContext, mDozeScrimController,
                    mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
                    new Handler(), mUpdateMonitor, mTunerService, 0 /* wakeUpDelay */,
                    mHandler, mUpdateMonitor, mTunerService, 0 /* wakeUpDelay */,
                    faceDismissesKeyguard);
            mFaceDismissesKeyguard = faceDismissesKeyguard;
        }