Allow legacy imap to sync

* Remove old (and dangerous) constants

Bug: 7210754
Bug: 7212263

Change-Id: I6a1463a653c5c4823a96c9fbb9ca37e53a45b48a
This commit is contained in:
Marc Blank 2012-09-21 17:49:26 -07:00
parent 9f05983f28
commit 54347010fb
5 changed files with 17 additions and 14 deletions

View File

@ -41,9 +41,6 @@ public final class HostAuth extends EmailContent implements HostAuthColumns, Par
}
// These legacy constants should be used in code created prior to Email2
public static final String LEGACY_SCHEME_IMAP = "imap";
public static final String LEGACY_SCHEME_POP3 = "pop3";
public static final String LEGACY_SCHEME_EAS = "eas";
public static final String LEGACY_SCHEME_SMTP = "smtp";
public static final String SCHEME_TRUST_ALL_CERTS = "trustallcerts";

View File

@ -540,7 +540,7 @@ public class AccountCheckSettingsFragment extends Fragment {
// Return "real" AD results
HostAuth auth = new HostAuth();
auth.setLogin("user", "password");
auth.setConnection(HostAuth.LEGACY_SCHEME_EAS, "testserver.com", 0);
auth.setConnection("eas", "testserver.com", 0);
return new AutoDiscoverResults(false, auth);
}
if (isCancelled()) return null;

View File

@ -55,6 +55,10 @@ import com.google.common.annotations.VisibleForTesting;
public final class DBHelper {
private static final String TAG = "EmailProvider";
private static final String LEGACY_SCHEME_IMAP = "imap";
private static final String LEGACY_SCHEME_POP3 = "pop3";
private static final String LEGACY_SCHEME_EAS = "eas";
private static final String WHERE_ID = EmailContent.RECORD_ID + "=?";
private static final String TRIGGER_MAILBOX_DELETE =
@ -570,6 +574,7 @@ public final class DBHelper {
createQuickResponseTable(db);
}
@Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion == 101 && newVersion == 100) {
Log.d(TAG, "Downgrade from v101 to v100");
@ -932,7 +937,7 @@ public final class DBHelper {
HostAuth.TABLE_NAME + " where " + Account.TABLE_NAME + "." +
AccountColumns.HOST_AUTH_KEY_RECV + "=" + HostAuth.TABLE_NAME + "." +
HostAuthColumns.ID + " and " + HostAuthColumns.PROTOCOL + "='" +
HostAuth.LEGACY_SCHEME_EAS + "')");
LEGACY_SCHEME_EAS + "')");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
Log.w(TAG, "Exception upgrading EmailProvider.db from 35 to 36 " + e);
@ -1119,8 +1124,8 @@ public final class DBHelper {
if (hostAuthCursor.moveToFirst()) {
String protocol = hostAuthCursor.getString(V21_HOSTAUTH_PROTOCOL);
// If this is a pop3 or imap account, create the account manager account
if (HostAuth.LEGACY_SCHEME_IMAP.equals(protocol) ||
HostAuth.LEGACY_SCHEME_POP3.equals(protocol)) {
if (LEGACY_SCHEME_IMAP.equals(protocol) ||
LEGACY_SCHEME_POP3.equals(protocol)) {
if (MailActivityEmail.DEBUG) {
Log.d(TAG, "Create AccountManager account for " + protocol +
"account: " +
@ -1131,7 +1136,7 @@ public final class DBHelper {
hostAuthCursor.getString(V21_HOSTAUTH_PASSWORD));
// If an EAS account, make Email sync automatically (equivalent of
// checking the "Sync Email" box in settings
} else if (HostAuth.LEGACY_SCHEME_EAS.equals(protocol)) {
} else if (LEGACY_SCHEME_EAS.equals(protocol)) {
android.accounts.Account amAccount =
new android.accounts.Account(
accountCursor.getString(V21_ACCOUNT_EMAIL),
@ -1215,7 +1220,7 @@ public final class DBHelper {
if (hostAuthCursor.moveToFirst()) {
String protocol = hostAuthCursor.getString(V25_HOSTAUTH_PROTOCOL);
// If this is an imap account, add the search flag
if (HostAuth.LEGACY_SCHEME_IMAP.equals(protocol)) {
if (LEGACY_SCHEME_IMAP.equals(protocol)) {
String id = accountCursor.getString(V25_ACCOUNT_ID);
int flags = accountCursor.getInt(V25_ACCOUNT_FLAGS);
cv.put(AccountColumns.FLAGS, flags | Account.FLAGS_SUPPORTS_SEARCH);
@ -1320,7 +1325,7 @@ public final class DBHelper {
HostAuth.TABLE_NAME + " where " + Account.TABLE_NAME + "." +
AccountColumns.HOST_AUTH_KEY_RECV + "=" + HostAuth.TABLE_NAME + "." +
HostAuthColumns.ID + " and " + HostAuthColumns.PROTOCOL + "='" +
HostAuth.LEGACY_SCHEME_EAS + "')");
LEGACY_SCHEME_EAS + "')");
} catch (SQLException e) {
Log.w(TAG, "Exception upgrading EmailProvider.db from 35/36 to 37/100 " + e);
}

View File

@ -28,10 +28,10 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.email.NotificationController;
import com.android.email.R;
import com.android.email.mail.Sender;
import com.android.email.mail.Store;
import com.android.email.provider.Utilities;
import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Api;
import com.android.emailcommon.Logging;
@ -107,8 +107,9 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
if (mailbox == null) return;
Account account = Account.restoreAccountWithId(mContext, mailbox.mAccountKey);
if (account == null) return;
EmailServiceInfo info = EmailServiceUtils.getServiceInfoForAccount(mContext, account.mId);
android.accounts.Account acct = new android.accounts.Account(account.mEmailAddress,
mContext.getString(R.string.account_manager_type_pop3));
info.accountType);
Bundle extras = new Bundle();
extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
extras.putLong(SYNC_EXTRA_MAILBOX_ID, mailboxId);

View File

@ -39,7 +39,6 @@ import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.provider.Mailbox;
import com.android.emailcommon.service.EmailServiceProxy;
@ -94,6 +93,7 @@ public class PopImapSyncAdapterService extends Service {
*/
private static boolean loadsFromServer(Context context, Mailbox m, String protocol) {
String legacyImapProtocol = context.getString(R.string.protocol_legacy_imap);
String pop3Protocol = context.getString(R.string.protocol_pop3);
if (legacyImapProtocol.equals(protocol)) {
// TODO: actually use a sync flag when creating the mailboxes. Right now we use an
// approximation for IMAP.
@ -101,7 +101,7 @@ public class PopImapSyncAdapterService extends Service {
&& m.mType != Mailbox.TYPE_OUTBOX
&& m.mType != Mailbox.TYPE_SEARCH;
} else if (HostAuth.LEGACY_SCHEME_POP3.equals(protocol)) {
} else if (pop3Protocol.equals(protocol)) {
return Mailbox.TYPE_INBOX == m.mType;
}