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

Commit 0c650462 authored by Ioana Alexandru's avatar Ioana Alexandru Committed by Android (Google) Code Review
Browse files

Merge "Dump latest flow values from NotificationListVM" into main

parents 2429135e e6d98e63
Loading
Loading
Loading
Loading
+36 −16
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.stack.ui.viewmodel

import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.domain.interactor.RemoteInputInteractor
@@ -31,6 +32,7 @@ import com.android.systemui.statusbar.notification.shelf.ui.viewmodel.Notificati
import com.android.systemui.statusbar.notification.stack.domain.interactor.NotificationStackInteractor
import com.android.systemui.statusbar.policy.domain.interactor.UserSetupInteractor
import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor
import com.android.systemui.util.kotlin.FlowDumperImpl
import com.android.systemui.util.kotlin.sample
import com.android.systemui.util.ui.AnimatableEvent
import com.android.systemui.util.ui.AnimatedValue
@@ -64,7 +66,8 @@ constructor(
    userSetupInteractor: UserSetupInteractor,
    zenModeInteractor: ZenModeInteractor,
    @Background bgDispatcher: CoroutineDispatcher,
) {
    dumpManager: DumpManager,
) : FlowDumperImpl(dumpManager) {
    /**
     * We want the NSSL to be unimportant for accessibility when there are no notifications in it
     * while the device is on lock screen, to avoid an unlabelled NSSL view in TalkBack. Otherwise,
@@ -81,8 +84,9 @@ constructor(
                ) { hasNotifications, isShowingOnLockscreen ->
                    hasNotifications || !isShowingOnLockscreen
                }
                .flowOn(bgDispatcher)
                .distinctUntilChanged()
                .dumpWhileCollecting("isImportantForAccessibility")
                .flowOn(bgDispatcher)
        }
    }

@@ -105,8 +109,9 @@ constructor(
                        else -> true
                    }
                }
                .flowOn(bgDispatcher)
                .distinctUntilChanged()
                .dumpWhileCollecting("shouldShowEmptyShadeView")
                .flowOn(bgDispatcher)
        }
    }

@@ -125,8 +130,9 @@ constructor(
            // the footer to be counted as part of the shade for measurements.
            shadeInteractor.shadeExpansion
                .map { it == 0f }
                .flowOn(bgDispatcher)
                .distinctUntilChanged()
                .dumpWhileCollecting("shouldHideFooterView")
                .flowOn(bgDispatcher)
        }
    }

@@ -173,7 +179,6 @@ constructor(
                        else -> VisibilityChange.APPEAR_WITH_ANIMATION
                    }
                }
                .flowOn(bgDispatcher)
                .distinctUntilChanged(
                    // Equivalent unless visibility changes
                    areEquivalent = { a: VisibilityChange, b: VisibilityChange ->
@@ -199,6 +204,8 @@ constructor(
                    AnimatableEvent(visibilityChange.visible, shouldAnimate)
                }
                .toAnimatedValueFlow()
                .dumpWhileCollecting("shouldIncludeFooterView")
                .flowOn(bgDispatcher)
        }
    }

@@ -213,7 +220,9 @@ constructor(
        if (FooterViewRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(false)
        } else {
            zenModeInteractor.areNotificationsHiddenInShade
            zenModeInteractor.areNotificationsHiddenInShade.dumpWhileCollecting(
                "areNotificationsHiddenInShade"
            )
        }
    }

@@ -222,7 +231,9 @@ constructor(
        if (FooterViewRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(false)
        } else {
            seenNotificationsInteractor.hasFilteredOutSeenNotifications
            seenNotificationsInteractor.hasFilteredOutSeenNotifications.dumpWhileCollecting(
                "hasFilteredOutSeenNotifications"
            )
        }
    }

@@ -230,7 +241,9 @@ constructor(
        if (FooterViewRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(false)
        } else {
            activeNotificationsInteractor.hasClearableAlertingNotifications
            activeNotificationsInteractor.hasClearableAlertingNotifications.dumpWhileCollecting(
                "hasClearableAlertingNotifications"
            )
        }
    }

@@ -238,7 +251,9 @@ constructor(
        if (FooterViewRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(false)
        } else {
            activeNotificationsInteractor.hasNonClearableSilentNotifications
            activeNotificationsInteractor.hasNonClearableSilentNotifications.dumpWhileCollecting(
                "hasNonClearableSilentNotifications"
            )
        }
    }

@@ -246,7 +261,7 @@ constructor(
        if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(null)
        } else {
            headsUpNotificationInteractor.topHeadsUpRow
            headsUpNotificationInteractor.topHeadsUpRow.dumpWhileCollecting("topHeadsUpRow")
        }
    }

@@ -254,23 +269,28 @@ constructor(
        if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(emptySet())
        } else {
            headsUpNotificationInteractor.pinnedHeadsUpRows
            headsUpNotificationInteractor.pinnedHeadsUpRows.dumpWhileCollecting("pinnedHeadsUpRows")
        }
    }

    val headsUpAnimationsEnabled: Flow<Boolean> by lazy {
        if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(false)
        } else {
            combine(keyguardInteractor.isKeyguardShowing, shadeInteractor.isShadeFullyExpanded) {
                    (isKeyguardShowing, isShadeFullyExpanded) ->
                    // TODO(b/325936094) use isShadeFullyCollapsed instead
                    !isKeyguardShowing && !isShadeFullyExpanded
                }
                .dumpWhileCollecting("headsUpAnimationsEnabled")
        }
    }

    val hasPinnedHeadsUpRow: Flow<Boolean> by lazy {
        if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) {
            flowOf(false)
        } else {
            headsUpNotificationInteractor.hasPinnedRows
            headsUpNotificationInteractor.hasPinnedRows.dumpWhileCollecting("hasPinnedHeadsUpRow")
        }
    }

+0 −8
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.notification.ui.viewbinder

import android.util.Log
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.shared.HeadsUpRowKey
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
@@ -26,9 +25,6 @@ import javax.inject.Inject
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch

private const val TAG = "HunBinder"
private val DEBUG = true // Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG)

class HeadsUpNotificationViewBinder
@Inject
constructor(private val viewModel: NotificationListViewModel) {
@@ -39,10 +35,6 @@ constructor(private val viewModel: NotificationListViewModel) {
                viewModel.pinnedHeadsUpRows
                    .sample(viewModel.headsUpAnimationsEnabled, ::Pair)
                    .collect { (newKeys, animationsEnabled) ->
                        if (DEBUG) {
                            Log.d(TAG, "update:$newKeys")
                        }

                        val added = newKeys - previousKeys
                        val removed = previousKeys - newKeys
                        previousKeys = newKeys
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification.stack.ui.viewmodel

import com.android.systemui.dump.dumpManager
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
@@ -48,5 +49,6 @@ val Kosmos.notificationListViewModel by Fixture {
        userSetupInteractor,
        zenModeInteractor,
        testDispatcher,
        dumpManager,
    )
}