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

Commit d0f5b298 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Fix FingerprintManager NPE" into main

parents b90e7f68 231aca52
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2680,6 +2680,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
                                    && mStatusBarStateController.getDozeAmount() == 1f
                                    && mWakefulnessLifecycle.getLastWakeReason()
                                    == PowerManager.WAKE_REASON_POWER_BUTTON
                                    && mFingerprintManager.get() != null
                                    && mFingerprintManager.get().isPowerbuttonFps()
                                    && mKeyguardUpdateMonitor
                                    .getCachedIsUnlockWithFingerprintPossible(
+26 −1
Original line number Diff line number Diff line
@@ -399,7 +399,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase {

        when(mGradientColors.supportsDarkText()).thenReturn(true);
        when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors);
        ConfigurationController configurationController = new ConfigurationControllerImpl(mContext);

        when(mLockscreenWallpaperLazy.get()).thenReturn(mLockscreenWallpaper);
        when(mBiometricUnlockControllerLazy.get()).thenReturn(mBiometricUnlockController);
@@ -438,6 +437,11 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
        when(mUserTracker.getUserHandle()).thenReturn(
                UserHandle.of(ActivityManager.getCurrentUser()));

        createCentralSurfaces();
    }

    private void createCentralSurfaces() {
        ConfigurationController configurationController = new ConfigurationControllerImpl(mContext);
        mCentralSurfaces = new CentralSurfacesImpl(
                mContext,
                mNotificationsController,
@@ -1083,6 +1087,27 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
        verify(mNotificationPanelViewController).setTouchAndAnimationDisabled(true);
    }

    /** Regression test for b/298355063 */
    @Test
    public void fingerprintManagerNull_noNPE() {
        // GIVEN null fingerprint manager
        mFingerprintManager = null;
        createCentralSurfaces();

        // GIVEN should animate doze wakeup
        when(mDozeServiceHost.shouldAnimateWakeup()).thenReturn(true);
        when(mBiometricUnlockController.getMode()).thenReturn(
                BiometricUnlockController.MODE_ONLY_WAKE);
        when(mDozeServiceHost.isPulsing()).thenReturn(false);
        when(mStatusBarStateController.getDozeAmount()).thenReturn(1f);

        // WHEN waking up from the power button
        mWakefulnessLifecycle.dispatchStartedWakingUp(PowerManager.WAKE_REASON_POWER_BUTTON);
        mCentralSurfaces.mWakefulnessObserver.onStartedWakingUp();

        // THEN no NPE when fingerprintManager is null
    }

    /**
     * Configures the appropriate mocks and then calls {@link CentralSurfacesImpl#updateIsKeyguard}
     * to reconfigure the keyguard to reflect the requested showing/occluded states.