diff --git a/src/com/android/email/NotificationController.java b/src/com/android/email/NotificationController.java index 3fdb4de2a..b3fb7cc94 100644 --- a/src/com/android/email/NotificationController.java +++ b/src/com/android/email/NotificationController.java @@ -514,7 +514,7 @@ public class NotificationController { * as well as special login/security notifications. */ public static void cancelNotifications(final Context context, final Account account) { - NotificationUtils.clearAccountNotifications(context, account.mEmailAddress); + NotificationUtils.clearAccountNotifications(context, account.mAmAccount); final NotificationManager notificationManager = getInstance(context).mNotificationManager; @@ -559,6 +559,12 @@ public class NotificationController { accountCursor.close(); } + if (account == null) { + LogUtils.d(LOG_TAG, "Tried to create a notification for a missing account %d", + mAccountId); + return; + } + final Cursor mailboxCursor = contentResolver.query( ContentUris.withAppendedId(EmailContent.MAILBOX_NOTIFICATION_URI, mAccountId), null, null, null, null); @@ -678,6 +684,7 @@ public class NotificationController { try { mLock.wait(); } catch (InterruptedException ex) { + // Loop around and wait again } } }