diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index cbef1c0bd..2b230e019 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -866,7 +866,7 @@ public class EmailProvider extends ContentProvider { // A specific mailbox // insert into this URI causes a message to be added to the mailbox // ** NOTE For now, the accountKey must be set manually in the values! - matcher.addURI(EmailContent.AUTHORITY, "mailbox/#", MAILBOX_ID); + matcher.addURI(EmailContent.AUTHORITY, "mailbox/*", MAILBOX_ID); matcher.addURI(EmailContent.AUTHORITY, "mailboxNotification/#", MAILBOX_NOTIFICATION); matcher.addURI(EmailContent.AUTHORITY, "mailboxMostRecentMessage/#", @@ -1720,7 +1720,7 @@ public class EmailProvider extends ContentProvider { AttachmentDownloadService.attachmentChanged(context, id, flags); } }; - private AttachmentService mAttachmentService = DEFAULT_ATTACHMENT_SERVICE; + private final AttachmentService mAttachmentService = DEFAULT_ATTACHMENT_SERVICE; private Cursor notificationQuery(final Uri uri) { final SQLiteDatabase db = getDatabase(getContext()); @@ -2676,7 +2676,7 @@ public class EmailProvider extends ContentProvider { return "content://" + EmailContent.AUTHORITY + "/" + type + "/" + id; } - private static final long COMBINED_ACCOUNT_ID = 0x10000000; + public static final long COMBINED_ACCOUNT_ID = 0x10000000; /** * Generate an id for a combined mailbox of a given type @@ -2691,7 +2691,7 @@ public class EmailProvider extends ContentProvider { return Long.toString(getVirtualMailboxId(accountId, type)); } - private static long getVirtualMailboxId(long accountId, int type) { + public static long getVirtualMailboxId(long accountId, int type) { return (accountId << 32) + type; } diff --git a/src/com/android/email/provider/WidgetProvider.java b/src/com/android/email/provider/WidgetProvider.java index 65f3dfb88..52b51cab7 100644 --- a/src/com/android/email/provider/WidgetProvider.java +++ b/src/com/android/email/provider/WidgetProvider.java @@ -98,6 +98,9 @@ public class WidgetProvider extends BaseWidgetProvider { return; } + accountId = migrateLegacyWidgetAccountId(accountId); + mailboxId = migrateLegacyWidgetMailboxId(mailboxId, accountId); + // Get Account and folder objects for the account id and mailbox id final com.android.mail.providers.Account uiAccount = getAccount(context, accountId); final Folder uiFolder = getFolder(context, mailboxId); @@ -116,6 +119,26 @@ public class WidgetProvider extends BaseWidgetProvider { editor.apply(); } + private long migrateLegacyWidgetAccountId(long accountId) { + if (accountId == Account.ACCOUNT_ID_COMBINED_VIEW) { + return EmailProvider.COMBINED_ACCOUNT_ID; + } + return accountId; + } + + /** + * @param accountId The migrated accountId + * @return + */ + private long migrateLegacyWidgetMailboxId(long mailboxId, long accountId) { + if (mailboxId == Mailbox.QUERY_ALL_INBOXES) { + return EmailProvider.getVirtualMailboxId(accountId, Mailbox.TYPE_INBOX); + } else if (mailboxId == Mailbox.QUERY_ALL_UNREAD) { + return EmailProvider.getVirtualMailboxId(accountId, Mailbox.TYPE_ALL_UNREAD); + } + return mailboxId; + } + private static com.android.mail.providers.Account getAccount(Context context, long accountId) { final ContentResolver resolver = context.getContentResolver(); final Cursor ac = resolver.query(EmailProvider.uiUri("uiaccount", accountId),