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

Commit 50b6ecd9 authored by Beverly's avatar Beverly
Browse files

Fix NPE before CentralSurfaces is registered

Test: atest StatusBarKeyguardViewManagerTest
Fixes: 259351782
Change-Id: Id397230fbd2b67ef8516e17254e13b5c79284e24
parent f8003e57
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -218,7 +218,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb

    protected LockPatternUtils mLockPatternUtils;
    protected ViewMediatorCallback mViewMediatorCallback;
    protected CentralSurfaces mCentralSurfaces;
    @Nullable protected CentralSurfaces mCentralSurfaces;
    private NotificationPanelViewController mNotificationPanelViewController;
    private BiometricUnlockController mBiometricUnlockController;
    private boolean mCentralSurfacesRegistered;
@@ -266,7 +266,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    private final KeyguardUpdateMonitor mKeyguardUpdateManager;
    private final LatencyTracker mLatencyTracker;
    private final KeyguardSecurityModel mKeyguardSecurityModel;
    private KeyguardBypassController mBypassController;
    @Nullable private KeyguardBypassController mBypassController;
    @Nullable private AlternateBouncer mAlternateBouncer;

    private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
@@ -742,6 +742,12 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    }

    private void updateAlternateBouncerShowing(boolean updateScrim) {
        if (!mCentralSurfacesRegistered) {
            // if CentralSurfaces hasn't been registered yet, then the controllers below haven't
            // been initialized yet so there's no need to attempt to forward them events.
            return;
        }

        final boolean isShowingAlternateBouncer = isShowingAlternateBouncer();
        if (mKeyguardMessageAreaController != null) {
            mKeyguardMessageAreaController.setIsVisible(isShowingAlternateBouncer);
+36 −0
Original line number Diff line number Diff line
@@ -570,4 +570,40 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
        mStatusBarKeyguardViewManager.hideBouncer(false);
        verify(mPrimaryBouncerInteractor, never()).hide();
    }

    @Test
    public void hideAlternateBouncer_beforeCentralSurfacesRegistered() {
        mStatusBarKeyguardViewManager =
                new StatusBarKeyguardViewManager(
                        getContext(),
                        mViewMediatorCallback,
                        mLockPatternUtils,
                        mStatusBarStateController,
                        mock(ConfigurationController.class),
                        mKeyguardUpdateMonitor,
                        mDreamOverlayStateController,
                        mock(NavigationModeController.class),
                        mock(DockManager.class),
                        mock(NotificationShadeWindowController.class),
                        mKeyguardStateController,
                        mock(NotificationMediaManager.class),
                        mKeyguardBouncerFactory,
                        mKeyguardMessageAreaFactory,
                        Optional.of(mSysUiUnfoldComponent),
                        () -> mShadeController,
                        mLatencyTracker,
                        mKeyguardSecurityModel,
                        mFeatureFlags,
                        mPrimaryBouncerCallbackInteractor,
                        mPrimaryBouncerInteractor,
                        mBouncerView) {
                    @Override
                    public ViewRootImpl getViewRootImpl() {
                        return mViewRootImpl;
                    }
                };

        // the following call before registering centralSurfaces should NOT throw a NPE:
        mStatusBarKeyguardViewManager.hideAlternateBouncer(true);
    }
}