Merge "Fix FingerprintManager NPE" into main
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 b797c63..b45a688 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -2680,6 +2680,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 137566b..bd3fb9f 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
@@ -399,7 +399,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);
@@ -438,6 +437,11 @@
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 @@
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.