summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2014-04-08 17:59:27 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-04-08 17:59:27 +0000
commitcfd3cd6df375793d714fe3b6570791e377cab1e5 (patch)
tree4f2c446a8c04cb90bac556aef94c9afcaebef6c7 /core/java/android
parent777a8e0aec6d8fd4813e75a39c5611c5cb660f9f (diff)
parenta263e4e438746f91fb78857bd569ba4f796a346d (diff)
downloadframeworks_base-cfd3cd6df375793d714fe3b6570791e377cab1e5.zip
frameworks_base-cfd3cd6df375793d714fe3b6570791e377cab1e5.tar.gz
frameworks_base-cfd3cd6df375793d714fe3b6570791e377cab1e5.tar.bz2
Merge "Pipe notifications from related users to listeners."
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java35
-rw-r--r--core/java/android/service/notification/StatusBarNotification.java7
2 files changed, 39 insertions, 3 deletions
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 050e1a0..3673f03 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.ServiceManager;
+import android.os.UserHandle;
import android.util.Log;
/**
@@ -121,11 +122,43 @@ public abstract class NotificationListenerService extends Service {
* {@link android.app.NotificationManager#notify(String, int, android.app.Notification)}.
* @param id ID of the notification as specified by the notifying app in
* {@link android.app.NotificationManager#notify(String, int, android.app.Notification)}.
+ * <p>
+ * @deprecated Use {@link #cancelNotification(String key)}
+ * instead. Beginning with {@link android.os.Build.VERSION_CODES#L} this method will no longer
+ * cancel the notification. It will continue to cancel the notification for applications
+ * whose {@code targetSdkVersion} is earlier than {@link android.os.Build.VERSION_CODES#L}.
*/
public final void cancelNotification(String pkg, String tag, int id) {
if (!isBound()) return;
try {
- getNotificationInterface().cancelNotificationFromListener(mWrapper, pkg, tag, id);
+ getNotificationInterface().cancelNotificationFromListener(
+ mWrapper, pkg, tag, id);
+ } catch (android.os.RemoteException ex) {
+ Log.v(TAG, "Unable to contact notification manager", ex);
+ }
+ }
+
+ /**
+ * Inform the notification manager about dismissal of a single notification.
+ * <p>
+ * Use this if your listener has a user interface that allows the user to dismiss individual
+ * notifications, similar to the behavior of Android's status bar and notification panel.
+ * It should be called after the user dismisses a single notification using your UI;
+ * upon being informed, the notification manager will actually remove the notification
+ * and you will get an {@link #onNotificationRemoved(StatusBarNotification)} callback.
+ * <P>
+ * <b>Note:</b> If your listener allows the user to fire a notification's
+ * {@link android.app.Notification#contentIntent} by tapping/clicking/etc., you should call
+ * this method at that time <i>if</i> the Notification in question has the
+ * {@link android.app.Notification#FLAG_AUTO_CANCEL} flag set.
+ * <p>
+ * @param key Notification to dismiss from {@link StatusBarNotification#getKey()}.
+ */
+ public final void cancelNotification(String key) {
+ if (!isBound()) return;
+ try {
+ getNotificationInterface().cancelNotificationsFromListener(mWrapper,
+ new String[] {key});
} catch (android.os.RemoteException ex) {
Log.v(TAG, "Unable to contact notification manager", ex);
}
diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java
index 7f15ab8..0f74169 100644
--- a/core/java/android/service/notification/StatusBarNotification.java
+++ b/core/java/android/service/notification/StatusBarNotification.java
@@ -175,7 +175,11 @@ public class StatusBarNotification implements Parcelable {
&& ((notification.flags & Notification.FLAG_NO_CLEAR) == 0);
}
- /** Returns a userHandle for the instance of the app that posted this notification. */
+ /**
+ * Returns a userHandle for the instance of the app that posted this notification.
+ *
+ * @deprecated Use {@link #getUser()} instead.
+ */
public int getUserId() {
return this.user.getIdentifier();
}
@@ -219,7 +223,6 @@ public class StatusBarNotification implements Parcelable {
/**
* The {@link android.os.UserHandle} for whom this notification is intended.
- * @hide
*/
public UserHandle getUser() {
return user;