From c9864af20fe2c1d16d8b7b5fdaec0856d4a7f93a Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 19 Jun 2012 15:34:16 -0700 Subject: [PATCH] Replace literal "eas", "pop3", "imap" with constants Change-Id: If3f4712acd39663e548f271ffaa2fb7b4f5656d4 --- .../src/com/android/emailcommon/provider/Account.java | 4 ++-- .../android/email/activity/setup/AccountSettingsUtils.java | 5 +++-- .../android/email/activity/setup/AccountSetupOptions.java | 3 ++- .../com/android/email/activity/setup/AccountSetupType.java | 2 +- .../src/com/android/email/activity/setup/DebugFragment.java | 4 +++- email2/src/com/android/email/provider/EmailProvider.java | 2 +- email2/src/com/android/email/service/AccountService.java | 3 ++- .../email/service/EmailBroadcastProcessorService.java | 4 ++-- email2/src/com/android/email/service/MailService.java | 6 ++++-- email2/src/com/android/email2/ui/MailActivityEmail.java | 4 +++- 10 files changed, 23 insertions(+), 14 deletions(-) diff --git a/email2/emailcommon/src/com/android/emailcommon/provider/Account.java b/email2/emailcommon/src/com/android/emailcommon/provider/Account.java index 3914176ed..ad0a6633f 100755 --- a/email2/emailcommon/src/com/android/emailcommon/provider/Account.java +++ b/email2/emailcommon/src/com/android/emailcommon/provider/Account.java @@ -461,12 +461,12 @@ public final class Account extends EmailContent implements AccountColumns, Parce * Use caution when you use this on the main thread. */ public boolean isEasAccount(Context context) { - return "eas".equals(getProtocol(context)); + return HostAuth.SCHEME_EAS.equals(getProtocol(context)); } public boolean supportsMoveMessages(Context context) { String protocol = getProtocol(context); - return "eas".equals(protocol) || "imap".equals(protocol); + return HostAuth.SCHEME_EAS.equals(protocol) || HostAuth.SCHEME_IMAP.equals(protocol); } /** diff --git a/email2/src/com/android/email/activity/setup/AccountSettingsUtils.java b/email2/src/com/android/email/activity/setup/AccountSettingsUtils.java index 8265bf7b3..a9b092f9e 100644 --- a/email2/src/com/android/email/activity/setup/AccountSettingsUtils.java +++ b/email2/src/com/android/email/activity/setup/AccountSettingsUtils.java @@ -30,6 +30,7 @@ import com.android.email.VendorPolicyLoader; import com.android.email.provider.AccountBackupRestore; import com.android.emailcommon.Logging; import com.android.emailcommon.provider.Account; +import com.android.emailcommon.provider.HostAuth; import com.android.emailcommon.provider.EmailContent.AccountColumns; import com.android.emailcommon.provider.QuickResponse; import com.google.common.annotations.VisibleForTesting; @@ -294,8 +295,8 @@ public class AccountSettingsUtils { if (firstDotIndex != -1) { // look at first word and decide what to do String firstWord = server.substring(0, firstDotIndex).toLowerCase(); - boolean isImapOrPop = "imap".equals(firstWord) - || "pop3".equals(firstWord) || "pop".equals(firstWord); + boolean isImapOrPop = HostAuth.SCHEME_IMAP.equals(firstWord) + || "pop".equals(firstWord) || HostAuth.SCHEME_POP3.equals(firstWord); boolean isMail = "mail".equals(firstWord); // Now decide what to do if (incoming != null) { diff --git a/email2/src/com/android/email/activity/setup/AccountSetupOptions.java b/email2/src/com/android/email/activity/setup/AccountSetupOptions.java index 2ebb85ff5..b99f63032 100644 --- a/email2/src/com/android/email/activity/setup/AccountSetupOptions.java +++ b/email2/src/com/android/email/activity/setup/AccountSetupOptions.java @@ -44,6 +44,7 @@ import com.android.email.service.MailService; import com.android.email2.ui.MailActivityEmail; import com.android.emailcommon.Logging; import com.android.emailcommon.provider.Account; +import com.android.emailcommon.provider.HostAuth; import com.android.emailcommon.provider.Policy; import com.android.emailcommon.service.SyncWindow; import com.android.emailcommon.utility.Utility; @@ -224,7 +225,7 @@ public class AccountSetupOptions extends AccountSetupActivity implements OnClick boolean calendar = false; boolean contacts = false; boolean email = mSyncEmailView.isChecked(); - if (account.mHostAuthRecv.mProtocol.equals("eas")) { + if (account.mHostAuthRecv.mProtocol.equals(HostAuth.SCHEME_EAS)) { if (SetupData.getPolicy() != null) { account.mFlags |= Account.FLAGS_SECURITY_HOLD; account.mPolicy = SetupData.getPolicy(); diff --git a/email2/src/com/android/email/activity/setup/AccountSetupType.java b/email2/src/com/android/email/activity/setup/AccountSetupType.java index 07123f079..a0fa0310f 100644 --- a/email2/src/com/android/email/activity/setup/AccountSetupType.java +++ b/email2/src/com/android/email/activity/setup/AccountSetupType.java @@ -55,7 +55,7 @@ public class AccountSetupType extends AccountSetupActivity implements OnClickLis // If we're in account setup flow mode, for EAS, skip this screen and "click" EAS if (flowMode == SetupData.FLOW_MODE_ACCOUNT_MANAGER_EAS) { - onSelect("eas"); + onSelect(HostAuth.SCHEME_EAS); return; } diff --git a/email2/src/com/android/email/activity/setup/DebugFragment.java b/email2/src/com/android/email/activity/setup/DebugFragment.java index e3ab807c5..ac2eae9a5 100644 --- a/email2/src/com/android/email/activity/setup/DebugFragment.java +++ b/email2/src/com/android/email/activity/setup/DebugFragment.java @@ -35,6 +35,7 @@ import com.android.email.activity.UiUtilities; import com.android.email.service.EmailServiceUtils; import com.android.email2.ui.MailActivityEmail; import com.android.emailcommon.Logging; +import com.android.emailcommon.provider.HostAuth; public class DebugFragment extends Fragment implements OnCheckedChangeListener, View.OnClickListener { @@ -72,7 +73,8 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener, // Note: To prevent recursion while presetting checkboxes, assign all listeners last mEnableDebugLoggingView.setOnCheckedChangeListener(this); - boolean exchangeAvailable = EmailServiceUtils.isServiceAvailable(context, "eas"); + boolean exchangeAvailable = + EmailServiceUtils.isServiceAvailable(context, HostAuth.SCHEME_EAS); if (exchangeAvailable) { mEnableExchangeLoggingView.setChecked(MailActivityEmail.DEBUG_EXCHANGE_VERBOSE); mEnableExchangeFileLoggingView.setChecked(MailActivityEmail.DEBUG_EXCHANGE_FILE); diff --git a/email2/src/com/android/email/provider/EmailProvider.java b/email2/src/com/android/email/provider/EmailProvider.java index e6cc0d63f..438de869b 100644 --- a/email2/src/com/android/email/provider/EmailProvider.java +++ b/email2/src/com/android/email/provider/EmailProvider.java @@ -2529,7 +2529,7 @@ outer: Context context = getContext(); Mailbox mailbox = Mailbox.restoreMailboxWithId(context, mailboxId); // Make sure we can't get NPE if mailbox has disappeared (the result will end up moot) - String protocol = "eas"; + String protocol = HostAuth.SCHEME_EAS; if (mailbox != null) { protocol = Account.getProtocol(context, mailbox.mAccountKey); // "load more" is valid for IMAP/POP3 diff --git a/email2/src/com/android/email/service/AccountService.java b/email2/src/com/android/email/service/AccountService.java index da8637b16..1ce8d6302 100644 --- a/email2/src/com/android/email/service/AccountService.java +++ b/email2/src/com/android/email/service/AccountService.java @@ -32,6 +32,7 @@ import com.android.email2.ui.MailActivityEmail; import com.android.emailcommon.Configuration; import com.android.emailcommon.Device; import com.android.emailcommon.provider.Account; +import com.android.emailcommon.provider.HostAuth; import com.android.emailcommon.service.IAccountService; import com.android.emailcommon.utility.EmailAsyncTask; @@ -104,7 +105,7 @@ public class AccountService extends Service { @Override public void run() { // Make sure the service is properly running (re: lifecycle) - EmailServiceUtils.startService(mContext, "eas"); + EmailServiceUtils.startService(mContext, HostAuth.SCHEME_EAS); // Send current logging flags MailActivityEmail.updateLoggingFlags(mContext); }}); diff --git a/email2/src/com/android/email/service/EmailBroadcastProcessorService.java b/email2/src/com/android/email/service/EmailBroadcastProcessorService.java index e770465ef..390949183 100644 --- a/email2/src/com/android/email/service/EmailBroadcastProcessorService.java +++ b/email2/src/com/android/email/service/EmailBroadcastProcessorService.java @@ -131,7 +131,7 @@ public class EmailBroadcastProcessorService extends IntentService { performOneTimeInitialization(); // Starts the service for Exchange, if supported. - EmailServiceUtils.startService(this, "eas"); + EmailServiceUtils.startService(this, HostAuth.SCHEME_EAS); } private void performOneTimeInitialization() { @@ -207,6 +207,6 @@ public class EmailBroadcastProcessorService extends IntentService { // If the exchange service wasn't already running, starting it will cause exchange account // reconciliation to be performed. The service stops itself it there are no EAS accounts. - EmailServiceUtils.startService(this, "eas"); + EmailServiceUtils.startService(this, HostAuth.SCHEME_EAS); } } diff --git a/email2/src/com/android/email/service/MailService.java b/email2/src/com/android/email/service/MailService.java index 50704057d..43412c942 100644 --- a/email2/src/com/android/email/service/MailService.java +++ b/email2/src/com/android/email/service/MailService.java @@ -76,7 +76,9 @@ public class MailService extends Service { while (c.moveToNext()) { long accountId = c.getLong(Account.CONTENT_ID_COLUMN); String protocol = Account.getProtocol(context, accountId); - if ((protocol != null) && ("pop3".equals(protocol) || "imap".equals(protocol))) { + if ((protocol != null) && + (HostAuth.SCHEME_POP3.equals(protocol) || + HostAuth.SCHEME_IMAP.equals(protocol))) { Account account = Account.restoreAccountWithId(context, accountId); if (account != null) { providerAccounts.add(account); @@ -148,7 +150,7 @@ public class MailService extends Service { options.putBoolean(EasAuthenticatorService.OPTIONS_CONTACTS_SYNC_ENABLED, contacts); options.putBoolean(EasAuthenticatorService.OPTIONS_CALENDAR_SYNC_ENABLED, calendar); options.putBoolean(EasAuthenticatorService.OPTIONS_EMAIL_SYNC_ENABLED, email); - String accountType = hostAuthRecv.mProtocol.equals("eas") ? + String accountType = hostAuthRecv.mProtocol.equals(HostAuth.SCHEME_EAS) ? AccountManagerTypes.TYPE_EXCHANGE : AccountManagerTypes.TYPE_POP_IMAP; AccountManager.get(context).addAccount(accountType, null, null, options, null, callback, diff --git a/email2/src/com/android/email2/ui/MailActivityEmail.java b/email2/src/com/android/email2/ui/MailActivityEmail.java index f13550d24..05560f7bb 100644 --- a/email2/src/com/android/email2/ui/MailActivityEmail.java +++ b/email2/src/com/android/email2/ui/MailActivityEmail.java @@ -34,6 +34,7 @@ import com.android.email.service.MailService; import com.android.emailcommon.Logging; import com.android.emailcommon.TempDirectory; import com.android.emailcommon.provider.Account; +import com.android.emailcommon.provider.HostAuth; import com.android.emailcommon.service.EmailServiceProxy; import com.android.emailcommon.utility.EmailAsyncTask; import com.android.emailcommon.utility.Utility; @@ -193,7 +194,8 @@ public class MailActivityEmail extends com.android.mail.ui.MailActivity { int enableStrictMode = prefs.getEnableStrictMode() ? EmailServiceProxy.DEBUG_ENABLE_STRICT_MODE : 0; int debugBits = debugLogging | verboseLogging | fileLogging | enableStrictMode; - EmailServiceProxy service = EmailServiceUtils.getService(context, null, "eas"); + EmailServiceProxy service = + EmailServiceUtils.getService(context, null, HostAuth.SCHEME_EAS); if (service != null) { try { service.setLogging(debugBits);