From cf7db5579b764d4b44212fcd00b1d6c82993fbeb 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 --- .../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 6649f3a5bdfdc..5b8ceb91ddc30 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -194,6 +194,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb protected CentralSurfaces mCentralSurfaces; private NotificationPanelViewController mNotificationPanelViewController; private BiometricUnlockController mBiometricUnlockController; + private boolean mCentralSurfacesRegistered; private View mNotificationContainer; @@ -312,6 +313,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mNotificationContainer = notificationContainer; mKeyguardMessageAreaController = mKeyguardMessageAreaFactory.create( centralSurfaces.getKeyguardMessageArea()); + mCentralSurfacesRegistered = true; registerListeners(); } @@ -1007,6 +1009,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb }; protected void updateStates() { + if (!mCentralSurfacesRegistered) { + return; + } boolean showing = mShowing; boolean occluded = mOccluded; boolean bouncerShowing = mBouncer.isShowing();