1 /* 2 * Copyright (C) 2020 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.notifcollection; 18 19 import androidx.annotation.NonNull; 20 import androidx.annotation.Nullable; 21 22 import com.android.systemui.statusbar.notification.collection.NotifPipeline; 23 import com.android.systemui.statusbar.notification.collection.NotificationEntry; 24 25 import java.util.Collection; 26 27 /** 28 * A notification collection that manages the list of {@link NotificationEntry}s that will be 29 * rendered. 30 * 31 * TODO: (b/145659174) Once we fully migrate to {@link NotifPipeline}, we probably won't need this, 32 * but having it for now makes it easy to switch between the two. 33 */ 34 public interface CommonNotifCollection { 35 /** 36 * Registers a listener to be informed when notifications are created, added, updated, removed, 37 * or deleted. 38 */ addCollectionListener(@onNull NotifCollectionListener listener)39 void addCollectionListener(@NonNull NotifCollectionListener listener); 40 41 /** 42 * Unregisters a listener previously added with {@link #addCollectionListener} 43 */ removeCollectionListener(@onNull NotifCollectionListener listener)44 void removeCollectionListener(@NonNull NotifCollectionListener listener); 45 46 /** 47 * Returns the list of all known notifications, i.e. the notifications that are currently posted 48 * to the phone. In general, this tracks closely to the list maintained by NotificationManager, 49 * but it can diverge slightly due to lifetime extenders. 50 * 51 * The returned collection is read-only, unsorted, unfiltered, and ungrouped. 52 */ getAllNotifs()53 @NonNull Collection<NotificationEntry> getAllNotifs(); 54 55 /** 56 * Returns the notification entry for the given notification key; 57 * the returned entry (if present) may be in any state. 58 */ getEntry(@onNull String key)59 @Nullable NotificationEntry getEntry(@NonNull String key); 60 } 61