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

Commit 515ac3e4 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Move EmptyShadeViewModel flows to the bg

Bug: 371134540
Bug: 366003631
Test: v2/android-crystalball-eng/health/microbench/systemui/main/systemui-quicksettings-2-jank-suite
Flag: android.app.modes_ui_empty_shade
Flag: android.app.modes_ui
Change-Id: Ida1966cdfa70683dd866edd83b6d2631c1cfb4b8
parent d86c1436
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,
        )
    }