1 /*
2  * Copyright (C) 2019 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;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.service.notification.NotificationListenerService;
22 
23 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
24 
25 /**
26  * Interface for anything that may need to prevent notifications from being removed. This is
27  * similar to a {@link NotificationLifetimeExtender} in the sense that it extends the life of
28  * a notification by preventing the removal, however, unlike the extender, the remove interceptor
29  * gets first pick at intercepting any type of removal -- the life time extender is unable to
30  * extend the life of a user dismissed or force removed notification.
31  */
32 public interface NotificationRemoveInterceptor {
33 
34     /**
35      * Called when a notification has been removed.
36      *
37      * @param key the key of the notification being removed. Never null
38      * @param entry the entry of the notification being removed.
39      * @param removeReason why the notification is being removed, e.g.
40      * {@link NotificationListenerService#REASON_CANCEL} or 0 if unknown.
41      *
42      * @return true if the removal should be ignored, false otherwise.
43      */
onNotificationRemoveRequested( @onNull String key, @Nullable NotificationEntry entry, int removeReason)44     boolean onNotificationRemoveRequested(
45             @NonNull String key,
46             @Nullable NotificationEntry entry,
47             int removeReason);
48 }
49