1 /**
2  * Copyright (c) 2013, 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.server.notification;
18 
19 import android.app.Notification;
20 import android.net.Uri;
21 import android.os.Bundle;
22 import android.os.UserHandle;
23 import android.service.notification.NotificationStats;
24 
25 import com.android.internal.statusbar.NotificationVisibility;
26 
27 public interface NotificationDelegate {
onSetDisabled(int status)28     void onSetDisabled(int status);
onClearAll(int callingUid, int callingPid, int userId)29     void onClearAll(int callingUid, int callingPid, int userId);
onNotificationClick(int callingUid, int callingPid, String key, NotificationVisibility nv)30     void onNotificationClick(int callingUid, int callingPid, String key,
31             NotificationVisibility nv);
onNotificationActionClick(int callingUid, int callingPid, String key, int actionIndex, Notification.Action action, NotificationVisibility nv, boolean generatedByAssistant)32     void onNotificationActionClick(int callingUid, int callingPid, String key, int actionIndex,
33             Notification.Action action, NotificationVisibility nv, boolean generatedByAssistant);
onNotificationClear(int callingUid, int callingPid, String pkg, int userId, String key, @NotificationStats.DismissalSurface int dismissalSurface, @NotificationStats.DismissalSentiment int dismissalSentiment, NotificationVisibility nv)34     void onNotificationClear(int callingUid, int callingPid,
35             String pkg, int userId, String key,
36             @NotificationStats.DismissalSurface int dismissalSurface,
37             @NotificationStats.DismissalSentiment int dismissalSentiment,
38             NotificationVisibility nv);
onNotificationError(int callingUid, int callingPid, String pkg, String tag, int id, int uid, int initialPid, String message, int userId)39     void onNotificationError(int callingUid, int callingPid,
40             String pkg, String tag, int id,
41             int uid, int initialPid, String message, int userId);
onPanelRevealed(boolean clearEffects, int numItems)42     void onPanelRevealed(boolean clearEffects, int numItems);
onPanelHidden()43     void onPanelHidden();
clearEffects()44     void clearEffects();
onNotificationVisibilityChanged( NotificationVisibility[] newlyVisibleKeys, NotificationVisibility[] noLongerVisibleKeys)45     void onNotificationVisibilityChanged(
46             NotificationVisibility[] newlyVisibleKeys,
47             NotificationVisibility[] noLongerVisibleKeys);
onNotificationExpansionChanged(String key, boolean userAction, boolean expanded, int notificationLocation)48     void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded,
49             int notificationLocation);
onNotificationDirectReplied(String key)50     void onNotificationDirectReplied(String key);
onNotificationSettingsViewed(String key)51     void onNotificationSettingsViewed(String key);
52     /**
53      * Called when the state of {@link Notification#FLAG_BUBBLE} is changed.
54      */
onNotificationBubbleChanged(String key, boolean isBubble, int flags)55     void onNotificationBubbleChanged(String key, boolean isBubble, int flags);
56     /**
57      * Called when the state of {@link Notification.BubbleMetadata#FLAG_SUPPRESS_NOTIFICATION}
58      * or {@link Notification.BubbleMetadata#FLAG_SUPPRESS_BUBBLE} changes.
59      */
onBubbleNotificationSuppressionChanged(String key, boolean isNotifSuppressed, boolean isBubbleSuppressed)60     void onBubbleNotificationSuppressionChanged(String key, boolean isNotifSuppressed,
61             boolean isBubbleSuppressed);
62 
63     /**
64      * Grant permission to read the specified URI to the package associated with the
65      * NotificationRecord associated with the given key.
66      */
grantInlineReplyUriPermission(String key, Uri uri, UserHandle user, String packageName, int callingUid)67     void grantInlineReplyUriPermission(String key, Uri uri, UserHandle user, String packageName,
68             int callingUid);
69 
70     /**
71      * Clear inline URI grants associated with the given notification.
72      */
clearInlineReplyUriPermissions(String key, int callingUid)73     void clearInlineReplyUriPermissions(String key, int callingUid);
74 
75     /**
76      * Notifies that smart replies and actions have been added to the UI.
77      */
onNotificationSmartSuggestionsAdded(String key, int smartReplyCount, int smartActionCount, boolean generatedByAssistant, boolean editBeforeSending)78     void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount, int smartActionCount,
79             boolean generatedByAssistant, boolean editBeforeSending);
80 
81     /**
82      * Notifies a smart reply is sent.
83      *
84      * @param key the notification key
85      * @param clickedIndex the index of clicked reply
86      * @param reply the reply that is sent
87      * @param notificationLocation the location of the notification containing the smart reply
88      * @param modifiedBeforeSending whether the user changed the smart reply before sending
89      */
onNotificationSmartReplySent(String key, int clickedIndex, CharSequence reply, int notificationLocation, boolean modifiedBeforeSending)90     void onNotificationSmartReplySent(String key, int clickedIndex, CharSequence reply,
91             int notificationLocation, boolean modifiedBeforeSending);
92 
93     /**
94      * Notifies a user feedback is provided.
95      *
96      * @param key the notification key
97      * @param feedback the feedback detail
98      */
onNotificationFeedbackReceived(String key, Bundle feedback)99     void onNotificationFeedbackReceived(String key, Bundle feedback);
100 
prepareForPossibleShutdown()101     void prepareForPossibleShutdown();
102 }
103