Home | History | Annotate | Download | only in plugins
      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.service.notification.NotificationListenerService.RankingMap;
     18 import android.service.notification.StatusBarNotification;
     19 
     20 import com.android.systemui.plugins.NotificationListenerController.NotificationProvider;
     21 import com.android.systemui.plugins.annotations.DependsOn;
     22 import com.android.systemui.plugins.annotations.ProvidesInterface;
     23 
     24 @ProvidesInterface(action = NotificationListenerController.ACTION,
     25         version = NotificationListenerController.VERSION)
     26 @DependsOn(target = NotificationProvider.class)
     27 public interface NotificationListenerController extends Plugin {
     28     String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_ASSISTANT";
     29     int VERSION = 1;
     30 
     31     void onListenerConnected(NotificationProvider provider);
     32 
     33     default boolean onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
     34         return false;
     35     }
     36     default boolean onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap) {
     37         return false;
     38     }
     39 
     40     default StatusBarNotification[] getActiveNotifications(
     41             StatusBarNotification[] activeNotifications) {
     42         return activeNotifications;
     43     }
     44 
     45     default RankingMap getCurrentRanking(RankingMap currentRanking) {
     46         return currentRanking;
     47     }
     48 
     49     @ProvidesInterface(version = NotificationProvider.VERSION)
     50     interface NotificationProvider {
     51         int VERSION = 1;
     52 
     53         // Methods to get info about current notifications
     54         StatusBarNotification[] getActiveNotifications();
     55         RankingMap getRankingMap();
     56 
     57         // Methods to notify sysui of changes to notification list.
     58         void addNotification(StatusBarNotification sbn);
     59         void removeNotification(StatusBarNotification sbn);
     60         void updateRanking();
     61     }
     62 }
     63