Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d46ef37 authored by Da Xing's avatar Da Xing Committed by android-build-merger
Browse files

Merge "Crash app on foreground service notification error." am: 036ea39d am: ebf0ccf2

am: 7dc7622d

Change-Id: Icf725c22df4041be24fc68bdfd854887d3e8c9be
parents 8de0b9de 7dc7622d
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -901,8 +901,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