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

Commit 028c27bb authored by Lucas Silva's avatar Lucas Silva
Browse files

Only transition to GH from dreaming if charging/postured/docked

If the device is picked up while dreaming, the dream will remain on the
screen. This ensures we go to lockscreen when the user exits the dream
instead of going to hub if they are no longer charging/postured/docked.

Bug: 383208131
Test: mp droid and verified dream exit behavior
Flag: com.android.systemui.glanceable_hub_v2
Change-Id: Ie6cc079b829c2615abe4dd368beae865f851ac2a
parent 94d9720e
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ constructor(
     * Whether communal hub should be shown automatically, depending on the user's [WhenToDream]
     * state.
     */
    val shouldShowCommunal: Flow<Boolean> =
    val shouldShowCommunal: StateFlow<Boolean> =
        allOf(
                isCommunalAvailable,
                communalSettingsInteractor.whenToDream
@@ -204,11 +204,15 @@ constructor(
                                )

                            WhenToDream.WHILE_POSTURED ->
                            allOf(batteryInteractor.isDevicePluggedIn, posturingInteractor.postured)
                                allOf(
                                    batteryInteractor.isDevicePluggedIn,
                                    posturingInteractor.postured,
                                )
                        }
                    }
                    .flowOn(bgDispatcher),
            )
            .stateIn(scope = bgScope, started = SharingStarted.Eagerly, initialValue = false)

    private val _isDisclaimerDismissed = MutableStateFlow(false)
    val isDisclaimerDismissed: Flow<Boolean> = _isDisclaimerDismissed.asStateFlow()
+8 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming
import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.FromDreamingTransitionInteractor
@@ -51,6 +52,7 @@ constructor(
    private val toLockscreenTransitionViewModel: DreamingToLockscreenTransitionViewModel,
    private val fromDreamingTransitionInteractor: FromDreamingTransitionInteractor,
    private val communalInteractor: CommunalInteractor,
    private val communalSettingsInteractor: CommunalSettingsInteractor,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    private val userTracker: UserTracker,
    dumpManager: DumpManager,
@@ -58,8 +60,12 @@ constructor(

    fun startTransitionFromDream() {
        val showGlanceableHub =
            if (communalSettingsInteractor.isV2FlagEnabled()) {
                communalInteractor.shouldShowCommunal.value
            } else {
                communalInteractor.isCommunalEnabled.value &&
                    !keyguardUpdateMonitor.isEncryptedOrLockdown(userTracker.userId)
            }
        fromDreamingTransitionInteractor.startToLockscreenOrGlanceableHubTransition(
            showGlanceableHub && !glanceableHubAllowKeyguardWhenDreaming()
        )