1 /* 2 * Copyright (C) 2025 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.notification.collection; 18 19 import android.content.Context; 20 import android.service.notification.NotificationListenerService; 21 import android.service.notification.StatusBarNotification; 22 23 import androidx.annotation.NonNull; 24 import androidx.annotation.Nullable; 25 26 import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender; 27 import com.android.systemui.statusbar.notification.icon.IconPack; 28 import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier; 29 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; 30 31 import kotlinx.coroutines.flow.StateFlow; 32 33 /** 34 * Adapter interface for UI to get relevant info. 35 */ 36 public interface EntryAdapter { 37 38 /** 39 * Returns the hash code of the backing entry 40 */ getBackingHashCode()41 int getBackingHashCode(); 42 43 /** 44 * Gets the parent of this entry, or null if the entry's view is not attached 45 */ getParent()46 @Nullable PipelineEntry getParent(); 47 48 /** 49 * Returns whether the entry is attached and appears at the top level of the shade 50 */ isTopLevelEntry()51 boolean isTopLevelEntry(); 52 53 /** 54 * @return the unique identifier for this entry 55 */ getKey()56 @NonNull String getKey(); 57 58 /** 59 * Gets the view that this entry is backing. 60 */ 61 @Nullable getRow()62 ExpandableNotificationRow getRow(); 63 64 /** 65 * Whether this entry is the root of its collapsable 'group' - either a BundleEntry or a 66 * notification group summary 67 */ isGroupRoot()68 boolean isGroupRoot(); 69 70 /** 71 * @return whether the row can be removed with the 'Clear All' action 72 */ isClearable()73 boolean isClearable(); 74 75 /** 76 * Returns whether the entry is attached to the current shade list 77 */ isAttached()78 default boolean isAttached() { 79 return getParent() != null; 80 } 81 82 /** 83 * Returns the target sdk of the package that owns this entry. 84 */ getTargetSdk()85 int getTargetSdk(); 86 87 /** 88 * Returns the summarization for this entry, if there is one 89 */ getSummarization()90 @Nullable String getSummarization(); 91 92 /** 93 * Performs any steps needed to set or reset data before an inflation or reinflation. 94 */ prepareForInflation()95 default void prepareForInflation() {} 96 97 /** 98 * Gets a color that would have sufficient contrast on the given background color. 99 */ getContrastedColor(Context context, boolean isLowPriority, int backgroundColor)100 int getContrastedColor(Context context, boolean isLowPriority, int backgroundColor); 101 102 /** 103 * Whether this entry can peek on screen as a heads up view 104 */ canPeek()105 boolean canPeek(); 106 107 /** 108 * Returns the visible 'time', in milliseconds, of the entry 109 */ getWhen()110 long getWhen(); 111 112 /** 113 * Retrieves the pack of icons associated with this entry 114 */ getIcons()115 IconPack getIcons(); 116 117 /** 118 * Returns whether the content of this entry is sensitive 119 */ isSensitive()120 StateFlow<Boolean> isSensitive(); 121 122 /** 123 * Returns whether this row has a background color set by an app 124 */ isColorized()125 boolean isColorized(); 126 127 /** 128 * Returns the SBN that backs this row, if present 129 */ 130 @Nullable getSbn()131 StatusBarNotification getSbn(); 132 133 /** 134 * Returns the ranking that backs this row, if present 135 */ 136 @Nullable getRanking()137 NotificationListenerService.Ranking getRanking(); 138 endLifetimeExtension( @ullable NotifLifetimeExtender.OnEndLifetimeExtensionCallback callback, @NonNull NotifLifetimeExtender extender)139 void endLifetimeExtension( 140 @Nullable NotifLifetimeExtender.OnEndLifetimeExtensionCallback callback, 141 @NonNull NotifLifetimeExtender extender); 142 143 onImportanceChanged()144 void onImportanceChanged(); 145 146 /** 147 * Use when a change has been made to the underlying object that will both rerank the object 148 * in the shade and change something about its appearance to delay the appearance change until 149 * the ranking reordering is likely to have settled. 150 */ markForUserTriggeredMovement()151 void markForUserTriggeredMovement(); 152 153 /** 154 * Determines whether a row is considered 'high priority'. 155 * 156 * Notifications that are high priority are visible on the lock screen/status bar and in the top 157 * section in the shade. 158 */ isHighPriority()159 boolean isHighPriority(); 160 isMarkedForUserTriggeredMovement()161 boolean isMarkedForUserTriggeredMovement(); 162 setInlineControlsShown(boolean currentlyVisible)163 void setInlineControlsShown(boolean currentlyVisible); 164 isBlockable()165 boolean isBlockable(); 166 canDragAndDrop()167 boolean canDragAndDrop(); 168 isBubble()169 boolean isBubble(); 170 getStyle()171 @Nullable String getStyle(); 172 getSectionBucket()173 int getSectionBucket(); 174 isAmbient()175 boolean isAmbient(); 176 getPeopleNotificationType()177 @PeopleNotificationIdentifier.Companion.PeopleNotificationType int getPeopleNotificationType(); 178 179 /** 180 * Returns whether this row represents promoted ongoing notification. 181 */ isPromotedOngoing()182 boolean isPromotedOngoing(); 183 isFullScreenCapable()184 default boolean isFullScreenCapable() { 185 return false; 186 } 187 onDragSuccess()188 void onDragSuccess(); 189 190 /** 191 * Process a click on a notification bubble icon 192 */ onNotificationBubbleIconClicked()193 void onNotificationBubbleIconClicked(); 194 195 /** 196 * Processes a click on a notification action 197 */ onNotificationActionClicked()198 void onNotificationActionClicked(); 199 getDismissState()200 NotificationEntry.DismissState getDismissState(); 201 onEntryClicked(ExpandableNotificationRow row)202 void onEntryClicked(ExpandableNotificationRow row); 203 204 } 205 206