summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/NotificationManagerService.java
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2013-08-01 09:32:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-08-01 09:32:40 -0700
commit9e6f26a8e1e69b1c49676d60a5ebe36c0a0f23f9 (patch)
tree72492b4258f2cd075104dde3a4b7049d65e18070 /services/java/com/android/server/NotificationManagerService.java
parent368d81fe185ed4484e3258a160416e6567896e31 (diff)
parentf3e2f8feef1a22708cc7ce1a7bc5d914bb53933d (diff)
am f3e2f8fe: am 9eb434c3: Allow the user to block notifications for foreground services.
* commit 'f3e2f8feef1a22708cc7ce1a7bc5d914bb53933d': 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.java12
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 29aaeaf33f4f..29780c06e8e5 100644
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -1606,7 +1606,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));
userId = ActivityManager.handleIncomingUser(callingPid,
callingUid, userId, true, false, "enqueueNotification", pkg);
@@ -2084,14 +2084,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;