summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/res/AndroidManifest.xml2
-rw-r--r--services/java/com/android/server/NotificationManagerService.java10
2 files changed, 8 insertions, 4 deletions
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 1b4adc5..1da99ad 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1943,7 +1943,7 @@
android:protectionLevel="signature" />
<!-- Allows an application to cancel notifications from other apps
- -->
+ @hide -->
<permission android:name="android.permission.CANCEL_NOTIFICATIONS"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signature|system"
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 4928a86..4bbf452 100644
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -1554,7 +1554,7 @@ public class NotificationManagerService extends INotificationManager.Stub
}
public void cancelNotificationWithTag(String pkg, String tag, int id, int userId) {
- checkCallerIsSystemOrSameApp(pkg);
+ checkCallerCanCancelNotification(pkg);
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userId, true, false, "cancelNotificationWithTag", pkg);
// Don't allow client applications to cancel foreground service notis.
@@ -1564,7 +1564,7 @@ public class NotificationManagerService extends INotificationManager.Stub
}
public void cancelAllNotifications(String pkg, int userId) {
- checkCallerIsSystemOrSameApp(pkg);
+ checkCallerCanCancelNotification(pkg);
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userId, true, false, "cancelAllNotifications", pkg);
@@ -1582,11 +1582,15 @@ public class NotificationManagerService extends INotificationManager.Stub
throw new SecurityException("Disallowed call for uid " + uid);
}
- void checkCallerIsSystemOrSameApp(String pkg) {
+ void checkCallerCanCancelNotification(String pkg) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.CANCEL_NOTIFICATIONS)
== PackageManager.PERMISSION_GRANTED) {
return;
}
+ checkCallerIsSystemOrSameApp(pkg);
+ }
+
+ void checkCallerIsSystemOrSameApp(String pkg) {
int uid = Binder.getCallingUid();
if (UserHandle.getAppId(uid) == Process.SYSTEM_UID || uid == 0) {
return;