diff options
author | Daniel Sandler <dsandler@android.com> | 2013-06-11 14:13:28 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-06-11 14:13:28 -0700 |
commit | ffcec1d4bd0f88a41b57493cf342b28f130d38e2 (patch) | |
tree | c3ea0b742197671b7002f71e12a884d5dcc3ecd0 /services/java/com/android/server/NotificationManagerService.java | |
parent | cf88be6dc843d972c98ff100430b16aa22c60516 (diff) | |
parent | 0a2ff8db4339261d701ad542ac770fb92bf2127b (diff) |
am 0a2ff8db: am 4e5694aa: Merge "Do not block notifications or toasts for SYSTEM_UID or PHONE_UID." into jb-mr2-dev
* commit '0a2ff8db4339261d701ad542ac770fb92bf2127b':
Do not block notifications or toasts for SYSTEM_UID or PHONE_UID.
Diffstat (limited to 'services/java/com/android/server/NotificationManagerService.java')
-rw-r--r-- | services/java/com/android/server/NotificationManagerService.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index f4065ed0ef89..6ddf3a1bdc63 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -1390,7 +1390,7 @@ public class NotificationManagerService extends INotificationManager.Stub return ; } - final boolean isSystemToast = ("android".equals(pkg)); + final boolean isSystemToast = isCallerSystem() || ("android".equals(pkg)); if (ENABLE_BLOCKED_TOASTS && !noteNotificationOp(pkg, Binder.getCallingUid())) { if (!isSystemToast) { @@ -1608,7 +1608,7 @@ public class NotificationManagerService extends INotificationManager.Stub Slog.v(TAG, "enqueueNotificationInternal: pkg=" + pkg + " id=" + id + " notification=" + notification); } checkCallerIsSystemOrSameApp(pkg); - final boolean isSystemNotification = ("android".equals(pkg)); + final boolean isSystemNotification = isCallerSystem() || ("android".equals(pkg)); userId = ActivityManager.handleIncomingUser(callingPid, callingUid, userId, true, false, "enqueueNotification", pkg); @@ -2084,19 +2084,26 @@ 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 + // any notifications or toasts blocked. + boolean isCallerSystem() { + final int uid = Binder.getCallingUid(); + final int appid = UserHandle.getAppId(uid); + return (appid == Process.SYSTEM_UID || appid == Process.PHONE_UID || uid == 0); + } + void checkCallerIsSystem() { - int uid = Binder.getCallingUid(); - if (UserHandle.getAppId(uid) == Process.SYSTEM_UID || uid == 0) { + if (isCallerSystem()) { return; } - throw new SecurityException("Disallowed call for uid " + uid); + throw new SecurityException("Disallowed call for uid " + Binder.getCallingUid()); } void checkCallerIsSystemOrSameApp(String pkg) { - int uid = Binder.getCallingUid(); - if (UserHandle.getAppId(uid) == Process.SYSTEM_UID || uid == 0) { + if (isCallerSystem()) { return; } + final int uid = Binder.getCallingUid(); try { ApplicationInfo ai = AppGlobals.getPackageManager().getApplicationInfo( pkg, 0, UserHandle.getCallingUserId()); |