summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2016-01-08 15:50:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-01-08 15:50:13 +0000
commit2d20a4dcc60a4d87ddf536d40cf00a59fa2d9479 (patch)
treeeb3886f1bd5826ac8f3920bc91263e8a318ca5a6 /core/java/android
parentc03c596a537df81bcb0ab4629e56c2ce1be4c0ed (diff)
parentab41eecf22352f54167ce9a272a397715ffd0015 (diff)
Merge "allow listeners to disable themselves"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/INotificationManager.aidl3
-rw-r--r--core/java/android/service/notification/NotificationAssistantService.java5
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java30
3 files changed, 38 insertions, 0 deletions
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index e60cb0377e96..633f6995b986 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -68,6 +68,9 @@ interface INotificationManager
void cancelNotificationFromListener(in INotificationListener token, String pkg, String tag, int id);
void cancelNotificationsFromListener(in INotificationListener token, in String[] keys);
+ void requestBindListener(in ComponentName component);
+ void requestUnbindListener(in INotificationListener token);
+
void setNotificationsShownFromListener(in INotificationListener token, in String[] keys);
ParceledListSlice getActiveNotificationsFromListener(in INotificationListener token, in String[] keys, int trim);
diff --git a/core/java/android/service/notification/NotificationAssistantService.java b/core/java/android/service/notification/NotificationAssistantService.java
index 3a8956ec15d9..aba82fad0bfa 100644
--- a/core/java/android/service/notification/NotificationAssistantService.java
+++ b/core/java/android/service/notification/NotificationAssistantService.java
@@ -17,13 +17,18 @@
package android.service.notification;
import android.annotation.SdkConstant;
+import android.annotation.SystemApi;
+import android.app.INotificationManager;
import android.app.Notification;
+import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.util.Log;
/**
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 1fd5f95ae9bf..ed90e795af00 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -692,6 +692,36 @@ public abstract class NotificationListenerService extends Service {
}
}
+ /**
+ * Request that the listener be rebound, after a previous call to (@link requestUnbind).
+ *
+ * <P>This method will fail for assistants that have
+ * not been granted the permission by the user.
+ *
+ * <P>The service should wait for the {@link #onListenerConnected()} event
+ * before performing any operations.
+ */
+ public static final void requestRebind(ComponentName componentName)
+ throws RemoteException {
+ INotificationManager noMan = INotificationManager.Stub.asInterface(
+ ServiceManager.getService(Context.NOTIFICATION_SERVICE));
+ noMan.requestBindListener(componentName);
+ }
+
+ /**
+ * Request that the service be unbound.
+ *
+ * <P>This will no longer receive updates until
+ * {@link #requestRebind(ComponentName)} is called.
+ * The service will likely be kiled by the system after this call.
+ */
+ public final void requestUnbind() throws RemoteException {
+ if (mWrapper != null) {
+ INotificationManager noMan = getNotificationInterface();
+ noMan.requestUnbindListener(mWrapper);
+ }
+ }
+
/** Convert new-style Icons to legacy representations for pre-M clients. */
private void createLegacyIconExtras(Notification n) {
Icon smallIcon = n.getSmallIcon();