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

Commit e5d366f9 authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Replace usages of communal_hub_on_mobile" into main

parents 04517b22 7862f5a6
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -1229,13 +1229,6 @@ flag {
  bug: "352301247"
}

flag {
  name: "communal_hub_on_mobile"
  namespace: "systemui"
  description: "Brings the glanceable hub experience to mobile phones"
  bug: "375689917"
}

flag {
  name: "glanceable_hub_v2"
  namespace: "systemui"
+3 −3
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import com.android.compose.animation.scene.SceneTransitionLayout
import com.android.compose.animation.scene.Swipe
import com.android.compose.animation.scene.observableTransitionState
import com.android.compose.animation.scene.transitions
import com.android.systemui.Flags.communalHubOnMobile
import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.shared.model.CommunalTransitionKeys
@@ -188,7 +187,7 @@ fun CommunalContainer(
        scene(
            CommunalScenes.Blank,
            userActions =
                if (communalHubOnMobile()) emptyMap()
                if (viewModel.v2FlagEnabled()) emptyMap()
                else mapOf(Swipe.Start(fromSource = Edge.End) to CommunalScenes.Communal),
        ) {
            // This scene shows nothing only allowing for transitions to the communal scene.
@@ -198,7 +197,8 @@ fun CommunalContainer(
        scene(
            CommunalScenes.Communal,
            userActions =
                if (communalHubOnMobile()) emptyMap() else mapOf(Swipe.End to CommunalScenes.Blank),
                if (viewModel.v2FlagEnabled()) emptyMap()
                else mapOf(Swipe.End to CommunalScenes.Blank),
        ) {
            CommunalScene(
                backgroundType = backgroundType,
+13 −4
Original line number Diff line number Diff line
@@ -29,8 +29,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.domain.interactor.setCommunalV2ConfigEnabled
import com.android.systemui.log.core.FakeLogBuffer
import com.android.systemui.shared.condition.Monitor
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.withArgCaptor
import kotlin.test.Test
import org.junit.Before
@@ -48,6 +51,8 @@ import org.mockito.kotlin.whenever
@TestableLooper.RunWithLooper
@RunWith(AndroidJUnit4::class)
class DreamOverlayRegistrantTest : SysuiTestCase() {
    private val kosmos = testKosmos()

    private val context = mock<Context>()

    private val packageManager = mock<PackageManager>()
@@ -73,6 +78,7 @@ class DreamOverlayRegistrantTest : SysuiTestCase() {
                monitor,
                packageManager,
                dreamManager,
                kosmos.communalSettingsInteractor,
                logBuffer,
            )

@@ -117,7 +123,7 @@ class DreamOverlayRegistrantTest : SysuiTestCase() {

    /** Verify overlay registered when enabled in manifest. */
    @Test
    @DisableFlags(Flags.FLAG_COMMUNAL_HUB_ON_MOBILE)
    @DisableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun testRegisteredWhenEnabledWithManifest() {
        serviceInfo.enabled = true
        start()
@@ -127,8 +133,10 @@ class DreamOverlayRegistrantTest : SysuiTestCase() {

    /** Verify overlay registered for mobile hub with flag. */
    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB_ON_MOBILE)
    @EnableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun testRegisteredForMobileHub() {
        kosmos.setCommunalV2ConfigEnabled(true)

        start()

        verify(dreamManager).registerDreamOverlayService(componentName)
@@ -139,7 +147,7 @@ class DreamOverlayRegistrantTest : SysuiTestCase() {
     * enabled.
     */
    @Test
    @DisableFlags(Flags.FLAG_COMMUNAL_HUB_ON_MOBILE)
    @DisableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun testDisabledForMobileWithoutMobileHub() {
        start()

@@ -154,8 +162,9 @@ class DreamOverlayRegistrantTest : SysuiTestCase() {

    /** Ensure service unregistered when component is disabled at runtime. */
    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB_ON_MOBILE)
    @EnableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun testUnregisteredWhenComponentDisabled() {
        kosmos.setCommunalV2ConfigEnabled(true)
        start()
        verify(dreamManager).registerDreamOverlayService(componentName)
        clearInvocations(dreamManager)
+8 −3
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ import com.android.internal.logging.UiEventLogger
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB_ON_MOBILE
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2
import com.android.systemui.Flags.FLAG_SCENE_CONTAINER
import com.android.systemui.SysuiTestCase
import com.android.systemui.ambient.touch.TouchHandler
@@ -55,7 +55,9 @@ import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepositor
import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.domain.interactor.setCommunalAvailable
import com.android.systemui.communal.domain.interactor.setCommunalV2ConfigEnabled
import com.android.systemui.communal.shared.log.CommunalUiEvent
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.complication.ComplicationHostViewController
@@ -262,6 +264,7 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() {
                mKeyguardUpdateMonitor,
                mScrimManager,
                mCommunalInteractor,
                kosmos.communalSettingsInteractor,
                kosmos.sceneInteractor,
                mSystemDialogsCloser,
                mUiEventLogger,
@@ -1283,7 +1286,7 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() {
        environmentComponents.verifyNoMoreInteractions()
    }

    @DisableFlags(FLAG_COMMUNAL_HUB_ON_MOBILE)
    @DisableFlags(FLAG_GLANCEABLE_HUB_V2)
    @Test
    fun testAmbientTouchHandlersRegistration_registerHideComplicationAndCommunal() {
        val client = client
@@ -1303,9 +1306,11 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() {
            .containsExactly(mHideComplicationTouchHandler, mCommunalTouchHandler)
    }

    @EnableFlags(FLAG_COMMUNAL_HUB_ON_MOBILE)
    @EnableFlags(FLAG_GLANCEABLE_HUB_V2)
    @Test
    fun testAmbientTouchHandlersRegistration_v2_registerOnlyHideComplication() {
        kosmos.setCommunalV2ConfigEnabled(true)

        val client = client

        // Inform the overlay service of dream starting.
+14 −10
Original line number Diff line number Diff line
@@ -25,7 +25,8 @@ import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.communalSceneRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.setCommunalEnabled
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.domain.interactor.setCommunalV2Enabled
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.andSceneContainer
@@ -38,7 +39,6 @@ import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -48,7 +48,7 @@ import platform.test.runner.parameterized.Parameters

@SmallTest
@OptIn(ExperimentalCoroutinesApi::class)
@EnableFlags(Flags.FLAG_GLANCEABLE_HUB_SHORTCUT_BUTTON)
@EnableFlags(Flags.FLAG_GLANCEABLE_HUB_SHORTCUT_BUTTON, Flags.FLAG_GLANCEABLE_HUB_V2)
@RunWith(ParameterizedAndroidJunit4::class)
class GlanceableHubQuickAffordanceConfigTest(flags: FlagsParameterization?) : SysuiTestCase() {
    private val kosmos = testKosmos()
@@ -69,6 +69,7 @@ class GlanceableHubQuickAffordanceConfigTest(flags: FlagsParameterization?) : Sy
                context = context,
                communalInteractor = kosmos.communalInteractor,
                communalSceneRepository = kosmos.communalSceneRepository,
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                sceneInteractor = kosmos.sceneInteractor,
            )
    }
@@ -76,28 +77,30 @@ class GlanceableHubQuickAffordanceConfigTest(flags: FlagsParameterization?) : Sy
    @Test
    fun lockscreenState_whenGlanceableHubEnabled_returnsVisible() =
        testScope.runTest {
            kosmos.setCommunalEnabled(true)
            kosmos.setCommunalV2Enabled(true)
            runCurrent()

            val lockScreenState by collectLastValue(underTest.lockScreenState)

            assertTrue(lockScreenState is KeyguardQuickAffordanceConfig.LockScreenState.Visible)
            assertThat(lockScreenState)
                .isInstanceOf(KeyguardQuickAffordanceConfig.LockScreenState.Visible::class.java)
        }

    @Test
    fun lockscreenState_whenGlanceableHubDisabled_returnsHidden() =
        testScope.runTest {
            kosmos.setCommunalEnabled(false)
            kosmos.setCommunalV2Enabled(false)
            val lockScreenState by collectLastValue(underTest.lockScreenState)
            runCurrent()

            assertTrue(lockScreenState is KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
            assertThat(lockScreenState)
                .isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
        }

    @Test
    fun pickerScreenState_whenGlanceableHubEnabled_returnsDefault() =
        testScope.runTest {
            kosmos.setCommunalEnabled(true)
            kosmos.setCommunalV2Enabled(true)
            runCurrent()

            assertThat(underTest.getPickerScreenState())
@@ -107,7 +110,7 @@ class GlanceableHubQuickAffordanceConfigTest(flags: FlagsParameterization?) : Sy
    @Test
    fun pickerScreenState_whenGlanceableHubDisabled_returnsDisabled() =
        testScope.runTest {
            kosmos.setCommunalEnabled(false)
            kosmos.setCommunalV2Enabled(false)
            runCurrent()

            assertThat(
@@ -143,7 +146,8 @@ class GlanceableHubQuickAffordanceConfigTest(flags: FlagsParameterization?) : Sy
        @Parameters(name = "{0}")
        fun getParams(): List<FlagsParameterization> {
            return FlagsParameterization.allCombinationsOf(
                    Flags.FLAG_GLANCEABLE_HUB_SHORTCUT_BUTTON
                    Flags.FLAG_GLANCEABLE_HUB_SHORTCUT_BUTTON,
                    Flags.FLAG_GLANCEABLE_HUB_V2,
                )
                .andSceneContainer()
        }
Loading