am fe218700: am 3a82ad59: Fix migration from Email1 to Email2 when using combined inbox.
* commit 'fe2187007af76fe8750367e7fdc6147efc6a0dea':
Fix migration from Email1 to Email2 when using combined inbox.
diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java
index cbef1c0..2b230e0 100644
--- a/src/com/android/email/provider/EmailProvider.java
+++ b/src/com/android/email/provider/EmailProvider.java
@@ -866,7 +866,7 @@
// 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 @@
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 @@
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 @@
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 65f3dfb..52b51ca 100644
--- a/src/com/android/email/provider/WidgetProvider.java
+++ b/src/com/android/email/provider/WidgetProvider.java
@@ -98,6 +98,9 @@
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 @@
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),