Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/RenderNotificationListInteractor.kt +16 −1 Original line number Diff line number Diff line Loading @@ -15,12 +15,14 @@ */ package com.android.systemui.statusbar.notification.domain.interactor import android.app.Notification import android.app.Notification.CallStyle.CALL_TYPE_INCOMING import android.app.Notification.CallStyle.CALL_TYPE_ONGOING import android.app.Notification.CallStyle.CALL_TYPE_SCREENING import android.app.Notification.CallStyle.CALL_TYPE_UNKNOWN import android.app.Notification.EXTRA_CALL_TYPE import android.app.Notification.FLAG_ONGOING_EVENT import android.app.Notification.MessagingStyle import android.app.PendingIntent import android.content.Context import android.graphics.drawable.Icon Loading @@ -46,6 +48,7 @@ import com.android.systemui.statusbar.notification.shared.ActiveNotificationEntr import com.android.systemui.statusbar.notification.shared.ActiveNotificationGroupModel import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.notification.shared.CallType import com.android.systemui.statusbar.notification.shared.NotifStyle import javax.inject.Inject import kotlinx.coroutines.flow.update Loading Loading @@ -220,7 +223,8 @@ private class ActiveNotificationsStoreBuilder( bucket = bucket, callType = sbn.toCallType(), promotedContent = promotedContent, requestedPromotion = sbn.notification.isRequestPromotedOngoing(), requestedPromotion = sbn.notification.isRequestPromotedOngoing, notifStyle = notifStyle(sbn.notification), ) } } Loading Loading @@ -251,6 +255,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif( callType: CallType, promotedContent: PromotedNotificationContentModels?, requestedPromotion: Boolean, notifStyle: NotifStyle?, ): ActiveNotificationModel { return individuals[key]?.takeIf { it.isCurrent( Loading Loading @@ -279,6 +284,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif( callType = callType, promotedContent = promotedContent, requestedPromotion = requestedPromotion, style = notifStyle, ) } ?: ActiveNotificationModel( Loading Loading @@ -307,6 +313,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif( callType = callType, promotedContent = promotedContent, requestedPromotion = requestedPromotion, style = notifStyle, ) } Loading Loading @@ -336,6 +343,7 @@ private fun ActiveNotificationModel.isCurrent( callType: CallType, promotedContent: PromotedNotificationContentModels?, requestedPromotion: Boolean, style: NotifStyle?, ): Boolean { return when { key != this.key -> false Loading Loading @@ -365,6 +373,7 @@ private fun ActiveNotificationModel.isCurrent( // recreating the active notification model constantly? promotedContent != this.promotedContent -> false requestedPromotion != this.requestedPromotion -> false style != this.style -> false else -> true } } Loading Loading @@ -434,3 +443,9 @@ private fun hasSameInstances(list1: List<*>, list2: List<*>): Boolean { } return true } private fun notifStyle(notif: Notification): NotifStyle? = when { notif.isStyle(MessagingStyle::class.java) -> NotifStyle.Messaging() else -> null } packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/ActiveNotificationModel.kt +10 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,8 @@ data class ActiveNotificationModel( val promotedContent: PromotedNotificationContentModels?, /** True if this notification set the "requested promotion?" extra and false otherwise. */ val requestedPromotion: Boolean, /** The visual style of the notification, containing additional data relevant to that style. */ val style: NotifStyle?, ) : ActiveNotificationEntryModel() { init { if (!PromotedNotificationContentModel.featureFlagEnabled()) { Loading Loading @@ -143,3 +145,11 @@ enum class CallType { /** See [android.app.Notification.CallStyle.CALL_TYPE_UNKNOWN]. */ Unknown, } /** Style-specific data for [ActiveNotificationModel] */ sealed class NotifStyle { /** * Data pertaining to [messaging style][android.app.Notification.MessagingStyle] notifications. */ class Messaging : NotifStyle() } packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SummarizationOnboardingInteractor.kt +5 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.util.Log import androidx.core.content.edit import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository import com.android.systemui.statusbar.notification.shared.NotifStyle import com.android.systemui.user.domain.interactor.SelectedUserInteractor import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.SharedPreferencesExt.observeBoolean Loading @@ -47,7 +48,10 @@ constructor( ) { private val notifsPresent: Flow<Boolean> = notifListRepo.activeNotifications .map { store -> store.renderList.isNotEmpty() } .map { store -> store.renderList.isNotEmpty() && store.individuals.any { (_, notif) -> notif.style is NotifStyle.Messaging } } .distinctUntilChanged() private val onboardingUnseen: Flow<Boolean> = Loading packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/model/ActiveNotificationModelBuilder.kt +3 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.notification.shared.CallType import com.android.systemui.statusbar.notification.shared.NotifStyle import com.android.systemui.statusbar.notification.stack.BUCKET_UNKNOWN /** Simple ActiveNotificationModel builder for use in tests. */ Loading Loading @@ -52,6 +53,7 @@ fun activeNotificationModel( callType: CallType = CallType.None, requestedPromotion: Boolean = false, promotedContent: PromotedNotificationContentModels? = null, notifStyle: NotifStyle? = null, ) = ActiveNotificationModel( key = key, Loading Loading @@ -79,4 +81,5 @@ fun activeNotificationModel( callType = callType, requestedPromotion = requestedPromotion, promotedContent = promotedContent, style = notifStyle, ) Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/RenderNotificationListInteractor.kt +16 −1 Original line number Diff line number Diff line Loading @@ -15,12 +15,14 @@ */ package com.android.systemui.statusbar.notification.domain.interactor import android.app.Notification import android.app.Notification.CallStyle.CALL_TYPE_INCOMING import android.app.Notification.CallStyle.CALL_TYPE_ONGOING import android.app.Notification.CallStyle.CALL_TYPE_SCREENING import android.app.Notification.CallStyle.CALL_TYPE_UNKNOWN import android.app.Notification.EXTRA_CALL_TYPE import android.app.Notification.FLAG_ONGOING_EVENT import android.app.Notification.MessagingStyle import android.app.PendingIntent import android.content.Context import android.graphics.drawable.Icon Loading @@ -46,6 +48,7 @@ import com.android.systemui.statusbar.notification.shared.ActiveNotificationEntr import com.android.systemui.statusbar.notification.shared.ActiveNotificationGroupModel import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.notification.shared.CallType import com.android.systemui.statusbar.notification.shared.NotifStyle import javax.inject.Inject import kotlinx.coroutines.flow.update Loading Loading @@ -220,7 +223,8 @@ private class ActiveNotificationsStoreBuilder( bucket = bucket, callType = sbn.toCallType(), promotedContent = promotedContent, requestedPromotion = sbn.notification.isRequestPromotedOngoing(), requestedPromotion = sbn.notification.isRequestPromotedOngoing, notifStyle = notifStyle(sbn.notification), ) } } Loading Loading @@ -251,6 +255,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif( callType: CallType, promotedContent: PromotedNotificationContentModels?, requestedPromotion: Boolean, notifStyle: NotifStyle?, ): ActiveNotificationModel { return individuals[key]?.takeIf { it.isCurrent( Loading Loading @@ -279,6 +284,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif( callType = callType, promotedContent = promotedContent, requestedPromotion = requestedPromotion, style = notifStyle, ) } ?: ActiveNotificationModel( Loading Loading @@ -307,6 +313,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif( callType = callType, promotedContent = promotedContent, requestedPromotion = requestedPromotion, style = notifStyle, ) } Loading Loading @@ -336,6 +343,7 @@ private fun ActiveNotificationModel.isCurrent( callType: CallType, promotedContent: PromotedNotificationContentModels?, requestedPromotion: Boolean, style: NotifStyle?, ): Boolean { return when { key != this.key -> false Loading Loading @@ -365,6 +373,7 @@ private fun ActiveNotificationModel.isCurrent( // recreating the active notification model constantly? promotedContent != this.promotedContent -> false requestedPromotion != this.requestedPromotion -> false style != this.style -> false else -> true } } Loading Loading @@ -434,3 +443,9 @@ private fun hasSameInstances(list1: List<*>, list2: List<*>): Boolean { } return true } private fun notifStyle(notif: Notification): NotifStyle? = when { notif.isStyle(MessagingStyle::class.java) -> NotifStyle.Messaging() else -> null }
packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/ActiveNotificationModel.kt +10 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,8 @@ data class ActiveNotificationModel( val promotedContent: PromotedNotificationContentModels?, /** True if this notification set the "requested promotion?" extra and false otherwise. */ val requestedPromotion: Boolean, /** The visual style of the notification, containing additional data relevant to that style. */ val style: NotifStyle?, ) : ActiveNotificationEntryModel() { init { if (!PromotedNotificationContentModel.featureFlagEnabled()) { Loading Loading @@ -143,3 +145,11 @@ enum class CallType { /** See [android.app.Notification.CallStyle.CALL_TYPE_UNKNOWN]. */ Unknown, } /** Style-specific data for [ActiveNotificationModel] */ sealed class NotifStyle { /** * Data pertaining to [messaging style][android.app.Notification.MessagingStyle] notifications. */ class Messaging : NotifStyle() }
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SummarizationOnboardingInteractor.kt +5 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.util.Log import androidx.core.content.edit import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository import com.android.systemui.statusbar.notification.shared.NotifStyle import com.android.systemui.user.domain.interactor.SelectedUserInteractor import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.SharedPreferencesExt.observeBoolean Loading @@ -47,7 +48,10 @@ constructor( ) { private val notifsPresent: Flow<Boolean> = notifListRepo.activeNotifications .map { store -> store.renderList.isNotEmpty() } .map { store -> store.renderList.isNotEmpty() && store.individuals.any { (_, notif) -> notif.style is NotifStyle.Messaging } } .distinctUntilChanged() private val onboardingUnseen: Flow<Boolean> = Loading
packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/model/ActiveNotificationModelBuilder.kt +3 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.notification.shared.CallType import com.android.systemui.statusbar.notification.shared.NotifStyle import com.android.systemui.statusbar.notification.stack.BUCKET_UNKNOWN /** Simple ActiveNotificationModel builder for use in tests. */ Loading Loading @@ -52,6 +53,7 @@ fun activeNotificationModel( callType: CallType = CallType.None, requestedPromotion: Boolean = false, promotedContent: PromotedNotificationContentModels? = null, notifStyle: NotifStyle? = null, ) = ActiveNotificationModel( key = key, Loading Loading @@ -79,4 +81,5 @@ fun activeNotificationModel( callType = callType, requestedPromotion = requestedPromotion, promotedContent = promotedContent, style = notifStyle, )