diff options
author | Daniel Sandler <dsandler@android.com> | 2013-08-01 09:35:16 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-08-01 09:35:16 -0700 |
commit | 87d01e9e83f33651872b3f3b2a1492c58d3846b5 (patch) | |
tree | e80861c1c986c9f4dc7da07cc4df1743d44c9307 /services/java/com/android/server/NotificationManagerService.java | |
parent | 9171db279826ee91d64eb9538a504ffed5e53b38 (diff) | |
parent | 9e6f26a8e1e69b1c49676d60a5ebe36c0a0f23f9 (diff) |
am 9e6f26a8: am f3e2f8fe: am 9eb434c3: Allow the user to block notifications for foreground services.
* commit '9e6f26a8e1e69b1c49676d60a5ebe36c0a0f23f9':
Allow the user to block notifications for foreground services.
Diffstat (limited to 'services/java/com/android/server/NotificationManagerService.java')
-rw-r--r-- | services/java/com/android/server/NotificationManagerService.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index 3ac05fd35d4c..1e8a589992d1 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -1633,7 +1633,7 @@ public class NotificationManagerService extends INotificationManager.Stub Slog.v(TAG, "enqueueNotificationInternal: pkg=" + pkg + " id=" + id + " notification=" + notification); } checkCallerIsSystemOrSameApp(pkg); - final boolean isSystemNotification = isCallerSystem() || ("android".equals(pkg)); + final boolean isSystemNotification = isUidSystem(callingUid) || ("android".equals(pkg)); final int userId = ActivityManager.handleIncomingUser(callingPid, callingUid, incomingUserId, true, false, "enqueueNotification", pkg); @@ -2151,14 +2151,18 @@ public class NotificationManagerService extends INotificationManager.Stub cancelAllNotificationsInt(pkg, 0, Notification.FLAG_FOREGROUND_SERVICE, true, userId); } - // Return true if the caller is a system or phone UID and therefore should not have + // Return true if the UID is a system or phone UID and therefore should not have // any notifications or toasts blocked. - boolean isCallerSystem() { - final int uid = Binder.getCallingUid(); + boolean isUidSystem(int uid) { final int appid = UserHandle.getAppId(uid); return (appid == Process.SYSTEM_UID || appid == Process.PHONE_UID || uid == 0); } + // same as isUidSystem(int, int) for the Binder caller's UID. + boolean isCallerSystem() { + return isUidSystem(Binder.getCallingUid()); + } + void checkCallerIsSystem() { if (isCallerSystem()) { return; |