summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Da Xing <qiyueliuhuo813@gmail.com> 2019-09-06 22:14:31 -0700
committer android-build-merger <android-build-merger@google.com> 2019-09-06 22:14:31 -0700
commit7dc7622d5f2f197987f8b70e11196c3ecb6b6339 (patch)
tree1fa7768c31771fd08a3cddb2a569faa4a57da177
parentefa011f8a34fed06ca75dd29663bf20a5c484163 (diff)
parentebf0ccf2dc8b817678f4b67b9e77745ea91fe8e2 (diff)
Merge "Crash app on foreground service notification error." am: 036ea39d96
am: ebf0ccf2dc Change-Id: Ib0312f964bc8d67aec37143e955a36fb919130cc
-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 d358f9a1a553..cc2df509bb91 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -892,8 +892,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