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

Commit 63490e16 authored by Justin Weir's avatar Justin Weir
Browse files

Replace setNotificationShadeWindowViewController with Dagger

The setter allows for the possibility of NPEs in very rare cases,
but using dependency injection does not.

Fixes: 361715280
Test: manually verified phone still boots and shade works
Test: updated affected tests
Flag: EXEMPT bug fix
Change-Id: I5821e1926b2059046046d04af637c20695408529
parent dcc2db21
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -245,10 +245,6 @@ public interface ShadeController extends CoreStartable {
    /** */
    default void setNotificationPresenter(NotificationPresenter presenter) {}

    /** */
    default void setNotificationShadeWindowViewController(
            NotificationShadeWindowViewController notificationShadeWindowViewController) {}

    /** Listens for shade visibility changes. */
    interface ShadeVisibilityListener {
        /** Called when shade expanded and visible state changed. */
+6 −10
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ public final class ShadeControllerImpl extends BaseShadeControllerImpl {
    private final StatusBarWindowController mStatusBarWindowController;
    private final DeviceProvisionedController mDeviceProvisionedController;

    private final Lazy<NotificationShadeWindowViewController> mNotifShadeWindowViewController;
    private final Lazy<NotificationPanelViewController> mNpvc;
    private final Lazy<AssistManager> mAssistManagerLazy;
    private final Lazy<NotificationGutsManager> mGutsManager;
@@ -72,7 +73,6 @@ public final class ShadeControllerImpl extends BaseShadeControllerImpl {
    private boolean mExpandedVisible;
    private boolean mLockscreenOrShadeVisible;

    private NotificationShadeWindowViewController mNotificationShadeWindowViewController;
    private ShadeVisibilityListener mShadeVisibilityListener;

    @Inject
@@ -87,6 +87,7 @@ public final class ShadeControllerImpl extends BaseShadeControllerImpl {
            DeviceProvisionedController deviceProvisionedController,
            NotificationShadeWindowController notificationShadeWindowController,
            @DisplayId int displayId,
            Lazy<NotificationShadeWindowViewController> notificationShadeWindowViewController,
            Lazy<NotificationPanelViewController> shadeViewControllerLazy,
            Lazy<AssistManager> assistManagerLazy,
            Lazy<NotificationGutsManager> gutsManager
@@ -105,6 +106,7 @@ public final class ShadeControllerImpl extends BaseShadeControllerImpl {
        mDeviceProvisionedController = deviceProvisionedController;
        mGutsManager = gutsManager;
        mNotificationShadeWindowController = notificationShadeWindowController;
        mNotifShadeWindowViewController = notificationShadeWindowViewController;
        mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
        mDisplayId = displayId;
        mKeyguardStateController = keyguardStateController;
@@ -139,7 +141,7 @@ public final class ShadeControllerImpl extends BaseShadeControllerImpl {
            // release focus immediately to kick off focus change transition
            mNotificationShadeWindowController.setNotificationShadeFocusable(false);

            mNotificationShadeWindowViewController.cancelExpandHelper();
            mNotifShadeWindowViewController.get().cancelExpandHelper();
            getNpvc().collapse(true, delayed, speedUpFactor);
        }
    }
@@ -242,7 +244,7 @@ public final class ShadeControllerImpl extends BaseShadeControllerImpl {
    @Override
    public void cancelExpansionAndCollapseShade() {
        if (getNpvc().isTracking()) {
            mNotificationShadeWindowViewController.cancelCurrentTouch();
            mNotifShadeWindowViewController.get().cancelCurrentTouch();
        }
        if (getNpvc().isPanelExpanded()
                && mStatusBarStateController.getState() == StatusBarState.SHADE) {
@@ -367,14 +369,8 @@ public final class ShadeControllerImpl extends BaseShadeControllerImpl {
        mShadeVisibilityListener.expandedVisibleChanged(expandedVisible);
    }

    @Override
    public void setNotificationShadeWindowViewController(
            NotificationShadeWindowViewController controller) {
        mNotificationShadeWindowViewController = controller;
    }

    private NotificationShadeWindowView getNotificationShadeWindowView() {
        return mNotificationShadeWindowViewController.getView();
        return mNotifShadeWindowViewController.get().getView();
    }

    private NotificationPanelViewController getNpvc() {
+0 −2
Original line number Diff line number Diff line
@@ -1511,8 +1511,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
        mNotificationShadeWindowController.fetchWindowRootView();
        getNotificationShadeWindowViewController().setupExpandedStatusBar();
        getNotificationShadeWindowViewController().setupCommunalHubLayout();
        mShadeController.setNotificationShadeWindowViewController(
                getNotificationShadeWindowViewController());
        mBackActionInteractor.setup(mQsController, mShadeSurface);
    }

+1 −1
Original line number Diff line number Diff line
@@ -117,11 +117,11 @@ class ShadeControllerImplTest : SysuiTestCase() {
                deviceProvisionedController,
                notificationShadeWindowController,
                0,
                Lazy { nswvc },
                Lazy { npvc },
                Lazy { assistManager },
                Lazy { gutsManager },
            )
        shadeController.setNotificationShadeWindowViewController(nswvc)
        shadeController.setVisibilityListener(mock())
    }

+1 −2
Original line number Diff line number Diff line
@@ -467,13 +467,12 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
                    mDeviceProvisionedController,
                    mNotificationShadeWindowController,
                    0,
                    () -> mNotificationShadeWindowViewController,
                    () -> mNotificationPanelViewController,
                    () -> mAssistManager,
                    () -> mNotificationGutsManager
            ));
        }
        mShadeController.setNotificationShadeWindowViewController(
                mNotificationShadeWindowViewController);
        mShadeController.setNotificationPresenter(mNotificationPresenter);

        when(mOperatorNameViewControllerFactory.create(any()))
Loading