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

Commit 231aca52 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Fix FingerprintManager NPE

Test: atest CentralSurfacesImpl
Fixes: 298355063
Change-Id: I45e3b0ebb857c228159aebd8f06f850e40aedfcf
parent b06a5995
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2678,6 +2678,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
@@ -398,7 +398,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);
@@ -437,6 +436,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,
@@ -1082,6 +1086,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.