Fix FingerprintManager NPE
Test: atest CentralSurfacesImpl
Fixes: 298355063
Change-Id: I45e3b0ebb857c228159aebd8f06f850e40aedfcf
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index 0277a36..acfae27 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -2678,6 +2678,7 @@
&& mStatusBarStateController.getDozeAmount() == 1f
&& mWakefulnessLifecycle.getLastWakeReason()
== PowerManager.WAKE_REASON_POWER_BUTTON
+ && mFingerprintManager.get() != null
&& mFingerprintManager.get().isPowerbuttonFps()
&& mKeyguardUpdateMonitor
.getCachedIsUnlockWithFingerprintPossible(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
index 4e3690f..c19159a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
@@ -398,7 +398,6 @@
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 @@
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 @@
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.