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

Commit 50bc205e authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge changes I75097a1f,I550b646a into main

* changes:
  Remove references to deprecated methods
  Avoid dismissing shade when launching activities from communal hub
parents e981ecd1 fd59bd3d
Loading
Loading
Loading
Loading
+54 −34
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.setCommunalAvailable
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.coroutines.collectLastValue
@@ -35,6 +36,8 @@ import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.statusbar.notificationShadeWindowController
import com.android.systemui.statusbar.phone.centralSurfaces
import com.android.systemui.statusbar.phone.centralSurfacesOptional
import com.android.systemui.testKosmos
import com.android.systemui.util.settings.fakeSettings
import com.google.common.truth.Truth.assertThat
@@ -49,6 +52,7 @@ import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.whenever

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@@ -67,6 +71,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
                CommunalSceneStartable(
                        dockManager = dockManager,
                        communalInteractor = communalInteractor,
                        communalSceneInteractor = communalSceneInteractor,
                        keyguardTransitionInteractor = keyguardTransitionInteractor,
                        keyguardInteractor = keyguardInteractor,
                        systemSettings = fakeSettings,
@@ -74,6 +79,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
                        applicationScope = applicationCoroutineScope,
                        bgScope = applicationCoroutineScope,
                        mainDispatcher = testDispatcher,
                        centralSurfacesOpt = centralSurfacesOptional,
                    )
                    .apply { start() }

@@ -90,9 +96,9 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun keyguardGoesAway_forceBlankScene() =
        with(kosmos) {
            testScope.runTest {
                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)

                communalInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                fakeKeyguardTransitionRepository.sendTransitionSteps(
@@ -110,7 +116,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun deviceDocked_forceCommunalScene() =
        with(kosmos) {
            testScope.runTest {
                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Blank)

                updateDocked(true)
@@ -127,8 +133,9 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun occluded_forceBlankScene() =
        with(kosmos) {
            testScope.runTest {
                val scene by collectLastValue(communalInteractor.desiredScene)
                communalInteractor.changeScene(CommunalScenes.Communal)
                whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(false)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                updateDocked(true)
@@ -141,11 +148,30 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            }
        }

    @Test
    fun occluded_doesNotForceBlankSceneIfLaunchingActivityOverLockscreen() =
        with(kosmos) {
            testScope.runTest {
                whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(true)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                updateDocked(true)
                fakeKeyguardTransitionRepository.sendTransitionSteps(
                    from = KeyguardState.GLANCEABLE_HUB,
                    to = KeyguardState.OCCLUDED,
                    testScope = this
                )
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
            }
        }

    @Test
    fun deviceDocked_doesNotForceCommunalIfTransitioningFromCommunal() =
        with(kosmos) {
            testScope.runTest {
                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Blank)

                updateDocked(true)
@@ -162,8 +188,8 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun deviceAsleep_forceBlankSceneAfterTimeout() =
        with(kosmos) {
            testScope.runTest {
                val scene by collectLastValue(communalInteractor.desiredScene)
                communalInteractor.changeScene(CommunalScenes.Communal)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                fakeKeyguardTransitionRepository.sendTransitionSteps(
@@ -183,8 +209,8 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun deviceAsleep_wakesUpBeforeTimeout_noChangeInScene() =
        with(kosmos) {
            testScope.runTest {
                val scene by collectLastValue(communalInteractor.desiredScene)
                communalInteractor.changeScene(CommunalScenes.Communal)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                fakeKeyguardTransitionRepository.sendTransitionSteps(
@@ -212,8 +238,8 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun dockingOnLockscreen_forcesCommunal() =
        with(kosmos) {
            testScope.runTest {
                communalInteractor.changeScene(CommunalScenes.Blank)
                val scene by collectLastValue(communalInteractor.desiredScene)
                communalSceneInteractor.changeScene(CommunalScenes.Blank)
                val scene by collectLastValue(communalSceneInteractor.currentScene)

                // device is docked while on the lockscreen
                fakeKeyguardTransitionRepository.sendTransitionSteps(
@@ -234,8 +260,8 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun dockingOnLockscreen_doesNotForceCommunalIfDreamStarts() =
        with(kosmos) {
            testScope.runTest {
                communalInteractor.changeScene(CommunalScenes.Blank)
                val scene by collectLastValue(communalInteractor.desiredScene)
                communalSceneInteractor.changeScene(CommunalScenes.Blank)
                val scene by collectLastValue(communalSceneInteractor.currentScene)

                // device is docked while on the lockscreen
                fakeKeyguardTransitionRepository.sendTransitionSteps(
@@ -266,9 +292,9 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
                // Device is dreaming and on communal.
                updateDreaming(true)
                communalInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)

                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                // Scene times out back to blank after the screen timeout.
@@ -283,11 +309,11 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
                // Device is not dreaming and on communal.
                updateDreaming(false)
                communalInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)

                // Scene stays as Communal
                advanceTimeBy(SCREEN_TIMEOUT.milliseconds)
                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
            }
        }
@@ -298,9 +324,9 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
                // Device is dreaming and on communal.
                updateDreaming(true)
                communalInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)

                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                // Wait a bit, but not long enough to timeout.
@@ -321,9 +347,9 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
                // Device is on communal, but not dreaming.
                updateDreaming(false)
                communalInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)

                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                // Wait a bit, but not long enough to timeout, then start dreaming.
@@ -342,11 +368,11 @@ class CommunalSceneStartableTest : SysuiTestCase() {
        with(kosmos) {
            testScope.runTest {
                // Device is on communal.
                communalInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)

                // Device stays on the hub after the timeout since we're not dreaming.
                advanceTimeBy(SCREEN_TIMEOUT.milliseconds * 2)
                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                // Start dreaming.
@@ -363,9 +389,9 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
                // Device is dreaming and on communal.
                updateDreaming(true)
                communalInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)

                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                // Wait a bit, but not long enough to timeout.
@@ -392,9 +418,9 @@ class CommunalSceneStartableTest : SysuiTestCase() {

                // Device is dreaming and on communal.
                updateDreaming(true)
                communalInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)

                val scene by collectLastValue(communalInteractor.desiredScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)

                // Scene times out back to blank after the screen timeout.
@@ -421,12 +447,6 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            runCurrent()
        }

    private suspend fun TestScope.enableCommunal() =
        with(kosmos) {
            setCommunalAvailable(true)
            runCurrent()
        }

    companion object {
        private const val SCREEN_TIMEOUT = 1000
    }
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.fakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.domain.model.CommunalContentModel
import com.android.systemui.communal.shared.log.CommunalUiEvent
@@ -106,6 +107,7 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {

        underTest =
            CommunalEditModeViewModel(
                kosmos.communalSceneInteractor,
                kosmos.communalInteractor,
                kosmos.communalSettingsInteractor,
                mediaHost,
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.communal.data.repository.fakeCommunalRepository
import com.android.systemui.communal.data.repository.fakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.communalTutorialInteractor
import com.android.systemui.communal.domain.model.CommunalContentModel
import com.android.systemui.communal.shared.model.CommunalScenes
@@ -143,6 +144,7 @@ class CommunalViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
                context.resources,
                kosmos.keyguardTransitionInteractor,
                kosmos.keyguardInteractor,
                kosmos.communalSceneInteractor,
                kosmos.communalInteractor,
                kosmos.communalTutorialInteractor,
                kosmos.shadeInteractor,
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ class WidgetInteractionHandlerTest : SysuiTestCase() {
        verify(activityStarter)
            .startPendingIntentMaybeDismissingKeyguard(
                eq(testIntent),
                eq(false),
                isNull(),
                notNull(),
                refEq(fillInIntent),
@@ -91,6 +92,7 @@ class WidgetInteractionHandlerTest : SysuiTestCase() {
        verify(activityStarter)
            .startPendingIntentMaybeDismissingKeyguard(
                eq(testIntent),
                eq(false),
                isNull(),
                isNull(),
                refEq(fillInIntent),
+6 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.ActivityTransitionAnimator
import com.android.systemui.animation.LaunchableView
import com.android.systemui.assist.AssistManager
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.plugins.ActivityStarter.OnDismissAction
@@ -94,6 +95,7 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {
    @Mock private lateinit var deviceProvisionedController: DeviceProvisionedController
    @Mock private lateinit var userTracker: UserTracker
    @Mock private lateinit var activityIntentHelper: ActivityIntentHelper
    @Mock private lateinit var communalSceneInteractor: CommunalSceneInteractor
    private lateinit var underTest: LegacyActivityStarterInternalImpl
    private val mainExecutor = FakeExecutor(FakeSystemClock())
    private val shadeAnimationInteractor =
@@ -127,6 +129,7 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {
                userTracker = userTracker,
                activityIntentHelper = activityIntentHelper,
                mainExecutor = mainExecutor,
                communalSceneInteractor = communalSceneInteractor,
            )
        whenever(userTracker.userHandle).thenReturn(UserHandle.OWNER)
    }
@@ -138,7 +141,7 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {
        whenever(keyguardStateController.isShowing).thenReturn(true)
        whenever(deviceProvisionedController.isDeviceProvisioned).thenReturn(true)

        underTest.startPendingIntentDismissingKeyguard(pendingIntent)
        underTest.startPendingIntentDismissingKeyguard(intent = pendingIntent, dismissShade = true)
        mainExecutor.runAllReady()

        verify(statusBarKeyguardViewManager)
@@ -232,6 +235,7 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {

        underTest.startPendingIntentDismissingKeyguard(
            intent = pendingIntent,
            dismissShade = true,
            intentSentUiThreadCallback = null,
            associatedView = associatedView,
        )
@@ -344,6 +348,7 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {
    ) {
        underTest.startPendingIntentDismissingKeyguard(
            intent = intent,
            dismissShade = true,
            intentSentUiThreadCallback = intentSentUiThreadCallback,
            animationController = animationController,
            showOverLockscreen = true,
Loading