Merge "Allow any user to clear a notification targeted at USER_ALL." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1f0752993f
@@ -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)
|
||||
|
||||
|
||||
# ---------------------------
|
||||
|
||||
@@ -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) {
|
||||
@@ -1230,21 +1230,35 @@ 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) {
|
||||
|
||||
Reference in New Issue
Block a user