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

Commit 89a8dc6a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move EmptyShadeViewModel flows to the bg" into main

parents dc322046 515ac3e4
Loading
Loading
Loading
Loading
+47 −36
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.statusbar.notification.emptyshade.ui.viewmodel

import android.content.Context
import android.icu.text.MessageFormat
import com.android.app.tracing.coroutines.flow.flowOn
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dump.DumpManager
import com.android.systemui.modes.shared.ModesUi
import com.android.systemui.res.R
@@ -32,6 +34,7 @@ import com.android.systemui.util.kotlin.FlowDumperImpl
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.util.Locale
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
@@ -50,11 +53,16 @@ constructor(
    zenModeInteractor: ZenModeInteractor,
    seenNotificationsInteractor: SeenNotificationsInteractor,
    notificationSettingsInteractor: NotificationSettingsInteractor,
    @Background bgDispatcher: CoroutineDispatcher,
    dumpManager: DumpManager,
) : FlowDumperImpl(dumpManager) {
    val areNotificationsHiddenInShade: Flow<Boolean> by lazy {
        if (FooterViewRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(false)
        } else if (ModesEmptyShadeFix.isEnabled) {
            zenModeInteractor.areNotificationsHiddenInShade
                .dumpWhileCollecting("areNotificationsHiddenInShade")
                .flowOn(bgDispatcher)
        } else {
            zenModeInteractor.areNotificationsHiddenInShade.dumpWhileCollecting(
                "areNotificationsHiddenInShade"
@@ -81,7 +89,8 @@ constructor(
            // The former does not depend on the modes flags being on, but the latter does.
            if (ModesUi.isEnabled) {
                    zenModeInteractor.modesHidingNotifications.map { modes ->
                    // Create a string that is either "No notifications" if no modes are filtering
                        // Create a string that is either "No notifications" if no modes are
                        // filtering
                        // them out, or something like "Notifications paused by SomeMode" otherwise.
                        val msgFormat =
                            MessageFormat(
@@ -105,6 +114,7 @@ constructor(
                        }
                    }
                }
                .flowOn(bgDispatcher)
        }
    }

@@ -137,6 +147,7 @@ constructor(
                    }
                }
            }
            .flowOn(bgDispatcher)
    }

    @AssistedFactory
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.emptyshade.ui.viewmodel
import android.content.applicationContext
import com.android.systemui.dump.dumpManager
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.shared.notifications.domain.interactor.notificationSettingsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.seenNotificationsInteractor
import com.android.systemui.statusbar.policy.domain.interactor.zenModeInteractor
@@ -30,6 +31,7 @@ val Kosmos.emptyShadeViewModel by
            zenModeInteractor,
            seenNotificationsInteractor,
            notificationSettingsInteractor,
            testDispatcher,
            dumpManager,
        )
    }