1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 * 14 */ 15 16 package com.android.systemui.statusbar.notification.shared 17 18 import android.app.PendingIntent 19 import android.graphics.drawable.Icon 20 import android.util.Log 21 import com.android.internal.logging.InstanceId 22 import com.android.systemui.statusbar.StatusBarIconView 23 import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel 24 import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels 25 import com.android.systemui.statusbar.notification.stack.PriorityBucket 26 27 /** 28 * Model for a top-level "entry" in the notification list, either an 29 * [individual notification][ActiveNotificationModel], or a [group][ActiveNotificationGroupModel]. 30 */ 31 sealed class ActiveNotificationEntryModel 32 33 /** 34 * Model for an individual notification in the notification list. These can appear as either an 35 * individual top-level notification, or as a child or summary of a [ActiveNotificationGroupModel]. 36 */ 37 data class ActiveNotificationModel( 38 val key: String, 39 /** Notification group key associated with this entry. */ 40 val groupKey: String?, 41 /** When this notification was posted. */ 42 val whenTime: Long, 43 /** True if this is a foreground service notification. */ 44 val isForegroundService: Boolean, 45 /** True if this notification is for an ongoing event. */ 46 val isOngoingEvent: Boolean, 47 /** Is this entry in the ambient / minimized section (lowest priority)? */ 48 val isAmbient: Boolean, 49 /** 50 * Is this entry dismissed? This is `true` when the user has dismissed the notification in the 51 * UI, but `NotificationManager` has not yet signalled to us that it has received the dismissal. 52 */ 53 val isRowDismissed: Boolean, 54 /** Is this entry in the silent section? */ 55 val isSilent: Boolean, 56 /** 57 * Does this entry represent a conversation, the last message of which was from a remote input 58 * reply? 59 */ 60 val isLastMessageFromReply: Boolean, 61 /** Is this entry suppressed from appearing in the status bar as an icon? */ 62 val isSuppressedFromStatusBar: Boolean, 63 /** Is this entry actively pulsing on AOD or bypassed-keyguard? */ 64 val isPulsing: Boolean, 65 /** Icon to display on AOD. */ 66 val aodIcon: Icon?, 67 /** Icon to display in the notification shelf. */ 68 val shelfIcon: Icon?, 69 /** Icon to display in the status bar. */ 70 val statusBarIcon: Icon?, 71 /** Icon to display in the status bar chip. */ 72 val statusBarChipIconView: StatusBarIconView?, 73 /** The notifying app's [packageName]'s uid. */ 74 val uid: Int, 75 /** The notifying app's packageName. */ 76 val packageName: String, 77 /** The notifying app's display name. */ 78 val appName: String, 79 /** The intent to execute if UI related to this notification is clicked. */ 80 val contentIntent: PendingIntent?, 81 /** A small per-notification ID, used for statsd logging. */ 82 val instanceId: InstanceId?, 83 /** If this notification is the group summary for a group of notifications. */ 84 val isGroupSummary: Boolean, 85 /** Indicates in which section the notification is displayed in. @see [PriorityBucket]. */ 86 @PriorityBucket val bucket: Int, 87 /** The call type set on the notification. */ 88 val callType: CallType, 89 /** 90 * The content needed to render this as a promoted notification on various surfaces, or null if 91 * this notification cannot be rendered as a promoted notification. 92 */ 93 val promotedContent: PromotedNotificationContentModels?, 94 ) : ActiveNotificationEntryModel() { 95 init { 96 if (!PromotedNotificationContentModel.featureFlagEnabled()) { 97 if (promotedContent != null) { 98 // TODO(b/401018545): convert to Log.wtf and fix tests (see: ag/32114199) 99 Log.e(TAG, "passing non-null promoted content without feature flag enabled") 100 } 101 } 102 } 103 104 companion object { 105 private const val TAG = "ActiveNotificationEntryModel" 106 } 107 } 108 109 /** Model for a group of notifications. */ 110 data class ActiveNotificationGroupModel( 111 val key: String, 112 val summary: ActiveNotificationModel, 113 val children: List<ActiveNotificationModel>, 114 ) : ActiveNotificationEntryModel() 115 116 /** Specifies the call type set on the notification. For most notifications, will be [None]. */ 117 enum class CallType { 118 /** This notification isn't a call-type notification. */ 119 None, 120 /** See [android.app.Notification.CallStyle.CALL_TYPE_INCOMING]. */ 121 Incoming, 122 /** See [android.app.Notification.CallStyle.CALL_TYPE_ONGOING]. */ 123 Ongoing, 124 /** See [android.app.Notification.CallStyle.CALL_TYPE_SCREENING]. */ 125 Screening, 126 /** See [android.app.Notification.CallStyle.CALL_TYPE_UNKNOWN]. */ 127 Unknown, 128 } 129