From 0e59150349d9611dc663cb0ca98e5d56c0924e41 Mon Sep 17 00:00:00 2001 From: Alex Stetson Date: Tue, 27 Sep 2022 10:55:53 -0700 Subject: [PATCH] Prevent null references when updating state Certain external calls (such as GlobalActionsComponent) will make calls to updateState which may happen without central surfaces being registered to this component. This can be prevented by checking for registration prior to update. This is more of a short term patch. In the long term, the StatusBarKeyguardViewManager is planned to be refactored/removed so additional effort or refactoring now seems unessesary. Bug: 249086825 Test: manual Change-Id: Ica4043470e13a239f0792a10e807dd1a899f5f85 (cherry picked from commit cf7db5579b764d4b44212fcd00b1d6c82993fbeb) --- .../statusbar/phone/StatusBarKeyguardViewManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index b9312c7fc40a3..ebc79ecde134b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -225,6 +225,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb protected CentralSurfaces mCentralSurfaces; private NotificationPanelViewController mNotificationPanelViewController; private BiometricUnlockController mBiometricUnlockController; + private boolean mCentralSurfacesRegistered; private View mNotificationContainer; @@ -356,6 +357,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mNotificationContainer = notificationContainer; mKeyguardMessageAreaController = mKeyguardMessageAreaFactory.create( centralSurfaces.getKeyguardMessageArea()); + mCentralSurfacesRegistered = true; registerListeners(); } @@ -1175,6 +1177,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb }; protected void updateStates() { + if (!mCentralSurfacesRegistered) { + return; + } boolean showing = mKeyguardStateController.isShowing(); boolean occluded = mKeyguardStateController.isOccluded(); boolean bouncerShowing = bouncerIsShowing();