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

Commit a4f4ada8 authored by William Xiao's avatar William Xiao
Browse files

Make usages of communal hub trunk flag also read config flag

The communal hub trunk stable flag is used to control the rollout of
the feature and is enabled across products. The config flag is used
to restrict the hub to tangorpro only. This CL adds a helper method
that ANDs the two flags together and can be used to disable things that
should not run at all if the hub isn't available. This prevents
unnecessary hub logic from running outside of tangor devices.

Bug: 351058701
Fix: 351058701
Test: atest ShadeTouchHandlerTest CommunalDreamStartableTest CommunalSettingsRepositoryImplTest LegacyActivityStarterInternalImplTest FromDreamingTransitionInteractorTest FromLockscreenTransitionInteractorTest KeyguardTransitionScenariosTest CommunalOngoingContentStartableTest
Flag: com.android.systemui.communal_hub
Change-Id: Ic203bde961fb97ecfc8df01e54906a8d0cf32d79
parent 19a9a180
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -25,9 +25,13 @@ import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.ambient.touch.TouchHandler.TouchSession
import com.android.systemui.ambient.touch.TouchHandler.TouchSession
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.shared.system.InputChannelCompat
import com.android.systemui.shared.system.InputChannelCompat
import com.android.systemui.statusbar.phone.CentralSurfaces
import com.android.systemui.statusbar.phone.CentralSurfaces
import com.android.systemui.testKosmos
import com.google.common.truth.Truth
import com.google.common.truth.Truth
import java.util.Optional
import java.util.Optional
import org.junit.Before
import org.junit.Before
@@ -45,6 +49,8 @@ import org.mockito.kotlin.whenever
@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4::class)
class ShadeTouchHandlerTest : SysuiTestCase() {
class ShadeTouchHandlerTest : SysuiTestCase() {
    private var kosmos = testKosmos()

    private var mCentralSurfaces = mock<CentralSurfaces>()
    private var mCentralSurfaces = mock<CentralSurfaces>()
    private var mShadeViewController = mock<ShadeViewController>()
    private var mShadeViewController = mock<ShadeViewController>()
    private var mDreamManager = mock<DreamManager>()
    private var mDreamManager = mock<DreamManager>()
@@ -62,6 +68,7 @@ class ShadeTouchHandlerTest : SysuiTestCase() {
                Optional.of(mCentralSurfaces),
                Optional.of(mCentralSurfaces),
                mShadeViewController,
                mShadeViewController,
                mDreamManager,
                mDreamManager,
                kosmos.communalSettingsInteractor,
                TOUCH_HEIGHT
                TOUCH_HEIGHT
            )
            )
    }
    }
@@ -86,6 +93,8 @@ class ShadeTouchHandlerTest : SysuiTestCase() {
    @Test
    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB)
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB)
    fun testSwipeDown_communalEnabled_sentToCentralSurfaces() {
    fun testSwipeDown_communalEnabled_sentToCentralSurfaces() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        swipe(Direction.DOWN)
        swipe(Direction.DOWN)


        // Both motion events are sent for central surfaces to process.
        // Both motion events are sent for central surfaces to process.
@@ -117,6 +126,8 @@ class ShadeTouchHandlerTest : SysuiTestCase() {
    @Test
    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB)
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB)
    fun testSwipeUp_communalEnabled_touchesNotSent() {
    fun testSwipeUp_communalEnabled_touchesNotSent() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        swipe(Direction.UP)
        swipe(Direction.UP)


        // Motion events are not sent for central surfaces to process as the swipe is going in the
        // Motion events are not sent for central surfaces to process as the swipe is going in the
+6 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.keyguardRepository
import com.android.systemui.keyguard.data.repository.keyguardRepository
@@ -61,9 +64,12 @@ class CommunalDreamStartableTest : SysuiTestCase() {


    @Before
    @Before
    fun setUp() {
    fun setUp() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        underTest =
        underTest =
            CommunalDreamStartable(
            CommunalDreamStartable(
                    powerInteractor = kosmos.powerInteractor,
                    powerInteractor = kosmos.powerInteractor,
                    communalSettingsInteractor = kosmos.communalSettingsInteractor,
                    keyguardInteractor = kosmos.keyguardInteractor,
                    keyguardInteractor = kosmos.keyguardInteractor,
                    keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor,
                    keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor,
                    dreamManager = dreamManager,
                    dreamManager = dreamManager,
+3 −3
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.fakeCommunalSmartspaceRepository
import com.android.systemui.communal.data.repository.fakeCommunalSmartspaceRepository
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.setCommunalEnabled
import com.android.systemui.communal.domain.interactor.setCommunalEnabled
import com.android.systemui.flags.Flags
import com.android.systemui.flags.Flags
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.flags.fakeFeatureFlagsClassic
@@ -48,20 +49,19 @@ class CommunalOngoingContentStartableTest : SysuiTestCase() {


    private val mediaRepository = kosmos.fakeCommunalMediaRepository
    private val mediaRepository = kosmos.fakeCommunalMediaRepository
    private val smartspaceRepository = kosmos.fakeCommunalSmartspaceRepository
    private val smartspaceRepository = kosmos.fakeCommunalSmartspaceRepository
    private val featureFlags =
        kosmos.fakeFeatureFlagsClassic.apply { set(Flags.COMMUNAL_SERVICE_ENABLED, true) }


    private lateinit var underTest: CommunalOngoingContentStartable
    private lateinit var underTest: CommunalOngoingContentStartable


    @Before
    @Before
    fun setUp() {
    fun setUp() {
        kosmos.fakeFeatureFlagsClassic.set(Flags.COMMUNAL_SERVICE_ENABLED, true)
        underTest =
        underTest =
            CommunalOngoingContentStartable(
            CommunalOngoingContentStartable(
                bgScope = kosmos.applicationCoroutineScope,
                bgScope = kosmos.applicationCoroutineScope,
                communalInteractor = kosmos.communalInteractor,
                communalInteractor = kosmos.communalInteractor,
                communalMediaRepository = mediaRepository,
                communalMediaRepository = mediaRepository,
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                communalSmartspaceRepository = smartspaceRepository,
                communalSmartspaceRepository = smartspaceRepository,
                featureFlags = featureFlags,
            )
            )
    }
    }


+2 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.domain.interactor.setCommunalAvailable
import com.android.systemui.communal.domain.interactor.setCommunalAvailable
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectLastValue
@@ -78,6 +79,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
                CommunalSceneStartable(
                CommunalSceneStartable(
                        dockManager = dockManager,
                        dockManager = dockManager,
                        communalInteractor = communalInteractor,
                        communalInteractor = communalInteractor,
                        communalSettingsInteractor = communalSettingsInteractor,
                        communalSceneInteractor = communalSceneInteractor,
                        communalSceneInteractor = communalSceneInteractor,
                        keyguardTransitionInteractor = keyguardTransitionInteractor,
                        keyguardTransitionInteractor = keyguardTransitionInteractor,
                        keyguardInteractor = keyguardInteractor,
                        keyguardInteractor = keyguardInteractor,
+32 −0
Original line number Original line Diff line number Diff line
@@ -66,6 +66,38 @@ class CommunalSettingsRepositoryImplTest : SysuiTestCase() {
        underTest = kosmos.communalSettingsRepository
        underTest = kosmos.communalSettingsRepository
    }
    }


    @EnableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun getFlagEnabled_bothEnabled() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        assertThat(underTest.getFlagEnabled()).isTrue()
    }

    @DisableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun getFlagEnabled_bothDisabled() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, false)

        assertThat(underTest.getFlagEnabled()).isFalse()
    }

    @DisableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun getFlagEnabled_onlyClassicFlagEnabled() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)

        assertThat(underTest.getFlagEnabled()).isFalse()
    }

    @EnableFlags(FLAG_COMMUNAL_HUB)
    @Test
    fun getFlagEnabled_onlyTrunkFlagEnabled() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, false)

        assertThat(underTest.getFlagEnabled()).isFalse()
    }

    @EnableFlags(FLAG_COMMUNAL_HUB)
    @EnableFlags(FLAG_COMMUNAL_HUB)
    @Test
    @Test
    fun secondaryUserIsInvalid() =
    fun secondaryUserIsInvalid() =
Loading