summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Julia Reynolds <juliacr@google.com> 2019-08-20 19:00:05 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-08-20 19:00:05 +0000
commitf1499a4e5d71bfeac46eb576e5e3d18a86da034f (patch)
treedca50380c62348a9f47b61f90c63a1311c29c064
parent9fbbd5716fec72ca8179dc769479f7dd7057163f (diff)
parentb740ed72b93e4671ced674456b2eaac26fda5ab9 (diff)
Merge "Crash app on foreground service notification error."
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 3ed776348f47..30b2245ec24e 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -911,8 +911,22 @@ public class NotificationManagerService extends SystemService {
@Override
public void onNotificationError(int callingUid, int callingPid, String pkg, String tag,
int id, int uid, int initialPid, String message, int userId) {
+ final boolean fgService;
+ synchronized (mNotificationLock) {
+ NotificationRecord r = findNotificationLocked(pkg, tag, id, userId);
+ fgService = r != null && (r.getNotification().flags & FLAG_FOREGROUND_SERVICE) != 0;
+ }
cancelNotification(callingUid, callingPid, pkg, tag, id, 0, 0, false, userId,
REASON_ERROR, null);
+ if (fgService) {
+ // Still crash for foreground services, preventing the not-crash behaviour abused
+ // by apps to give us a garbage notification and silently start a fg service.
+ Binder.withCleanCallingIdentity(
+ () -> mAm.crashApplication(uid, initialPid, pkg, -1,
+ "Bad notification(tag=" + tag + ", id=" + id + ") posted from package "
+ + pkg + ", crashing app(uid=" + uid + ", pid=" + initialPid + "): "
+ + message));
+ }
}
@Override