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

Commit 4dd9f772 authored by William Xiao's avatar William Xiao
Browse files

Only allow hub mode to show when keyguard is visible

Since the hub mode SceneTransitionLayout is in the notification shade
window, it's currently accessible when the notification shade is open,
even if the device is unlocked or an activity is open.

This CL hides the SceneTransitionLayout when keyguard is not visible.
Future CLs will also allow the SceneTransitionLayout to show on top of
the dream.

Bug: 308813166
Flag: ACONFIG com.android.systemui.communal_hub DEVELOPMENT
Test: manually verified on device
Change-Id: I80b8a4020016d476c758e3a78e4c78c6d89b89e2
parent e55af2dd
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -65,10 +65,13 @@ fun CommunalContainer(
        viewModel.currentScene
        viewModel.currentScene
            .transform<CommunalSceneKey, SceneKey> { value -> value.toTransitionSceneKey() }
            .transform<CommunalSceneKey, SceneKey> { value -> value.toTransitionSceneKey() }
            .collectAsState(TransitionSceneKey.Blank)
            .collectAsState(TransitionSceneKey.Blank)
    // Don't show hub mode UI if keyguard is present. This is important since we're in the shade,
    // which can be opened from many locations.
    val isKeyguardShowing by viewModel.isKeyguardVisible.collectAsState(initial = false)


    // Failsafe to hide the whole SceneTransitionLayout in case of bugginess.
    // Failsafe to hide the whole SceneTransitionLayout in case of bugginess.
    var showSceneTransitionLayout by remember { mutableStateOf(true) }
    var showSceneTransitionLayout by remember { mutableStateOf(true) }
    if (!showSceneTransitionLayout) {
    if (!showSceneTransitionLayout || !isKeyguardShowing) {
        return
        return
    }
    }


+4 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.communal.shared.model.CommunalContentSize
import com.android.systemui.communal.shared.model.CommunalSceneKey
import com.android.systemui.communal.shared.model.CommunalSceneKey
import com.android.systemui.communal.widgets.EditWidgetsActivityStarter
import com.android.systemui.communal.widgets.EditWidgetsActivityStarter
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.smartspace.data.repository.SmartspaceRepository
import com.android.systemui.smartspace.data.repository.SmartspaceRepository
import javax.inject.Inject
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -46,6 +47,7 @@ constructor(
    private val widgetRepository: CommunalWidgetRepository,
    private val widgetRepository: CommunalWidgetRepository,
    mediaRepository: CommunalMediaRepository,
    mediaRepository: CommunalMediaRepository,
    smartspaceRepository: SmartspaceRepository,
    smartspaceRepository: SmartspaceRepository,
    keyguardInteractor: KeyguardInteractor,
    private val appWidgetHost: AppWidgetHost,
    private val appWidgetHost: AppWidgetHost,
    private val editWidgetsActivityStarter: EditWidgetsActivityStarter
    private val editWidgetsActivityStarter: EditWidgetsActivityStarter
) {
) {
@@ -67,6 +69,8 @@ constructor(
    val isCommunalShowing: Flow<Boolean> =
    val isCommunalShowing: Flow<Boolean> =
        communalRepository.desiredScene.map { it == CommunalSceneKey.Communal }
        communalRepository.desiredScene.map { it == CommunalSceneKey.Communal }


    val isKeyguardVisible: Flow<Boolean> = keyguardInteractor.isKeyguardVisible

    /** Callback received whenever the [SceneTransitionLayout] finishes a scene transition. */
    /** Callback received whenever the [SceneTransitionLayout] finishes a scene transition. */
    fun onSceneChanged(newScene: CommunalSceneKey) {
    fun onSceneChanged(newScene: CommunalSceneKey) {
        communalRepository.setDesiredScene(newScene)
        communalRepository.setDesiredScene(newScene)
+2 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,8 @@ abstract class BaseCommunalViewModel(
    private val communalInteractor: CommunalInteractor,
    private val communalInteractor: CommunalInteractor,
    val mediaHost: MediaHost,
    val mediaHost: MediaHost,
) {
) {
    val isKeyguardVisible: Flow<Boolean> = communalInteractor.isKeyguardVisible

    val currentScene: StateFlow<CommunalSceneKey> = communalInteractor.desiredScene
    val currentScene: StateFlow<CommunalSceneKey> = communalInteractor.desiredScene


    fun onSceneChanged(scene: CommunalSceneKey) {
    fun onSceneChanged(scene: CommunalSceneKey) {
+0 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,6 @@ constructor(
    tutorialInteractor: CommunalTutorialInteractor,
    tutorialInteractor: CommunalTutorialInteractor,
    @Named(MediaModule.COMMUNAL_HUB) mediaHost: MediaHost,
    @Named(MediaModule.COMMUNAL_HUB) mediaHost: MediaHost,
) : BaseCommunalViewModel(communalInteractor, mediaHost) {
) : BaseCommunalViewModel(communalInteractor, mediaHost) {

    @OptIn(ExperimentalCoroutinesApi::class)
    @OptIn(ExperimentalCoroutinesApi::class)
    override val communalContent: Flow<List<CommunalContentModel>> =
    override val communalContent: Flow<List<CommunalContentModel>> =
        tutorialInteractor.isTutorialAvailable.flatMapLatest { isTutorialMode ->
        tutorialInteractor.isTutorialAvailable.flatMapLatest { isTutorialMode ->
+1 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,7 @@ object CommunalInteractorFactory {
                widgetRepository,
                widgetRepository,
                mediaRepository,
                mediaRepository,
                smartspaceRepository,
                smartspaceRepository,
                withDeps.keyguardInteractor,
                appWidgetHost,
                appWidgetHost,
                editWidgetsActivityStarter,
                editWidgetsActivityStarter,
            ),
            ),