summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalOngoingContentStartableTest.kt74
-rw-r--r--packages/SystemUI/res/values/config.xml3
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/CommunalOngoingContentStartable.kt13
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt7
4 files changed, 67 insertions, 30 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalOngoingContentStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalOngoingContentStartableTest.kt
index e53155de653d..ed73d89db2c7 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalOngoingContentStartableTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalOngoingContentStartableTest.kt
@@ -21,6 +21,8 @@ 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.communalMediaRepository
+import com.android.systemui.communal.data.repository.communalSmartspaceRepository
import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.fakeCommunalSmartspaceRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
@@ -28,12 +30,12 @@ import com.android.systemui.communal.domain.interactor.communalSettingsInteracto
import com.android.systemui.communal.domain.interactor.setCommunalEnabled
import com.android.systemui.flags.Flags
import com.android.systemui.flags.fakeFeatureFlagsClassic
+import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.applicationCoroutineScope
-import com.android.systemui.kosmos.testScope
+import com.android.systemui.kosmos.runTest
+import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.test.runCurrent
-import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -42,46 +44,64 @@ import org.junit.runner.RunWith
@EnableFlags(FLAG_COMMUNAL_HUB)
@RunWith(AndroidJUnit4::class)
class CommunalOngoingContentStartableTest : SysuiTestCase() {
- private val kosmos = testKosmos()
- private val testScope = kosmos.testScope
+ private val kosmos = testKosmos().useUnconfinedTestDispatcher()
- private val mediaRepository = kosmos.fakeCommunalMediaRepository
- private val smartspaceRepository = kosmos.fakeCommunalSmartspaceRepository
+ private var showUmoOnHub = true
- private lateinit var underTest: CommunalOngoingContentStartable
+ private val Kosmos.underTest by
+ Kosmos.Fixture {
+ CommunalOngoingContentStartable(
+ bgScope = applicationCoroutineScope,
+ communalInteractor = communalInteractor,
+ communalMediaRepository = communalMediaRepository,
+ communalSettingsInteractor = communalSettingsInteractor,
+ communalSmartspaceRepository = communalSmartspaceRepository,
+ showUmoOnHub = showUmoOnHub,
+ )
+ }
@Before
fun setUp() {
kosmos.fakeFeatureFlagsClassic.set(Flags.COMMUNAL_SERVICE_ENABLED, true)
- underTest =
- CommunalOngoingContentStartable(
- bgScope = kosmos.applicationCoroutineScope,
- communalInteractor = kosmos.communalInteractor,
- communalMediaRepository = mediaRepository,
- communalSettingsInteractor = kosmos.communalSettingsInteractor,
- communalSmartspaceRepository = smartspaceRepository,
- )
}
@Test
- fun testListenForOngoingContentWhenCommunalIsEnabled() =
- testScope.runTest {
+ fun testListenForOngoingContent() =
+ kosmos.runTest {
+ underTest.start()
+
+ assertThat(fakeCommunalMediaRepository.isListening()).isFalse()
+ assertThat(fakeCommunalSmartspaceRepository.isListening()).isFalse()
+
+ kosmos.setCommunalEnabled(true)
+
+ assertThat(fakeCommunalMediaRepository.isListening()).isTrue()
+ assertThat(fakeCommunalSmartspaceRepository.isListening()).isTrue()
+
+ kosmos.setCommunalEnabled(false)
+
+ assertThat(fakeCommunalMediaRepository.isListening()).isFalse()
+ assertThat(fakeCommunalSmartspaceRepository.isListening()).isFalse()
+ }
+
+ @Test
+ fun testListenForOngoingContent_showUmoFalse() =
+ kosmos.runTest {
+ showUmoOnHub = false
underTest.start()
- runCurrent()
- assertThat(mediaRepository.isListening()).isFalse()
- assertThat(smartspaceRepository.isListening()).isFalse()
+ assertThat(fakeCommunalMediaRepository.isListening()).isFalse()
+ assertThat(fakeCommunalSmartspaceRepository.isListening()).isFalse()
kosmos.setCommunalEnabled(true)
- runCurrent()
- assertThat(mediaRepository.isListening()).isTrue()
- assertThat(smartspaceRepository.isListening()).isTrue()
+ // Media listening does not start when UMO is disabled.
+ assertThat(fakeCommunalMediaRepository.isListening()).isFalse()
+ assertThat(fakeCommunalSmartspaceRepository.isListening()).isTrue()
kosmos.setCommunalEnabled(false)
- runCurrent()
- assertThat(mediaRepository.isListening()).isFalse()
- assertThat(smartspaceRepository.isListening()).isFalse()
+ assertThat(fakeCommunalMediaRepository.isListening()).isFalse()
+ assertThat(fakeCommunalSmartspaceRepository.isListening()).isFalse()
}
}
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 8d10e393b5ca..0607dffa138d 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -1116,4 +1116,7 @@
<!-- Configuration to swipe to open glanceable hub -->
<bool name="config_swipeToOpenGlanceableHub">false</bool>
+
+ <!-- Whether or not to show the UMO on the glanceable hub when media is playing. -->
+ <bool name="config_showUmoOnHub">false</bool>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/communal/CommunalOngoingContentStartable.kt b/packages/SystemUI/src/com/android/systemui/communal/CommunalOngoingContentStartable.kt
index 48a6d9de380c..7765d0017c4e 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/CommunalOngoingContentStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/CommunalOngoingContentStartable.kt
@@ -16,7 +16,9 @@
package com.android.systemui.communal
+import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.CoreStartable
+import com.android.systemui.communal.dagger.CommunalModule.Companion.SHOW_UMO
import com.android.systemui.communal.data.repository.CommunalMediaRepository
import com.android.systemui.communal.data.repository.CommunalSmartspaceRepository
import com.android.systemui.communal.domain.interactor.CommunalInteractor
@@ -24,8 +26,8 @@ import com.android.systemui.communal.domain.interactor.CommunalSettingsInteracto
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import javax.inject.Inject
+import javax.inject.Named
import kotlinx.coroutines.CoroutineScope
-import com.android.app.tracing.coroutines.launchTraced as launch
@SysUISingleton
class CommunalOngoingContentStartable
@@ -36,6 +38,7 @@ constructor(
private val communalMediaRepository: CommunalMediaRepository,
private val communalSettingsInteractor: CommunalSettingsInteractor,
private val communalSmartspaceRepository: CommunalSmartspaceRepository,
+ @Named(SHOW_UMO) private val showUmoOnHub: Boolean,
) : CoreStartable {
override fun start() {
@@ -46,10 +49,14 @@ constructor(
bgScope.launch {
communalInteractor.isCommunalEnabled.collect { enabled ->
if (enabled) {
- communalMediaRepository.startListening()
+ if (showUmoOnHub) {
+ communalMediaRepository.startListening()
+ }
communalSmartspaceRepository.startListening()
} else {
- communalMediaRepository.stopListening()
+ if (showUmoOnHub) {
+ communalMediaRepository.stopListening()
+ }
communalSmartspaceRepository.stopListening()
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt
index ff741625a3cc..bb3be531aa8a 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt
@@ -105,6 +105,7 @@ interface CommunalModule {
const val LOGGABLE_PREFIXES = "loggable_prefixes"
const val LAUNCHER_PACKAGE = "launcher_package"
const val SWIPE_TO_HUB = "swipe_to_hub"
+ const val SHOW_UMO = "show_umo"
@Provides
@Communal
@@ -150,5 +151,11 @@ interface CommunalModule {
fun provideSwipeToHub(@Main resources: Resources): Boolean {
return resources.getBoolean(R.bool.config_swipeToOpenGlanceableHub)
}
+
+ @Provides
+ @Named(SHOW_UMO)
+ fun provideShowUmo(@Main resources: Resources): Boolean {
+ return resources.getBoolean(R.bool.config_showUmoOnHub)
+ }
}
}