summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Priyanka Advani <padvani@google.com> 2024-02-29 19:42:00 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-02-29 19:42:00 +0000
commitdb30837938e05dff4a16a95abfc6eacf3aa07541 (patch)
tree1278419c45124e7ba81683dab0e03cae617f743a
parenteb8bf79795c7ea46d19bd07fb880baf59497c92b (diff)
Revert "Implement UMO transitions to & from the communal hub"
This reverts commit eb8bf79795c7ea46d19bd07fb880baf59497c92b. Reason for revert: Probable culprit for b/327643568. Will be verifying through ABTD for confirmation and before submitting the revert. Change-Id: I702c9347db7e76ad34d09a87dcd3cf97d9ce7dbd
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalTransitionViewModel.kt58
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DreamingToGlanceableHubTransitionViewModel.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToDreamingTransitionViewModel.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToLockscreenTransitionViewModel.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToGlanceableHubTransitionViewModel.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt14
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt29
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/communal/ui/viewmodel/CommunalTransitionViewModelKosmos.kt24
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/communal/ui/viewmodel/FakeCommunalTransitionViewModel.kt29
10 files changed, 30 insertions, 157 deletions
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 a02c5ce8bb14..82d943796e2a 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt
@@ -23,8 +23,6 @@ import com.android.systemui.communal.data.repository.CommunalRepositoryModule
import com.android.systemui.communal.data.repository.CommunalSettingsRepositoryModule
import com.android.systemui.communal.data.repository.CommunalTutorialRepositoryModule
import com.android.systemui.communal.data.repository.CommunalWidgetRepositoryModule
-import com.android.systemui.communal.ui.viewmodel.CommunalTransitionViewModel
-import com.android.systemui.communal.ui.viewmodel.CommunalTransitionViewModelImpl
import com.android.systemui.communal.widgets.CommunalWidgetModule
import com.android.systemui.communal.widgets.EditWidgetsActivityStarter
import com.android.systemui.communal.widgets.EditWidgetsActivityStarterImpl
@@ -49,9 +47,4 @@ interface CommunalModule {
fun bindEditWidgetsActivityStarter(
starter: EditWidgetsActivityStarterImpl
): EditWidgetsActivityStarter
-
- @Binds
- fun bindCommunalTransitionViewModel(
- impl: CommunalTransitionViewModelImpl
- ): CommunalTransitionViewModel
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalTransitionViewModel.kt
deleted file mode 100644
index eed0aa397b65..000000000000
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalTransitionViewModel.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.ui.viewmodel
-
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.keyguard.ui.viewmodel.DreamingToGlanceableHubTransitionViewModel
-import com.android.systemui.keyguard.ui.viewmodel.GlanceableHubToDreamingTransitionViewModel
-import com.android.systemui.keyguard.ui.viewmodel.GlanceableHubToLockscreenTransitionViewModel
-import com.android.systemui.keyguard.ui.viewmodel.LockscreenToGlanceableHubTransitionViewModel
-import javax.inject.Inject
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.distinctUntilChanged
-import kotlinx.coroutines.flow.merge
-
-/** View model for transitions related to the communal hub. */
-interface CommunalTransitionViewModel {
- val isUmoOnCommunal: Flow<Boolean>
-}
-
-@OptIn(ExperimentalCoroutinesApi::class)
-@SysUISingleton
-class CommunalTransitionViewModelImpl
-@Inject
-constructor(
- glanceableHubToLockscreenTransitionViewModel: GlanceableHubToLockscreenTransitionViewModel,
- lockscreenToGlanceableHubTransitionViewModel: LockscreenToGlanceableHubTransitionViewModel,
- dreamToGlanceableHubTransitionViewModel: DreamingToGlanceableHubTransitionViewModel,
- glanceableHubToDreamTransitionViewModel: GlanceableHubToDreamingTransitionViewModel,
-) : CommunalTransitionViewModel {
- /**
- * Whether UMO location should be on communal. This flow is responsive to transitions so that a
- * new value is emitted at the right step of a transition to/from communal hub that the location
- * of UMO should be updated.
- */
- override val isUmoOnCommunal: Flow<Boolean> =
- merge(
- lockscreenToGlanceableHubTransitionViewModel.showUmo,
- glanceableHubToLockscreenTransitionViewModel.showUmo,
- dreamToGlanceableHubTransitionViewModel.showUmo,
- glanceableHubToDreamTransitionViewModel.showUmo,
- )
- .distinctUntilChanged()
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DreamingToGlanceableHubTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DreamingToGlanceableHubTransitionViewModel.kt
index 5cb2ec9642b9..c64f277b519a 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DreamingToGlanceableHubTransitionViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DreamingToGlanceableHubTransitionViewModel.kt
@@ -28,7 +28,6 @@ import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.map
@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
@@ -66,15 +65,6 @@ constructor(
name = "DREAMING->GLANCEABLE_HUB: dreamOverlayAlpha",
)
- // Show UMO once the transition starts.
- val showUmo: Flow<Boolean> =
- transitionAnimation
- .sharedFlow(
- duration = TO_GLANCEABLE_HUB_DURATION,
- onStep = { it },
- )
- .map { step -> step != 0f }
-
private companion object {
val TO_GLANCEABLE_HUB_DURATION = 1.seconds
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToDreamingTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToDreamingTransitionViewModel.kt
index 90be4f904105..478c4faa1be3 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToDreamingTransitionViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToDreamingTransitionViewModel.kt
@@ -28,7 +28,6 @@ import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.map
@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
@@ -67,15 +66,6 @@ constructor(
)
}
- // Show UMO until transition finishes.
- val showUmo: Flow<Boolean> =
- transitionAnimation
- .sharedFlow(
- duration = FROM_GLANCEABLE_HUB_DURATION,
- onStep = { it },
- )
- .map { step -> step != 1f }
-
private companion object {
val FROM_GLANCEABLE_HUB_DURATION = 1.seconds
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToLockscreenTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToLockscreenTransitionViewModel.kt
index f81598f717b0..e5b596419efe 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToLockscreenTransitionViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GlanceableHubToLockscreenTransitionViewModel.kt
@@ -64,9 +64,6 @@ constructor(
)
.onStart { emit(0f) }
- // Show UMO as long as keyguard is not visible.
- val showUmo: Flow<Boolean> = keyguardAlpha.map { alpha -> alpha == 0f }
-
val keyguardTranslationX: Flow<StateToValue> =
configurationInteractor
.dimensionPixelSize(R.dimen.hub_to_lockscreen_transition_lockscreen_translation_x)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToGlanceableHubTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToGlanceableHubTransitionViewModel.kt
index 0c33e18d0113..978e71e2a825 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToGlanceableHubTransitionViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToGlanceableHubTransitionViewModel.kt
@@ -63,9 +63,6 @@ constructor(
)
.onStart { emit(1f) }
- // Show UMO as long as keyguard is not visible.
- val showUmo: Flow<Boolean> = keyguardAlpha.map { alpha -> alpha == 0f }
-
val keyguardTranslationX: Flow<StateToValue> =
configurationInteractor
.dimensionPixelSize(R.dimen.lockscreen_to_hub_transition_lockscreen_translation_x)
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
index a4f3e2174791..dbd71f3e3a04 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
@@ -36,7 +36,7 @@ import androidx.annotation.VisibleForTesting
import com.android.app.animation.Interpolators
import com.android.app.tracing.traceSection
import com.android.keyguard.KeyguardViewController
-import com.android.systemui.communal.ui.viewmodel.CommunalTransitionViewModel
+import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
@@ -58,6 +58,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.policy.SplitShadeStateController
import com.android.systemui.util.animation.UniqueObjectHostView
+import com.android.systemui.util.kotlin.BooleanFlowOperators.and
import com.android.systemui.util.settings.SecureSettings
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -101,7 +102,7 @@ constructor(
private val mediaManager: MediaDataManager,
private val keyguardViewController: KeyguardViewController,
private val dreamOverlayStateController: DreamOverlayStateController,
- communalTransitionViewModel: CommunalTransitionViewModel,
+ private val communalInteractor: CommunalInteractor,
configurationController: ConfigurationController,
wakefulnessLifecycle: WakefulnessLifecycle,
shadeInteractor: ShadeInteractor,
@@ -586,10 +587,11 @@ constructor(
// Listen to the communal UI state. Make sure that communal UI is showing and hub itself is
// available, ie. not disabled and able to be shown.
coroutineScope.launch {
- communalTransitionViewModel.isUmoOnCommunal.collect { value ->
- isCommunalShowing = value
- updateDesiredLocation(forceNoAnimation = true)
- }
+ and(communalInteractor.isCommunalShowing, communalInteractor.isCommunalAvailable)
+ .collect { value ->
+ isCommunalShowing = value
+ updateDesiredLocation()
+ }
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt
index fa28036f274b..45f49f01a43e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt
@@ -24,8 +24,11 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.test.filters.SmallTest
import com.android.keyguard.KeyguardViewController
+import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
-import com.android.systemui.communal.ui.viewmodel.fakeCommunalTransitionViewModel
+import com.android.systemui.communal.domain.interactor.communalInteractor
+import com.android.systemui.communal.domain.interactor.setCommunalAvailable
+import com.android.systemui.communal.shared.model.CommunalSceneKey
import com.android.systemui.controls.controller.ControlsControllerImplTest.Companion.eq
import com.android.systemui.dreams.DreamOverlayStateController
import com.android.systemui.keyguard.WakefulnessLifecycle
@@ -112,10 +115,10 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
private lateinit var isQsBypassingShade: MutableStateFlow<Boolean>
private lateinit var mediaFrame: ViewGroup
private val configurationController = FakeConfigurationController()
+ private val communalInteractor = kosmos.communalInteractor
private val settings = FakeSettings()
private lateinit var testableLooper: TestableLooper
private lateinit var fakeHandler: FakeHandler
- private var communalTransitionViewModel = kosmos.fakeCommunalTransitionViewModel
@Before
fun setup() {
@@ -139,7 +142,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
mediaDataManager,
keyguardViewController,
dreamOverlayStateController,
- communalTransitionViewModel,
+ communalInteractor,
configurationController,
wakefulnessLifecycle,
shadeInteractor,
@@ -507,7 +510,11 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
@Test
fun testCommunalLocation() =
testScope.runTest {
- communalTransitionViewModel.setIsUmoOnCommunal(true)
+ mSetFlagsRule.enableFlags(Flags.FLAG_COMMUNAL_HUB)
+ kosmos.setCommunalAvailable(true)
+ runCurrent()
+
+ communalInteractor.onSceneChanged(CommunalSceneKey.Communal)
runCurrent()
verify(mediaCarouselController)
.onDesiredLocationChanged(
@@ -519,7 +526,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
)
clearInvocations(mediaCarouselController)
- communalTransitionViewModel.setIsUmoOnCommunal(false)
+ communalInteractor.onSceneChanged(CommunalSceneKey.Blank)
runCurrent()
verify(mediaCarouselController)
.onDesiredLocationChanged(
@@ -534,11 +541,15 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
@Test
fun testCommunalLocation_showsOverLockscreen() =
testScope.runTest {
+ mSetFlagsRule.enableFlags(Flags.FLAG_COMMUNAL_HUB)
+ kosmos.setCommunalAvailable(true)
+ runCurrent()
+
// Device is on lock screen.
whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD)
// UMO goes to communal even over the lock screen.
- communalTransitionViewModel.setIsUmoOnCommunal(true)
+ communalInteractor.onSceneChanged(CommunalSceneKey.Communal)
runCurrent()
verify(mediaCarouselController)
.onDesiredLocationChanged(
@@ -553,10 +564,14 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
@Test
fun testCommunalLocation_showsUntilQsExpands() =
testScope.runTest {
+ mSetFlagsRule.enableFlags(Flags.FLAG_COMMUNAL_HUB)
+ kosmos.setCommunalAvailable(true)
+ runCurrent()
+
// Device is on lock screen.
whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD)
- communalTransitionViewModel.setIsUmoOnCommunal(true)
+ communalInteractor.onSceneChanged(CommunalSceneKey.Communal)
runCurrent()
verify(mediaCarouselController)
.onDesiredLocationChanged(
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/ui/viewmodel/CommunalTransitionViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/ui/viewmodel/CommunalTransitionViewModelKosmos.kt
deleted file mode 100644
index eaa657b76c3d..000000000000
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/ui/viewmodel/CommunalTransitionViewModelKosmos.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.ui.viewmodel
-
-import com.android.systemui.kosmos.Kosmos
-
-val Kosmos.communalTransitionViewModel by
- Kosmos.Fixture<CommunalTransitionViewModel> { fakeCommunalTransitionViewModel }
-
-val Kosmos.fakeCommunalTransitionViewModel by Kosmos.Fixture { FakeCommunalTransitionViewModel() }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/ui/viewmodel/FakeCommunalTransitionViewModel.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/ui/viewmodel/FakeCommunalTransitionViewModel.kt
deleted file mode 100644
index 409cc1d03fda..000000000000
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/ui/viewmodel/FakeCommunalTransitionViewModel.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.ui.viewmodel
-
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.MutableStateFlow
-
-class FakeCommunalTransitionViewModel : CommunalTransitionViewModel {
- private val _isUmoOnCommunal = MutableStateFlow(false)
- override val isUmoOnCommunal: Flow<Boolean> = _isUmoOnCommunal
-
- fun setIsUmoOnCommunal(value: Boolean) {
- _isUmoOnCommunal.value = value
- }
-}