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

Commit 91a1789f authored by Brian's avatar Brian
Browse files

Call deleteIntent when swiping to remove a notification, similar to how

the clear button works.

Developers can set a deleteIntent that is called when the clear button is used
to remove all notificaitons, to perform any cleanup needed when deleting
a notificaiton without viewing it.  Since the swipe to remove is basically
a similar use case, but on a single notification, it should call this intent
(if defined) as well.

Change-Id: Idea238d1b8e3b9e5a285d5a8442f193f644f50e5

whitespace errors.
parent 8357ebd4
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -330,6 +330,23 @@ public class NotificationManagerService extends INotificationManager.Stub
        }

        public void onNotificationClear(String pkg, String tag, int id) {
            // Do this up here and not in cancelNotification, since that method is used more broadly. This gets called
            // specifically when we're canceling a notification from the status bar without clicking on it.
            synchronized (mNotificationList) {
                int index = indexOfNotificationLocked(pkg, tag, id);
                if (index >= 0) {
                    NotificationRecord r = mNotificationList.get(index);
                    if (r.notification.deleteIntent != null) {
                        try {
                            r.notification.deleteIntent.send();
                        } catch (PendingIntent.CanceledException ex) {
                            // do nothing - there's no relevant way to recover, and
                            // no reason to let this propagate
                            Slog.w(TAG, "canceled PendingIntent for " + r.pkg, ex);
                        }
                    }
                }
            }
            cancelNotification(pkg, tag, id, 0, Notification.FLAG_FOREGROUND_SERVICE);
        }