Ensure undo notification is removed

If you archive a conversation through a notification action, then
launch the app, it clears the ^^unseen- label from the conversation.
As a result, if you then undo the action through the notification,
the undo notification remains in place, because we can't display the
original notification (as there are no longer any unseen messages).
Instead, we will explicitly cancel any notifications that should no
longer be around.

UR9 version of I634e8eeab5997b470f5f146e7269c2c923c9e5a9

Bug: 8250119
Change-Id: Id466166d2b67ce90241cfc2cd51fb65cfc26552f
diff --git a/src/com/android/mail/utils/NotificationUtils.java b/src/com/android/mail/utils/NotificationUtils.java
index a1ec555..a783b80 100644
--- a/src/com/android/mail/utils/NotificationUtils.java
+++ b/src/com/android/mail/utils/NotificationUtils.java
@@ -376,11 +376,15 @@
             final boolean getAttention) {
         boolean ignoreUnobtrusiveSetting = false;
 
+        final int notificationId = getNotificationId(account.name, folder);
+
         // Update the notification map
         final NotificationMap notificationMap = getNotificationMap(context);
         final NotificationKey key = new NotificationKey(account, folder);
         if (unreadCount == 0) {
             notificationMap.remove(key);
+            ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE))
+                    .cancel(notificationId);
         } else {
             if (!notificationMap.containsKey(key)) {
                 // This account previously didn't have any unread mail; ignore the "unobtrusive
@@ -398,7 +402,6 @@
                     getAttention);
         }
 
-        final int notificationId = getNotificationId(account.name, folder);
         if (NotificationActionUtils.sUndoNotifications.get(notificationId) == null) {
             validateNotifications(context, folder, account, getAttention, ignoreUnobtrusiveSetting,
                     key);