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

Commit 9f3f8c0f authored by Bryce Lee's avatar Bryce Lee
Browse files

Add back gesture navigation to Glanceable Hub.

This changelist adds back gesture handling on Glanceable Hub, snapping
back to the lockscreen when invoked.

This change also removes a communal tutorial interactor test that
is predicated on setting the tutorial state before entering the
Glanceable Hub. This is incompatible with a state flow for isShowing
as the default initial state will immediately set the tutorial to
shown. The tutorial code is unused and deprecated so the test has
been removed.

Flag: com.android.systemui.glanceable_hub_back_action
Test: atest CommunalBackActionInteractorTest
Fixes: 382771533
Change-Id: I3e50b52aa12cd27f20a7260385c3d4b534f4e65b
parent 37b9d5c9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1236,6 +1236,13 @@ flag {
  is_fixed_read_only: true
}

flag {
    name: "glanceable_hub_back_action"
    namespace: "systemui"
    description: "Support back action from glanceable hub"
    bug: "382771533"
}

flag {
    name: "dream_overlay_updated_font"
    namespace: "systemui"
+17 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.back.domain.interactor

import android.platform.test.annotations.EnableFlags
import android.platform.test.annotations.RequiresFlagsDisabled
import android.platform.test.annotations.RequiresFlagsEnabled
import android.platform.test.flag.junit.DeviceFlagsValueProvider
@@ -31,6 +32,7 @@ import androidx.test.filters.SmallTest
import com.android.internal.statusbar.IStatusBarService
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.CommunalBackActionInteractor
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
@@ -93,6 +95,7 @@ class BackActionInteractorTest : SysuiTestCase() {
    @Mock private lateinit var onBackInvokedDispatcher: WindowOnBackInvokedDispatcher
    @Mock private lateinit var iStatusBarService: IStatusBarService
    @Mock private lateinit var headsUpManager: HeadsUpManager
    @Mock private lateinit var communalBackActionInteractor: CommunalBackActionInteractor

    private val keyguardRepository = FakeKeyguardRepository()
    private val windowRootViewVisibilityInteractor: WindowRootViewVisibilityInteractor by lazy {
@@ -117,6 +120,7 @@ class BackActionInteractorTest : SysuiTestCase() {
            windowRootViewVisibilityInteractor,
            shadeBackActionInteractor,
            qsController,
            communalBackActionInteractor,
        )
    }

@@ -306,6 +310,19 @@ class BackActionInteractorTest : SysuiTestCase() {
        verify(shadeBackActionInteractor).onBackProgressed(0.4f)
    }

    @Test
    @EnableFlags(Flags.FLAG_GLANCEABLE_HUB_BACK_ACTION)
    fun onBackAction_communalCanBeDismissed_communalBackActionInteractorCalled() {
        backActionInteractor.start()
        windowRootViewVisibilityInteractor.setIsLockscreenOrShadeVisible(true)
        powerInteractor.setAwakeForTest()
        val callback = getBackInvokedCallback()
        whenever(communalBackActionInteractor.canBeDismissed()).thenReturn(true)
        callback.onBackInvoked()

        verify(communalBackActionInteractor).onBackPressed()
    }

    private fun getBackInvokedCallback(): OnBackInvokedCallback {
        testScope.runCurrent()
        val captor = argumentCaptor<OnBackInvokedCallback>()
+63 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.communal.domain.interactor

import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.communalSceneRepository
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.runCurrent
import com.android.systemui.kosmos.runTest
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.junit.Test
import org.junit.runner.RunWith

@SmallTest
@OptIn(ExperimentalCoroutinesApi::class)
@RunWith(AndroidJUnit4::class)
class CommunalBackActionInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos()

    private var Kosmos.underTest by Fixture { communalBackActionInteractor }

    @Test
    @EnableFlags(FLAG_COMMUNAL_HUB)
    fun communalShowing_canBeDismissed() =
        kosmos.runTest {
            setCommunalAvailable(true)
            assertThat(underTest.canBeDismissed()).isEqualTo(false)
            communalInteractor.changeScene(CommunalScenes.Communal, "test")
            runCurrent()
            assertThat(underTest.canBeDismissed()).isEqualTo(true)
        }

    @Test
    @EnableFlags(FLAG_COMMUNAL_HUB)
    fun onBackPressed_invokesSceneChange() =
        kosmos.runTest {
            underTest.onBackPressed()
            runCurrent()
            assertThat(communalSceneRepository.currentScene.value).isEqualTo(CommunalScenes.Blank)
        }
}
+0 −13
Original line number Diff line number Diff line
@@ -129,19 +129,6 @@ class CommunalTutorialInteractorTest : SysuiTestCase() {
            assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_STARTED)
        }

    @Test
    fun tutorialState_startedAndCommunalSceneShowing_stateWillNotUpdate() =
        testScope.runTest {
            val tutorialSettingState by
                collectLastValue(communalTutorialRepository.tutorialSettingState)

            communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_STARTED)

            goToCommunal()

            assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_STARTED)
        }

    @Test
    fun tutorialState_completedAndCommunalSceneShowing_stateWillNotUpdate() =
        testScope.runTest {
+5 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;

import static com.android.systemui.Flags.glanceableHubBackAction;
import static com.android.systemui.shared.Flags.shadeAllowBackGesture;

import android.annotation.LongDef;
@@ -352,6 +353,10 @@ public class QuickStepContract {
        }
        // Disable back gesture on the hub, but not when the shade is showing.
        if ((sysuiStateFlags & SYSUI_STATE_COMMUNAL_HUB_SHOWING) != 0) {
            // Allow back gesture on Glanceable Hub with back action support.
            if (glanceableHubBackAction()) {
                return false;
            }
            // Use QS expanded signal as the notification panel is always considered visible
            // expanded when on the lock screen and when opening hub over lock screen. This does
            // mean that back gesture is disabled when opening shade over hub while in portrait
Loading