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

Commit 60985a39 authored by burakov's avatar burakov
Browse files

[bc25] Refactor ShadeInteractor for Dual Shade Overlays.

This also adds expandNotificationShade() and expandQuickSettingsShade(),
 which make it easier to ensure the shade is opened correctly in the
 different shade modes.

Bug: 356596436
Flag: com.android.systemui.scene_container
Flag: com.android.systemui.dual_shade
Test: Manually tested by opening the Wallpaper Picker and navigating to
 the "Lock screen" tab and "Shortcuts" section. The lockscreen preview
 renders correctly, and the shortcuts change and render correctly too.
Test: Added new unit tests for the two new functions introduced.
Test: Existing unit tests still pass.
Change-Id: I92368206c6849c8fefba881049db391d8ca9b11f
parent 5394369d
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -87,6 +87,26 @@ class ShadeModeInteractorImplTest : SysuiTestCase() {
            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
        }

    @Test
    @EnableFlags(DualShade.FLAG_NAME)
    fun isDualShade_flagEnabled_true() =
        testScope.runTest {
            // Initiate collection.
            val shadeMode by collectLastValue(underTest.shadeMode)

            assertThat(underTest.isDualShade).isTrue()
        }

    @Test
    @DisableFlags(DualShade.FLAG_NAME)
    fun isDualShade_flagDisabled_false() =
        testScope.runTest {
            // Initiate collection.
            val shadeMode by collectLastValue(underTest.shadeMode)

            assertThat(underTest.isDualShade).isFalse()
        }

    @Test
    fun getTopEdgeSplitFraction_narrowScreen_splitInHalf() =
        testScope.runTest {
+7 −10
Original line number Diff line number Diff line
@@ -101,10 +101,10 @@ import com.android.systemui.navigationbar.views.buttons.KeyButtonView;
import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
import com.android.systemui.scene.domain.interactor.SceneInteractor;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.scene.shared.model.SceneFamilies;
import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeViewController;
import com.android.systemui.shade.domain.interactor.ShadeInteractor;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.QuickStepContract;
@@ -158,6 +158,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
    private final ScreenPinningRequest mScreenPinningRequest;
    private final NotificationShadeWindowController mStatusBarWinController;
    private final Provider<SceneInteractor> mSceneInteractor;
    private final Provider<ShadeInteractor> mShadeInteractor;

    private final KeyboardTouchpadEduStatsInteractor mKeyboardTouchpadEduStatsInteractor;

@@ -246,11 +247,8 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                            }
                        } else if (action == ACTION_UP) {
                            // Gesture was too short to be picked up by scene container touch
                            // handling; programmatically start the transition to shade scene.
                            mSceneInteractor.get().changeScene(
                                    SceneFamilies.NotifShade,
                                    "short launcher swipe"
                            );
                            // handling; programmatically start the transition to the shade.
                            mShadeInteractor.get().expandNotificationShade("short launcher swipe");
                        }
                    }
                    event.recycle();
@@ -267,10 +265,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                        mSceneInteractor.get().onRemoteUserInputStarted(
                                "trackpad swipe");
                    } else if (action == ACTION_UP) {
                        mSceneInteractor.get().changeScene(
                                SceneFamilies.NotifShade,
                                "short trackpad swipe"
                        );
                        mShadeInteractor.get().expandNotificationShade("short trackpad swipe");
                    }
                    mStatusBarWinController.getWindowRootView().dispatchTouchEvent(event);
                } else {
@@ -652,6 +647,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
            NotificationShadeWindowController statusBarWinController,
            SysUiState sysUiState,
            Provider<SceneInteractor> sceneInteractor,
            Provider<ShadeInteractor> shadeInteractor,
            UserTracker userTracker,
            UserManager userManager,
            WakefulnessLifecycle wakefulnessLifecycle,
@@ -688,6 +684,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        mScreenPinningRequest = screenPinningRequest;
        mStatusBarWinController = statusBarWinController;
        mSceneInteractor = sceneInteractor;
        mShadeInteractor = shadeInteractor;
        mUserTracker = userTracker;
        mConnectionBackoffAttempts = 0;
        mRecentsComponentName = ComponentName.unflattenFromString(context.getString(
+5 −14
Original line number Diff line number Diff line
@@ -91,17 +91,14 @@ constructor(
    }

    override fun instantCollapseShade() {
        sceneInteractor.snapToScene(
            SceneFamilies.Home,
            "hide shade",
        )
        sceneInteractor.snapToScene(SceneFamilies.Home, "hide shade")
    }

    override fun animateCollapseShade(
        flags: Int,
        force: Boolean,
        delayed: Boolean,
        speedUpFactor: Float
        speedUpFactor: Float,
    ) {
        if (!force && !shadeInteractor.isAnyExpanded.value) {
            runPostCollapseActions()
@@ -147,7 +144,7 @@ constructor(
        if (shadeInteractor.isAnyExpanded.value) {
            commandQueue.animateCollapsePanels(
                CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL,
                true /* force */
                true, /* force */
            )
            assistManagerLazy.get().hideAssist()
        }
@@ -172,17 +169,11 @@ constructor(
    }

    override fun expandToNotifications() {
        sceneInteractor.changeScene(
            SceneFamilies.NotifShade,
            "ShadeController.animateExpandShade",
        )
        shadeInteractor.expandNotificationShade("ShadeController.animateExpandShade")
    }

    override fun expandToQs() {
        sceneInteractor.changeScene(
            SceneFamilies.QuickSettings,
            "ShadeController.animateExpandQs",
        )
        shadeInteractor.expandQuickSettingsShade("ShadeController.animateExpandQs")
    }

    override fun setVisibilityListener(listener: ShadeVisibilityListener) {
+12 −0
Original line number Diff line number Diff line
@@ -140,6 +140,18 @@ interface BaseShadeInteractor {
     * animating.
     */
    val isUserInteractingWithQs: Flow<Boolean>

    /**
     * Triggers the expansion (opening) of the notification shade. If the notification shade is
     * already open, this has no effect.
     */
    fun expandNotificationShade(loggingReason: String)

    /**
     * Triggers the expansion (opening) of the quick settings shade. If the quick settings shade is
     * already open, this has no effect.
     */
    fun expandQuickSettingsShade(loggingReason: String)
}

fun createAnyExpansionFlow(
+4 −0
Original line number Diff line number Diff line
@@ -49,4 +49,8 @@ class ShadeInteractorEmptyImpl @Inject constructor() : ShadeInteractor {
    override val isShadeLayoutWide: StateFlow<Boolean> = inactiveFlowBoolean

    override fun getTopEdgeSplitFraction(): Float = 0.5f

    override fun expandNotificationShade(loggingReason: String) {}

    override fun expandQuickSettingsShade(loggingReason: String) {}
}
Loading