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

Commit 68249429 authored by Justin Weir's avatar Justin Weir
Browse files

Move shouldHideStatusBarIconsWhenExpanded to PanelExpansionInteractor

This removes one more method from ShadeViewController and fixes most of
b/330408932. The partial fix prevents NPVC from sending bad data to
ShadeExpansionStateManager when the scene container is active and adds
a scene-based implementation of shouldHideStatusBarIconsWhenExpanded,
allowing CollapsedStatusBarFragment.shouldHideStatusBar to work when
scenes are enabled.

Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Test: Updated and ran affected tests
Test: Manual
Bug: 303267342
Bug: 330408932
Change-Id: Ifa02960c120652e16c37feea1345caee5a4d63bc
parent 2459f784
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ class PanelExpansionInteractorImplTest : SysuiTestCase() {
    private val deviceEntryRepository = kosmos.fakeDeviceEntryRepository
    private val deviceUnlockedInteractor = kosmos.deviceUnlockedInteractor
    private val sceneInteractor = kosmos.sceneInteractor
    private val shadeAnimationInteractor = kosmos.shadeAnimationInteractor
    private val transitionState =
        MutableStateFlow<ObservableTransitionState>(
            ObservableTransitionState.Idle(Scenes.Lockscreen)
@@ -112,6 +113,40 @@ class PanelExpansionInteractorImplTest : SysuiTestCase() {
            changeScene(Scenes.Communal) { assertThat(panelExpansion).isEqualTo(1f) }
            assertThat(panelExpansion).isEqualTo(1f)
        }

    @Test
    @EnableSceneContainer
    fun shouldHideStatusBarIconsWhenExpanded_goneScene() =
        testScope.runTest {
            underTest = kosmos.panelExpansionInteractorImpl
            shadeAnimationInteractor.setIsLaunchingActivity(false)
            changeScene(Scenes.Gone)

            assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isFalse()
        }

    @Test
    @EnableSceneContainer
    fun shouldHideStatusBarIconsWhenExpanded_lockscreenScene() =
        testScope.runTest {
            underTest = kosmos.panelExpansionInteractorImpl
            shadeAnimationInteractor.setIsLaunchingActivity(false)
            changeScene(Scenes.Lockscreen)

            assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isTrue()
        }

    @Test
    @EnableSceneContainer
    fun shouldHideStatusBarIconsWhenExpanded_activityLaunch() =
        testScope.runTest {
            underTest = kosmos.panelExpansionInteractorImpl
            changeScene(Scenes.Gone)
            shadeAnimationInteractor.setIsLaunchingActivity(true)

            assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isFalse()
        }

    private fun TestScope.setUnlocked(isUnlocked: Boolean) {
        val isDeviceUnlocked by collectLastValue(deviceUnlockedInteractor.isDeviceUnlocked)
        deviceEntryRepository.setUnlocked(isUnlocked)
+4 −3
Original line number Diff line number Diff line
@@ -4121,9 +4121,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

    @Override
    public void updateExpansionAndVisibility() {
        if (!SceneContainerFlag.isEnabled()) {
            mShadeExpansionStateManager.onPanelExpansionChanged(
                    mExpandedFraction, isExpanded(), isTracking());

        }
        updateVisibility();
    }

+0 −3
Original line number Diff line number Diff line
@@ -33,9 +33,6 @@ interface ShadeViewController {
    /** Returns whether the shade's top level view is enabled. */
    @Deprecated("No longer supported. Do not add new calls to this.") val isViewEnabled: Boolean

    /** Returns whether status bar icons should be hidden when the shade is expanded. */
    fun shouldHideStatusBarIconsWhenExpanded(): Boolean

    /** If the latency tracker is enabled, begins tracking expand latency. */
    @Deprecated("No longer supported. Do not add new calls to this.")
    fun startExpandLatencyTracking()
+4 −0
Original line number Diff line number Diff line
@@ -72,4 +72,8 @@ interface PanelExpansionInteractor {

    /** Returns the StatusBarState. Note: System UI was formerly known simply as Status Bar. */
    @Deprecated("Use SceneInteractor or ShadeInteractor instead") val barState: Int

    /** Returns whether status bar icons should be hidden when the shade is expanded. */
    @Deprecated("No longer supported. Do not add new calls to this.")
    fun shouldHideStatusBarIconsWhenExpanded(): Boolean
}
+13 −10
Original line number Diff line number Diff line
@@ -69,27 +69,21 @@ constructor(
                        state.fromScene == Scenes.Gone ->
                            if (state.toScene.isExpandable()) {
                                // Moving from Gone to a scene that can animate-expand has a
                                // panel
                                // expansion
                                // that tracks with the transition.
                                // panel expansion that tracks with the transition.
                                state.progress
                            } else {
                                // Moving from Gone to a scene that doesn't animate-expand
                                // immediately makes
                                // the panel fully expanded.
                                // immediately makes the panel fully expanded.
                                flowOf(1f)
                            }
                        state.toScene == Scenes.Gone ->
                            if (state.fromScene.isExpandable()) {
                                // Moving to Gone from a scene that can animate-expand has a
                                // panel
                                // expansion
                                // that tracks with the transition.
                                // panel expansion that tracks with the transition.
                                state.progress.map { 1 - it }
                            } else {
                                // Moving to Gone from a scene that doesn't animate-expand
                                // immediately makes
                                // the panel fully collapsed.
                                // immediately makes the panel fully collapsed.
                                flowOf(0f)
                            }
                        else -> flowOf(1f)
@@ -126,6 +120,15 @@ constructor(
    override val barState
        get() = statusBarStateController.state

    @Deprecated("No longer supported. Do not add new calls to this.")
    override fun shouldHideStatusBarIconsWhenExpanded(): Boolean {
        if (shadeAnimationInteractor.isLaunchingActivity.value) {
            return false
        }
        // TODO(b/325936094) if a HUN is showing, return false
        return sceneInteractor.currentScene.value == Scenes.Lockscreen
    }

    private fun SceneKey.isExpandable(): Boolean {
        return this == Scenes.Shade || this == Scenes.QuickSettings
    }
Loading