• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 package com.android.systemui.plugins;
16 
17 import android.app.NotificationChannel;
18 import android.os.UserHandle;
19 import android.service.notification.NotificationListenerService.RankingMap;
20 import android.service.notification.StatusBarNotification;
21 
22 import com.android.systemui.plugins.NotificationListenerController.NotificationProvider;
23 import com.android.systemui.plugins.annotations.DependsOn;
24 import com.android.systemui.plugins.annotations.ProvidesInterface;
25 
26 @ProvidesInterface(action = NotificationListenerController.ACTION,
27         version = NotificationListenerController.VERSION)
28 @DependsOn(target = NotificationProvider.class)
29 public interface NotificationListenerController extends Plugin {
30     String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_ASSISTANT";
31     int VERSION = 1;
32 
onListenerConnected(NotificationProvider provider)33     void onListenerConnected(NotificationProvider provider);
34 
35     /**
36      * @return whether plugin wants to skip the default callbacks.
37      */
onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap)38     default boolean onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
39         return false;
40     }
41 
42     /**
43      * @return whether plugin wants to skip the default callbacks.
44      */
onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap)45     default boolean onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap) {
46         return false;
47     }
48 
49     /**
50      * Called when a notification channel is modified.
51      * @param modificationType One of {@link #NOTIFICATION_CHANNEL_OR_GROUP_ADDED},
52      *                                {@link #NOTIFICATION_CHANNEL_OR_GROUP_UPDATED},
53      *                                {@link #NOTIFICATION_CHANNEL_OR_GROUP_DELETED}.
54      * @return whether a plugin wants to skip the default callbacks.
55      */
onNotificationChannelModified( String pkgName, UserHandle user, NotificationChannel channel, int modificationType)56     default boolean onNotificationChannelModified(
57             String pkgName, UserHandle user, NotificationChannel channel, int modificationType) {
58         return false;
59     }
60 
getActiveNotifications( StatusBarNotification[] activeNotifications)61     default StatusBarNotification[] getActiveNotifications(
62             StatusBarNotification[] activeNotifications) {
63         return activeNotifications;
64     }
65 
getCurrentRanking(RankingMap currentRanking)66     default RankingMap getCurrentRanking(RankingMap currentRanking) {
67         return currentRanking;
68     }
69 
70     @ProvidesInterface(version = NotificationProvider.VERSION)
71     interface NotificationProvider {
72         int VERSION = 1;
73 
74         // Methods to get info about current notifications
getActiveNotifications()75         StatusBarNotification[] getActiveNotifications();
getRankingMap()76         RankingMap getRankingMap();
77 
78         // Methods to notify sysui of changes to notification list.
addNotification(StatusBarNotification sbn)79         void addNotification(StatusBarNotification sbn);
removeNotification(StatusBarNotification sbn)80         void removeNotification(StatusBarNotification sbn);
updateRanking()81         void updateRanking();
82     }
83 }
84