diff options
| author | Daniel Sandler <dsandler@android.com> | 2012-10-15 22:23:27 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-15 22:23:29 -0700 |
| commit | 1f0752993ffd4339cdf0e7d69b96093503bd2e24 (patch) | |
| tree | 981523ec9088a180cab3efafeba2b7ab5e7a05c5 | |
| parent | f6dbd61b108e586c1db3e61cbfc07d4d750027c0 (diff) | |
| parent | 321e9c562b9146cf936b3d1ec2f9317e98edd5fe (diff) | |
| download | frameworks_base-1f0752993ffd4339cdf0e7d69b96093503bd2e24.zip frameworks_base-1f0752993ffd4339cdf0e7d69b96093503bd2e24.tar.gz frameworks_base-1f0752993ffd4339cdf0e7d69b96093503bd2e24.tar.bz2 | |
Merge "Allow any user to clear a notification targeted at USER_ALL." into jb-mr1-dev
| -rw-r--r-- | services/java/com/android/server/EventLogTags.logtags | 6 | ||||
| -rwxr-xr-x | services/java/com/android/server/NotificationManagerService.java | 28 |
2 files changed, 24 insertions, 10 deletions
diff --git a/services/java/com/android/server/EventLogTags.logtags b/services/java/com/android/server/EventLogTags.logtags index 840e006..0fe66fc 100644 --- a/services/java/com/android/server/EventLogTags.logtags +++ b/services/java/com/android/server/EventLogTags.logtags @@ -52,12 +52,12 @@ option java_package com.android.server # NotificationManagerService.java # --------------------------- # when a NotificationManager.notify is called -2750 notification_enqueue (pkg|3),(id|1|5),(tag|3),(notification|3) +2750 notification_enqueue (pkg|3),(id|1|5),(tag|3),(userid|1|5),(notification|3) # when someone tries to cancel a notification, the notification manager sometimes # calls this with flags too -2751 notification_cancel (pkg|3),(id|1|5),(tag|3),(required_flags|1),(forbidden_flags|1) +2751 notification_cancel (pkg|3),(id|1|5),(tag|3),(userid|1|5),(required_flags|1),(forbidden_flags|1) # when someone tries to cancel all of the notifications for a particular package -2752 notification_cancel_all (pkg|3),(required_flags|1),(forbidden_flags|1) +2752 notification_cancel_all (pkg|3),(userid|1|5),(required_flags|1),(forbidden_flags|1) # --------------------------- diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index 09a606e..4a54efe 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -916,7 +916,7 @@ public class NotificationManagerService extends INotificationManager.Stub // behalf of the download manager without affecting other apps. if (!pkg.equals("com.android.providers.downloads") || Log.isLoggable("DownloadManager", Log.VERBOSE)) { - EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, tag, + EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, tag, userId, notification.toString()); } @@ -1207,7 +1207,7 @@ public class NotificationManagerService extends INotificationManager.Stub */ private void cancelNotification(String pkg, String tag, int id, int mustHaveFlags, int mustNotHaveFlags, boolean sendDelete, int userId) { - EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL, pkg, id, tag, + EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL, pkg, id, tag, userId, mustHaveFlags, mustNotHaveFlags); synchronized (mNotificationList) { @@ -1231,20 +1231,34 @@ public class NotificationManagerService extends INotificationManager.Stub } /** + * Determine whether the userId applies to the notification in question, either because + * they match exactly, or one of them is USER_ALL (which is treated as a wildcard). + */ + private boolean notificationMatchesUserId(NotificationRecord r, int userId) { + return + // looking for USER_ALL notifications? match everything + userId == UserHandle.USER_ALL + // a notification sent to USER_ALL matches any query + || r.userId == UserHandle.USER_ALL + // an exact user match + || r.userId == userId; + } + + /** * Cancels all notifications from a given package that have all of the * {@code mustHaveFlags}. */ boolean cancelAllNotificationsInt(String pkg, int mustHaveFlags, int mustNotHaveFlags, boolean doit, int userId) { - EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL_ALL, pkg, mustHaveFlags, - mustNotHaveFlags); + EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL_ALL, pkg, userId, + mustHaveFlags, mustNotHaveFlags); synchronized (mNotificationList) { final int N = mNotificationList.size(); boolean canceledSomething = false; for (int i = N-1; i >= 0; --i) { NotificationRecord r = mNotificationList.get(i); - if (userId != UserHandle.USER_ALL && r.userId != userId) { + if (!notificationMatchesUserId(r, userId)) { continue; } if ((r.notification.flags & mustHaveFlags) != mustHaveFlags) { @@ -1322,7 +1336,7 @@ public class NotificationManagerService extends INotificationManager.Stub for (int i=N-1; i>=0; i--) { NotificationRecord r = mNotificationList.get(i); - if (r.userId != userId) { + if (!notificationMatchesUserId(r, userId)) { continue; } @@ -1376,7 +1390,7 @@ public class NotificationManagerService extends INotificationManager.Stub final int len = list.size(); for (int i=0; i<len; i++) { NotificationRecord r = list.get(i); - if (r.userId != userId || r.id != id) { + if (!notificationMatchesUserId(r, userId) || r.id != id) { continue; } if (tag == null) { |
