Don't crash apps on notification error

Apps cannot recover from this error, and crashing is a bad user
experience.

Test: none
Bug: 30529567
Change-Id: I088ab04f8efeb5fa2483520141c54e90ff441ba4
This commit is contained in:
Julia Reynolds
2018-04-17 09:36:30 -04:00
parent bae834c061
commit 3ad4cdd107

View File

@@ -782,18 +782,8 @@ public class NotificationManagerService extends SystemService {
@Override @Override
public void onNotificationError(int callingUid, int callingPid, String pkg, String tag, int id, public void onNotificationError(int callingUid, int callingPid, String pkg, String tag, int id,
int uid, int initialPid, String message, int userId) { int uid, int initialPid, String message, int userId) {
Slog.d(TAG, "onNotification error pkg=" + pkg + " tag=" + tag + " id=" + id
+ "; will crashApplication(uid=" + uid + ", pid=" + initialPid + ")");
cancelNotification(callingUid, callingPid, pkg, tag, id, 0, 0, false, userId, cancelNotification(callingUid, callingPid, pkg, tag, id, 0, 0, false, userId,
REASON_ERROR, null); REASON_ERROR, null);
long ident = Binder.clearCallingIdentity();
try {
ActivityManager.getService().crashApplication(uid, initialPid, pkg, -1,
"Bad notification posted from package " + pkg
+ ": " + message);
} catch (RemoteException e) {
}
Binder.restoreCallingIdentity(ident);
} }
@Override @Override