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

Commit 1aca561e authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Clean up AmbientStatusBarViewController's Status Bar Listener." into main

parents af5140c5 1e18fd01
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ public class AmbientStatusBarViewControllerTest extends SysuiTestCase {
                mKosmos.getWifiInteractor(),
                mKosmos.getCommunalSceneInteractor(),
                mLogBuffer);
        mController.onInit();
    }

    @Test
@@ -517,6 +518,15 @@ public class AmbientStatusBarViewControllerTest extends SysuiTestCase {
        verify(mDreamOverlayStateController).setDreamOverlayStatusBarVisible(false);
    }

    @Test
    public void testStatusBarWindowStateControllerListenerLifecycle() {
        ArgumentCaptor<StatusBarWindowStateListener> listenerCaptor =
                ArgumentCaptor.forClass(StatusBarWindowStateListener.class);
        verify(mStatusBarWindowStateController).addListener(listenerCaptor.capture());
        mController.destroy();
        verify(mStatusBarWindowStateController).removeListener(eq(listenerCaptor.getValue()));
    }

    private StatusBarWindowStateListener updateStatusBarWindowState(boolean show) {
        when(mStatusBarWindowStateController.windowIsShowing()).thenReturn(show);
        final ArgumentCaptor<StatusBarWindowStateListener>
+17 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.window.StatusBarWindowStateController;
import com.android.systemui.statusbar.window.StatusBarWindowStateListener;
import com.android.systemui.util.ViewController;
import com.android.systemui.util.time.DateFormatUtil;

@@ -127,6 +128,9 @@ public class AmbientStatusBarViewController extends ViewController<AmbientStatus
    private final DreamOverlayStatusBarItemsProvider.Callback mStatusBarItemsProviderCallback =
            this::onStatusBarItemsChanged;

    private final StatusBarWindowStateListener mStatusBarWindowStateListener =
            this::onSystemStatusBarStateChanged;

    @Inject
    public AmbientStatusBarViewController(
            AmbientStatusBarView view,
@@ -161,10 +165,22 @@ public class AmbientStatusBarViewController extends ViewController<AmbientStatus
        mWifiInteractor = wifiInteractor;
        mCommunalSceneInteractor = communalSceneInteractor;
        mLogger = new DreamLogger(logBuffer, TAG);
    }

    @Override
    protected void onInit() {
        super.onInit();

        // Register to receive show/hide updates for the system status bar. Our custom status bar
        // needs to hide when the system status bar is showing to ovoid overlapping status bars.
        statusBarWindowStateController.addListener(this::onSystemStatusBarStateChanged);
        mStatusBarWindowStateController.addListener(mStatusBarWindowStateListener);
    }

    @Override
    public void destroy() {
        mStatusBarWindowStateController.removeListener(mStatusBarWindowStateListener);

        super.destroy();
    }

    @Override