From 32e698b12fc85a25463d536fb6f231f14a07b448 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Thu, 18 Apr 2013 10:51:35 -0400 Subject: Once again, cancel all when notifications canceled for pkg. Right now this only works if you go through the front door (using setNotificationsEnabledForPackage()); if you set the AppOps for a package otherwise the existing notifications will not be cleared (but new ones will be blocked). Since there's no UI for modifying AppOps today this shouldn't be a problem. Bug: 8489214 Change-Id: I84f8c76a0d03959127e9076ab2b7d37dbdaebb17 --- .../java/com/android/server/NotificationManagerService.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index 3bebf91a922c..9a93f637e072 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -450,11 +450,16 @@ public class NotificationManagerService extends INotificationManager.Stub public void setNotificationsEnabledForPackage(String pkg, int uid, boolean enabled) { checkCallerIsSystem(); - if (true||DBG) { - Slog.v(TAG, (enabled?"en":"dis") + "abling notifications for " + pkg); - } + + Slog.v(TAG, (enabled?"en":"dis") + "abling notifications for " + pkg); + mAppOps.setMode(AppOpsManager.OP_POST_NOTIFICATION, uid, pkg, enabled ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED); + + // Now, cancel any outstanding notifications that are part of a just-disabled app + if (ENABLE_BLOCKED_NOTIFICATIONS && !enabled) { + cancelAllNotificationsInt(pkg, 0, 0, true, UserHandle.getUserId(uid)); + } } -- cgit v1.2.3-59-g8ed1b