am 36074eec: am 1f075299: Merge "Allow any user to clear a notification targeted at USER_ALL." into jb-mr1-dev
* commit '36074eecccaaa52e535513829b9de13ac3930347': Allow any user to clear a notification targeted at USER_ALL.
This commit is contained in:
@@ -52,12 +52,12 @@ option java_package com.android.server
|
|||||||
# NotificationManagerService.java
|
# NotificationManagerService.java
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# when a NotificationManager.notify is called
|
# 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
|
# when someone tries to cancel a notification, the notification manager sometimes
|
||||||
# calls this with flags too
|
# 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
|
# 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.
|
// behalf of the download manager without affecting other apps.
|
||||||
if (!pkg.equals("com.android.providers.downloads")
|
if (!pkg.equals("com.android.providers.downloads")
|
||||||
|| Log.isLoggable("DownloadManager", Log.VERBOSE)) {
|
|| Log.isLoggable("DownloadManager", Log.VERBOSE)) {
|
||||||
EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, tag,
|
EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, tag, userId,
|
||||||
notification.toString());
|
notification.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1207,7 +1207,7 @@ public class NotificationManagerService extends INotificationManager.Stub
|
|||||||
*/
|
*/
|
||||||
private void cancelNotification(String pkg, String tag, int id, int mustHaveFlags,
|
private void cancelNotification(String pkg, String tag, int id, int mustHaveFlags,
|
||||||
int mustNotHaveFlags, boolean sendDelete, int userId) {
|
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);
|
mustHaveFlags, mustNotHaveFlags);
|
||||||
|
|
||||||
synchronized (mNotificationList) {
|
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
|
* Cancels all notifications from a given package that have all of the
|
||||||
* {@code mustHaveFlags}.
|
* {@code mustHaveFlags}.
|
||||||
*/
|
*/
|
||||||
boolean cancelAllNotificationsInt(String pkg, int mustHaveFlags,
|
boolean cancelAllNotificationsInt(String pkg, int mustHaveFlags,
|
||||||
int mustNotHaveFlags, boolean doit, int userId) {
|
int mustNotHaveFlags, boolean doit, int userId) {
|
||||||
EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL_ALL, pkg, mustHaveFlags,
|
EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL_ALL, pkg, userId,
|
||||||
mustNotHaveFlags);
|
mustHaveFlags, mustNotHaveFlags);
|
||||||
|
|
||||||
synchronized (mNotificationList) {
|
synchronized (mNotificationList) {
|
||||||
final int N = mNotificationList.size();
|
final int N = mNotificationList.size();
|
||||||
boolean canceledSomething = false;
|
boolean canceledSomething = false;
|
||||||
for (int i = N-1; i >= 0; --i) {
|
for (int i = N-1; i >= 0; --i) {
|
||||||
NotificationRecord r = mNotificationList.get(i);
|
NotificationRecord r = mNotificationList.get(i);
|
||||||
if (userId != UserHandle.USER_ALL && r.userId != userId) {
|
if (!notificationMatchesUserId(r, userId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((r.notification.flags & mustHaveFlags) != mustHaveFlags) {
|
if ((r.notification.flags & mustHaveFlags) != mustHaveFlags) {
|
||||||
@@ -1322,7 +1336,7 @@ public class NotificationManagerService extends INotificationManager.Stub
|
|||||||
for (int i=N-1; i>=0; i--) {
|
for (int i=N-1; i>=0; i--) {
|
||||||
NotificationRecord r = mNotificationList.get(i);
|
NotificationRecord r = mNotificationList.get(i);
|
||||||
|
|
||||||
if (r.userId != userId) {
|
if (!notificationMatchesUserId(r, userId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1376,7 +1390,7 @@ public class NotificationManagerService extends INotificationManager.Stub
|
|||||||
final int len = list.size();
|
final int len = list.size();
|
||||||
for (int i=0; i<len; i++) {
|
for (int i=0; i<len; i++) {
|
||||||
NotificationRecord r = list.get(i);
|
NotificationRecord r = list.get(i);
|
||||||
if (r.userId != userId || r.id != id) {
|
if (!notificationMatchesUserId(r, userId) || r.id != id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user