diff options
| author | 2014-08-20 16:09:01 +0000 | |
|---|---|---|
| committer | 2014-08-16 04:32:18 +0000 | |
| commit | 0fc2ff7b8a70a7066b484e1519daa17e2dd2f147 (patch) | |
| tree | 28d58b3df5826d953491e202df6a2d18dddf203c | |
| parent | 9b4d6dd3db3cb9d61369e0fcd152580e3141015e (diff) | |
| parent | 38156c504e49e685b67b5f003a11876438157c4f (diff) | |
Merge "Add check to allow notification listener packages to post >50 notifications" into lmp-dev
| -rw-r--r-- | services/core/java/com/android/server/notification/NotificationManagerService.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 7117933e0333..45bd812af943 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -1528,14 +1528,15 @@ public class NotificationManagerService extends SystemService { } checkCallerIsSystemOrSameApp(pkg); final boolean isSystemNotification = isUidSystem(callingUid) || ("android".equals(pkg)); + final boolean isNotificationFromListener = mListeners.isListenerPackage(pkg); final int userId = ActivityManager.handleIncomingUser(callingPid, callingUid, incomingUserId, true, false, "enqueueNotification", pkg); final UserHandle user = new UserHandle(userId); // Limit the number of notifications that any given package except the android - // package can enqueue. Prevents DOS attacks and deals with leaks. - if (!isSystemNotification) { + // package or a registered listener can enqueue. Prevents DOS attacks and deals with leaks. + if (!isSystemNotification && !isNotificationFromListener) { synchronized (mNotificationList) { int count = 0; final int N = mNotificationList.size(); @@ -2720,6 +2721,21 @@ public class NotificationManagerService extends SystemService { Log.e(TAG, "unable to notify listener (listener hints): " + listener, ex); } } + + private boolean isListenerPackage(String packageName) { + if (packageName == null) { + return false; + } + // TODO: clean up locking object later + synchronized (mNotificationList) { + for (final ManagedServiceInfo serviceInfo : mServices) { + if (packageName.equals(serviceInfo.component.getPackageName())) { + return true; + } + } + } + return false; + } } public static final class DumpFilter { |