From bb68c13afa630cae058eb40d3ce68644f3f3c8b9 Mon Sep 17 00:00:00 2001 From: Paul Westbrook Date: Sun, 7 Sep 2014 13:36:33 -0700 Subject: [PATCH] Changes to support smaller email tombstone apk size This reduces the tombstone down by 100K A follow-on cl will remove the unused resources from the tombstone build Bug: 17414014 Change-Id: I5d38811b17a5273ec726e750ab123e10e36cee04 --- Android.mk | 1 + proguard.flags | 2 + .../com/android/email/AttachmentInfo.java | 0 .../com/android/email/DebugUtils.java | 0 .../email/EmailConnectivityManager.java | 0 .../com/android/email/EmailIntentService.java | 6 +- .../android/email/FixedLengthInputStream.java | 0 .../com/android/email/LegacyConversions.java | 0 .../android/email/NotificationController.java | 39 ++++ .../email/NotificationControllerCreator.java | 23 ++ .../NotificationControllerCreatorHolder.java | 42 ++++ .../android/email/PeekableInputStream.java | 0 .../com/android/email/Preferences.java | 0 .../com/android/email/ResourceHelper.java | 0 .../com/android/email/SecurityPolicy.java | 42 ++-- .../email/activity/setup/AccountSecurity.java | 0 .../activity/setup/AccountSettingsUtils.java | 0 .../activity/setup/ForwardingIntent.java | 0 .../com/android/email/mail/Sender.java | 0 .../com/android/email/mail/Store.java | 0 .../mail/internet/AuthenticationCache.java | 0 .../mail/internet/OAuthAuthenticator.java | 0 .../email/mail/store/ImapConnection.java | 0 .../android/email/mail/store/ImapFolder.java | 0 .../android/email/mail/store/ImapStore.java | 0 .../android/email/mail/store/Pop3Store.java | 0 .../email/mail/store/ServiceStore.java | 0 .../email/mail/store/imap/ImapConstants.java | 0 .../email/mail/store/imap/ImapElement.java | 0 .../email/mail/store/imap/ImapList.java | 0 .../mail/store/imap/ImapMemoryLiteral.java | 0 .../email/mail/store/imap/ImapResponse.java | 0 .../mail/store/imap/ImapResponseParser.java | 0 .../mail/store/imap/ImapSimpleString.java | 0 .../email/mail/store/imap/ImapString.java | 0 .../mail/store/imap/ImapTempFileLiteral.java | 0 .../email/mail/store/imap/ImapUtility.java | 0 .../email/mail/transport/DiscourseLogger.java | 0 .../email/mail/transport/MailTransport.java | 0 .../email/provider/AccountBackupRestore.java | 0 .../email/provider/AccountReconciler.java | 9 +- .../email/provider/AttachmentProvider.java | 0 .../android/email/provider/ContentCache.java | 0 .../com/android/email/provider/DBHelper.java | 0 .../provider/EmailConversationCursor.java | 0 .../email/provider/EmailMessageCursor.java | 0 .../android/email/provider/EmailProvider.java | 105 ++++++++- .../email/provider/FolderPickerActivity.java | 0 .../email/provider/FolderPickerCallback.java | 0 .../email/provider/FolderPickerDialog.java | 0 .../provider/FolderPickerSelectorAdapter.java | 0 .../email/provider/RefreshStatusMonitor.java | 0 .../com/android/email/provider/Utilities.java | 0 .../email/provider/WidgetProvider.java | 0 .../android/email/service/AccountService.java | 0 .../email/service/AttachmentService.java | 8 +- .../email/service/AuthenticatorService.java | 6 +- .../service/EasAuthenticatorService.java | 0 .../EasAuthenticatorServiceAlternate.java | 0 .../service/EasTestAuthenticatorService.java | 6 +- .../EmailBroadcastProcessorService.java | 0 .../email/service/EmailBroadcastReceiver.java | 0 .../email/service/EmailServiceStub.java | 12 +- .../email/service/EmailServiceUtils.java | 0 .../EmailUpgradeBroadcastReceiver.java | 0 .../service/ImapAuthenticatorService.java | 0 .../android/email/service/ImapService.java | 4 +- .../email/service/ImapTempFileLiteral.java | 0 .../LegacyEasAuthenticatorService.java | 0 .../LegacyEmailAuthenticatorService.java | 0 .../LegacyImapAuthenticatorService.java | 0 .../service/LegacyImapSyncAdapterService.java | 0 .../android/email/service/PolicyService.java | 0 .../service/Pop3AuthenticatorService.java | 0 .../android/email/service/Pop3Service.java | 10 +- .../email/service/Pop3SyncAdapterService.java | 0 .../service/PopImapSyncAdapterService.java | 0 .../setup/AuthenticatorSetupIntentHelper.java | 65 ++++++ src/com/android/email/EmailApplication.java | 8 + ....java => EmailNotificationController.java} | 33 ++- .../setup/AccountCreationFragment.java | 3 +- .../setup/AccountServerSettingsActivity.java | 3 +- .../setup/AccountSettingsFragment.java | 3 +- .../activity/setup/AccountSetupFinal.java | 40 +--- .../setup/AccountSetupNamesFragment.java | 9 +- .../setup/EmailPreferenceActivity.java | 3 +- .../setup/HeadlessAccountSettingsLoader.java | 7 - .../activity/setup/SetupDataFragment.java | 11 +- .../android/email2/ui/MailActivityEmail.java | 81 +------ .../providers/EmailAccountCacheProvider.java | 3 +- .../email/NotificationControllerTest.java | 55 ----- .../activity/ContactStatusLoaderTest.java | 210 ------------------ .../setup/AccountSetupIncomingTests.java | 3 +- .../setup/AccountSetupOptionsTests.java | 3 +- .../setup/AccountSetupOutgoingTests.java | 3 +- 95 files changed, 402 insertions(+), 456 deletions(-) rename {src => provider_src}/com/android/email/AttachmentInfo.java (100%) rename {src => provider_src}/com/android/email/DebugUtils.java (100%) rename {src => provider_src}/com/android/email/EmailConnectivityManager.java (100%) rename {src => provider_src}/com/android/email/EmailIntentService.java (85%) rename {src => provider_src}/com/android/email/FixedLengthInputStream.java (100%) rename {src => provider_src}/com/android/email/LegacyConversions.java (100%) create mode 100644 provider_src/com/android/email/NotificationController.java create mode 100644 provider_src/com/android/email/NotificationControllerCreator.java create mode 100644 provider_src/com/android/email/NotificationControllerCreatorHolder.java rename {src => provider_src}/com/android/email/PeekableInputStream.java (100%) rename {src => provider_src}/com/android/email/Preferences.java (100%) rename {src => provider_src}/com/android/email/ResourceHelper.java (100%) rename {src => provider_src}/com/android/email/SecurityPolicy.java (96%) rename {src => provider_src}/com/android/email/activity/setup/AccountSecurity.java (100%) rename {src => provider_src}/com/android/email/activity/setup/AccountSettingsUtils.java (100%) rename {src => provider_src}/com/android/email/activity/setup/ForwardingIntent.java (100%) rename {src => provider_src}/com/android/email/mail/Sender.java (100%) rename {src => provider_src}/com/android/email/mail/Store.java (100%) rename {src => provider_src}/com/android/email/mail/internet/AuthenticationCache.java (100%) rename {src => provider_src}/com/android/email/mail/internet/OAuthAuthenticator.java (100%) rename {src => provider_src}/com/android/email/mail/store/ImapConnection.java (100%) rename {src => provider_src}/com/android/email/mail/store/ImapFolder.java (100%) rename {src => provider_src}/com/android/email/mail/store/ImapStore.java (100%) rename {src => provider_src}/com/android/email/mail/store/Pop3Store.java (100%) rename {src => provider_src}/com/android/email/mail/store/ServiceStore.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapConstants.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapElement.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapList.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapMemoryLiteral.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapResponse.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapResponseParser.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapSimpleString.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapString.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapTempFileLiteral.java (100%) rename {src => provider_src}/com/android/email/mail/store/imap/ImapUtility.java (100%) rename {src => provider_src}/com/android/email/mail/transport/DiscourseLogger.java (100%) rename {src => provider_src}/com/android/email/mail/transport/MailTransport.java (100%) rename {src => provider_src}/com/android/email/provider/AccountBackupRestore.java (100%) rename {src => provider_src}/com/android/email/provider/AccountReconciler.java (97%) rename {src => provider_src}/com/android/email/provider/AttachmentProvider.java (100%) rename {src => provider_src}/com/android/email/provider/ContentCache.java (100%) rename {src => provider_src}/com/android/email/provider/DBHelper.java (100%) rename {src => provider_src}/com/android/email/provider/EmailConversationCursor.java (100%) rename {src => provider_src}/com/android/email/provider/EmailMessageCursor.java (100%) rename {src => provider_src}/com/android/email/provider/EmailProvider.java (98%) rename {src => provider_src}/com/android/email/provider/FolderPickerActivity.java (100%) rename {src => provider_src}/com/android/email/provider/FolderPickerCallback.java (100%) rename {src => provider_src}/com/android/email/provider/FolderPickerDialog.java (100%) rename {src => provider_src}/com/android/email/provider/FolderPickerSelectorAdapter.java (100%) rename {src => provider_src}/com/android/email/provider/RefreshStatusMonitor.java (100%) rename {src => provider_src}/com/android/email/provider/Utilities.java (100%) rename {src => provider_src}/com/android/email/provider/WidgetProvider.java (100%) rename {src => provider_src}/com/android/email/service/AccountService.java (100%) rename {src => provider_src}/com/android/email/service/AttachmentService.java (99%) rename {src => provider_src}/com/android/email/service/AuthenticatorService.java (96%) rename {src => provider_src}/com/android/email/service/EasAuthenticatorService.java (100%) rename {src => provider_src}/com/android/email/service/EasAuthenticatorServiceAlternate.java (100%) rename {src => provider_src}/com/android/email/service/EasTestAuthenticatorService.java (95%) rename {src => provider_src}/com/android/email/service/EmailBroadcastProcessorService.java (100%) rename {src => provider_src}/com/android/email/service/EmailBroadcastReceiver.java (100%) rename {src => provider_src}/com/android/email/service/EmailServiceStub.java (98%) rename {src => provider_src}/com/android/email/service/EmailServiceUtils.java (100%) rename {src => provider_src}/com/android/email/service/EmailUpgradeBroadcastReceiver.java (100%) rename {src => provider_src}/com/android/email/service/ImapAuthenticatorService.java (100%) rename {src => provider_src}/com/android/email/service/ImapService.java (99%) rename {src => provider_src}/com/android/email/service/ImapTempFileLiteral.java (100%) rename {src => provider_src}/com/android/email/service/LegacyEasAuthenticatorService.java (100%) rename {src => provider_src}/com/android/email/service/LegacyEmailAuthenticatorService.java (100%) rename {src => provider_src}/com/android/email/service/LegacyImapAuthenticatorService.java (100%) rename {src => provider_src}/com/android/email/service/LegacyImapSyncAdapterService.java (100%) rename {src => provider_src}/com/android/email/service/PolicyService.java (100%) rename {src => provider_src}/com/android/email/service/Pop3AuthenticatorService.java (100%) rename {src => provider_src}/com/android/email/service/Pop3Service.java (98%) rename {src => provider_src}/com/android/email/service/Pop3SyncAdapterService.java (100%) rename {src => provider_src}/com/android/email/service/PopImapSyncAdapterService.java (100%) create mode 100644 provider_src/com/android/email/setup/AuthenticatorSetupIntentHelper.java rename src/com/android/email/{NotificationController.java => EmailNotificationController.java} (97%) delete mode 100644 tests/src/com/android/email/NotificationControllerTest.java delete mode 100644 tests/src/com/android/email/activity/ContactStatusLoaderTest.java diff --git a/Android.mk b/Android.mk index 94135c95d..60d471196 100644 --- a/Android.mk +++ b/Android.mk @@ -34,6 +34,7 @@ LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-java-files-under, $(unified_email_dir)/src) LOCAL_SRC_FILES += $(call all-java-files-under, src/com/android) +LOCAL_SRC_FILES += $(call all-java-files-under, provider_src/com/android) LOCAL_SRC_FILES += $(call all-java-files-under, src/com/beetstra) LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dir)) diff --git a/proguard.flags b/proguard.flags index d21d40f7d..a4f9ee71c 100644 --- a/proguard.flags +++ b/proguard.flags @@ -3,3 +3,5 @@ -keepclasseswithmembers class * { public *** newInstance(com.android.emailcommon.provider.Account, android.content.Context); } + +-keepclasses class com.android.email.activity.setup.AccountSetupFinal diff --git a/src/com/android/email/AttachmentInfo.java b/provider_src/com/android/email/AttachmentInfo.java similarity index 100% rename from src/com/android/email/AttachmentInfo.java rename to provider_src/com/android/email/AttachmentInfo.java diff --git a/src/com/android/email/DebugUtils.java b/provider_src/com/android/email/DebugUtils.java similarity index 100% rename from src/com/android/email/DebugUtils.java rename to provider_src/com/android/email/DebugUtils.java diff --git a/src/com/android/email/EmailConnectivityManager.java b/provider_src/com/android/email/EmailConnectivityManager.java similarity index 100% rename from src/com/android/email/EmailConnectivityManager.java rename to provider_src/com/android/email/EmailConnectivityManager.java diff --git a/src/com/android/email/EmailIntentService.java b/provider_src/com/android/email/EmailIntentService.java similarity index 85% rename from src/com/android/email/EmailIntentService.java rename to provider_src/com/android/email/EmailIntentService.java index 7bf1b2d20..0c6d76178 100644 --- a/src/com/android/email/EmailIntentService.java +++ b/provider_src/com/android/email/EmailIntentService.java @@ -37,7 +37,11 @@ public class EmailIntentService extends MailIntentService { super.onHandleIntent(intent); if (UIProvider.ACTION_UPDATE_NOTIFICATION.equals(intent.getAction())) { - NotificationController.handleUpdateNotificationIntent(this, intent); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(this); + if (nc != null) { + nc.handleUpdateNotificationIntent(this, intent); + } } LogUtils.v(LOG_TAG, "Handling intent %s", intent); diff --git a/src/com/android/email/FixedLengthInputStream.java b/provider_src/com/android/email/FixedLengthInputStream.java similarity index 100% rename from src/com/android/email/FixedLengthInputStream.java rename to provider_src/com/android/email/FixedLengthInputStream.java diff --git a/src/com/android/email/LegacyConversions.java b/provider_src/com/android/email/LegacyConversions.java similarity index 100% rename from src/com/android/email/LegacyConversions.java rename to provider_src/com/android/email/LegacyConversions.java diff --git a/provider_src/com/android/email/NotificationController.java b/provider_src/com/android/email/NotificationController.java new file mode 100644 index 000000000..0bd25a8be --- /dev/null +++ b/provider_src/com/android/email/NotificationController.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.email; + +import android.content.Context; +import android.content.Intent; +import com.android.emailcommon.provider.Account; +import com.android.emailcommon.provider.EmailContent.Attachment; + + +public interface NotificationController { + void watchForMessages(); + void showDownloadForwardFailedNotificationSynchronous(Attachment attachment); + void showLoginFailedNotificationSynchronous(long accountId, boolean incoming); + void cancelLoginFailedNotification(long accountId); + void cancelNotifications(final Context context, final Account account); + void handleUpdateNotificationIntent(Context context, Intent intent); + void showSecurityNeededNotification(Account account); + void showSecurityUnsupportedNotification(Account account); + void showSecurityChangedNotification(Account account); + void cancelSecurityNeededNotification(); + void showPasswordExpiringNotificationSynchronous(long accountId); + void showPasswordExpiredNotificationSynchronous(long accountId); + void cancelPasswordExpirationNotifications(); +} diff --git a/provider_src/com/android/email/NotificationControllerCreator.java b/provider_src/com/android/email/NotificationControllerCreator.java new file mode 100644 index 000000000..76aa8162d --- /dev/null +++ b/provider_src/com/android/email/NotificationControllerCreator.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.email; + +import android.content.Context; + +public interface NotificationControllerCreator { + NotificationController getInstance(Context context); +} diff --git a/provider_src/com/android/email/NotificationControllerCreatorHolder.java b/provider_src/com/android/email/NotificationControllerCreatorHolder.java new file mode 100644 index 000000000..23824a4fa --- /dev/null +++ b/provider_src/com/android/email/NotificationControllerCreatorHolder.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.email; + +import android.content.Context; + +public class NotificationControllerCreatorHolder { + private static NotificationControllerCreator sCreator = + new NotificationControllerCreator() { + @Override + public NotificationController getInstance(Context context){ + return null; + } + }; + + public static void setNotificationControllerCreator( + NotificationControllerCreator creator) { + sCreator = creator; + } + + public static NotificationControllerCreator getNotificationControllerCreator() { + return sCreator; + } + + public static NotificationController getInstance(Context context) { + return getNotificationControllerCreator().getInstance(context); + } +} \ No newline at end of file diff --git a/src/com/android/email/PeekableInputStream.java b/provider_src/com/android/email/PeekableInputStream.java similarity index 100% rename from src/com/android/email/PeekableInputStream.java rename to provider_src/com/android/email/PeekableInputStream.java diff --git a/src/com/android/email/Preferences.java b/provider_src/com/android/email/Preferences.java similarity index 100% rename from src/com/android/email/Preferences.java rename to provider_src/com/android/email/Preferences.java diff --git a/src/com/android/email/ResourceHelper.java b/provider_src/com/android/email/ResourceHelper.java similarity index 100% rename from src/com/android/email/ResourceHelper.java rename to provider_src/com/android/email/ResourceHelper.java diff --git a/src/com/android/email/SecurityPolicy.java b/provider_src/com/android/email/SecurityPolicy.java similarity index 96% rename from src/com/android/email/SecurityPolicy.java rename to provider_src/com/android/email/SecurityPolicy.java index fe9f9b38f..58e77a22d 100644 --- a/src/com/android/email/SecurityPolicy.java +++ b/provider_src/com/android/email/SecurityPolicy.java @@ -32,6 +32,8 @@ import android.net.Uri; import android.os.Bundle; import android.os.RemoteException; +import com.android.email.NotificationController; +import com.android.email.NotificationControllerCreatorHolder; import com.android.email.provider.AccountReconciler; import com.android.email.provider.EmailProvider; import com.android.email.service.EmailBroadcastProcessorService; @@ -452,7 +454,9 @@ public class SecurityPolicy { setAccountHoldFlag(context, account, newState); if (newState) { // Make sure there's a notification up - NotificationController.getInstance(context).showSecurityNeededNotification(account); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(context); + nc.showSecurityNeededNotification(account); } } } @@ -499,11 +503,12 @@ public class SecurityPolicy { setAccountHoldFlag(mContext, account, true); // Put up an appropriate notification + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(mContext); if (policy.mProtocolPoliciesUnsupported == null) { - NotificationController.getInstance(mContext).showSecurityNeededNotification(account); + nc.showSecurityNeededNotification(account); } else { - NotificationController.getInstance(mContext).showSecurityUnsupportedNotification( - account); + nc.showSecurityUnsupportedNotification(account); } } @@ -612,14 +617,15 @@ public class SecurityPolicy { } boolean setHold = false; + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(mContext); if (policy.mProtocolPoliciesUnsupported != null) { // We can't support this, reasons in unsupportedRemotePolicies LogUtils.d(Logging.LOG_TAG, "Notify policies for " + account.mDisplayName + " not supported."); setHold = true; if (notify) { - NotificationController.getInstance(mContext).showSecurityUnsupportedNotification( - account); + nc.showSecurityUnsupportedNotification(account); } // Erase data Uri uri = EmailProvider.uiUri("uiaccountdata", accountId); @@ -630,8 +636,7 @@ public class SecurityPolicy { + " changed."); if (notify) { // Notify that policies changed - NotificationController.getInstance(mContext).showSecurityChangedNotification( - account); + nc.showSecurityChangedNotification(account); } } else { LogUtils.d(Logging.LOG_TAG, "Policy is active and unchanged; do not notify."); @@ -642,8 +647,7 @@ public class SecurityPolicy { " are not being enforced."); if (notify) { // Put up a notification - NotificationController.getInstance(mContext).showSecurityNeededNotification( - account); + nc.showSecurityNeededNotification(account); } } // Set/clear the account hold. @@ -655,7 +659,10 @@ public class SecurityPolicy { * cleared now. */ public void clearNotification() { - NotificationController.getInstance(mContext).cancelSecurityNeededNotification(); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(mContext); + + nc.cancelSecurityNeededNotification(); } /** @@ -754,17 +761,17 @@ public class SecurityPolicy { long expirationDate = getDPM().getPasswordExpiration(mAdminName); long timeUntilExpiration = expirationDate - System.currentTimeMillis(); boolean expired = timeUntilExpiration < 0; + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(context); if (!expired) { // 4. If warning, simply put up a generic notification and report that it came from // the shortest-expiring account. - NotificationController.getInstance(mContext).showPasswordExpiringNotificationSynchronous( - nextExpiringAccountId); + nc.showPasswordExpiringNotificationSynchronous(nextExpiringAccountId); } else { // 5. Actually expired - find all accounts that expire passwords, and wipe them boolean wiped = wipeExpiredAccounts(context); if (wiped) { - NotificationController.getInstance(mContext).showPasswordExpiredNotificationSynchronous( - nextExpiringAccountId); + nc.showPasswordExpiredNotificationSynchronous(nextExpiringAccountId); } } } @@ -838,7 +845,10 @@ public class SecurityPolicy { // Clear security holds (if any) Account.clearSecurityHoldOnAllAccounts(context); // Cancel any active notifications (if any are posted) - NotificationController.getInstance(context).cancelPasswordExpirationNotifications(); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(context); + + nc.cancelPasswordExpirationNotifications(); break; case DEVICE_ADMIN_MESSAGE_PASSWORD_EXPIRING: instance.onPasswordExpiring(instance.mContext); diff --git a/src/com/android/email/activity/setup/AccountSecurity.java b/provider_src/com/android/email/activity/setup/AccountSecurity.java similarity index 100% rename from src/com/android/email/activity/setup/AccountSecurity.java rename to provider_src/com/android/email/activity/setup/AccountSecurity.java diff --git a/src/com/android/email/activity/setup/AccountSettingsUtils.java b/provider_src/com/android/email/activity/setup/AccountSettingsUtils.java similarity index 100% rename from src/com/android/email/activity/setup/AccountSettingsUtils.java rename to provider_src/com/android/email/activity/setup/AccountSettingsUtils.java diff --git a/src/com/android/email/activity/setup/ForwardingIntent.java b/provider_src/com/android/email/activity/setup/ForwardingIntent.java similarity index 100% rename from src/com/android/email/activity/setup/ForwardingIntent.java rename to provider_src/com/android/email/activity/setup/ForwardingIntent.java diff --git a/src/com/android/email/mail/Sender.java b/provider_src/com/android/email/mail/Sender.java similarity index 100% rename from src/com/android/email/mail/Sender.java rename to provider_src/com/android/email/mail/Sender.java diff --git a/src/com/android/email/mail/Store.java b/provider_src/com/android/email/mail/Store.java similarity index 100% rename from src/com/android/email/mail/Store.java rename to provider_src/com/android/email/mail/Store.java diff --git a/src/com/android/email/mail/internet/AuthenticationCache.java b/provider_src/com/android/email/mail/internet/AuthenticationCache.java similarity index 100% rename from src/com/android/email/mail/internet/AuthenticationCache.java rename to provider_src/com/android/email/mail/internet/AuthenticationCache.java diff --git a/src/com/android/email/mail/internet/OAuthAuthenticator.java b/provider_src/com/android/email/mail/internet/OAuthAuthenticator.java similarity index 100% rename from src/com/android/email/mail/internet/OAuthAuthenticator.java rename to provider_src/com/android/email/mail/internet/OAuthAuthenticator.java diff --git a/src/com/android/email/mail/store/ImapConnection.java b/provider_src/com/android/email/mail/store/ImapConnection.java similarity index 100% rename from src/com/android/email/mail/store/ImapConnection.java rename to provider_src/com/android/email/mail/store/ImapConnection.java diff --git a/src/com/android/email/mail/store/ImapFolder.java b/provider_src/com/android/email/mail/store/ImapFolder.java similarity index 100% rename from src/com/android/email/mail/store/ImapFolder.java rename to provider_src/com/android/email/mail/store/ImapFolder.java diff --git a/src/com/android/email/mail/store/ImapStore.java b/provider_src/com/android/email/mail/store/ImapStore.java similarity index 100% rename from src/com/android/email/mail/store/ImapStore.java rename to provider_src/com/android/email/mail/store/ImapStore.java diff --git a/src/com/android/email/mail/store/Pop3Store.java b/provider_src/com/android/email/mail/store/Pop3Store.java similarity index 100% rename from src/com/android/email/mail/store/Pop3Store.java rename to provider_src/com/android/email/mail/store/Pop3Store.java diff --git a/src/com/android/email/mail/store/ServiceStore.java b/provider_src/com/android/email/mail/store/ServiceStore.java similarity index 100% rename from src/com/android/email/mail/store/ServiceStore.java rename to provider_src/com/android/email/mail/store/ServiceStore.java diff --git a/src/com/android/email/mail/store/imap/ImapConstants.java b/provider_src/com/android/email/mail/store/imap/ImapConstants.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapConstants.java rename to provider_src/com/android/email/mail/store/imap/ImapConstants.java diff --git a/src/com/android/email/mail/store/imap/ImapElement.java b/provider_src/com/android/email/mail/store/imap/ImapElement.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapElement.java rename to provider_src/com/android/email/mail/store/imap/ImapElement.java diff --git a/src/com/android/email/mail/store/imap/ImapList.java b/provider_src/com/android/email/mail/store/imap/ImapList.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapList.java rename to provider_src/com/android/email/mail/store/imap/ImapList.java diff --git a/src/com/android/email/mail/store/imap/ImapMemoryLiteral.java b/provider_src/com/android/email/mail/store/imap/ImapMemoryLiteral.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapMemoryLiteral.java rename to provider_src/com/android/email/mail/store/imap/ImapMemoryLiteral.java diff --git a/src/com/android/email/mail/store/imap/ImapResponse.java b/provider_src/com/android/email/mail/store/imap/ImapResponse.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapResponse.java rename to provider_src/com/android/email/mail/store/imap/ImapResponse.java diff --git a/src/com/android/email/mail/store/imap/ImapResponseParser.java b/provider_src/com/android/email/mail/store/imap/ImapResponseParser.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapResponseParser.java rename to provider_src/com/android/email/mail/store/imap/ImapResponseParser.java diff --git a/src/com/android/email/mail/store/imap/ImapSimpleString.java b/provider_src/com/android/email/mail/store/imap/ImapSimpleString.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapSimpleString.java rename to provider_src/com/android/email/mail/store/imap/ImapSimpleString.java diff --git a/src/com/android/email/mail/store/imap/ImapString.java b/provider_src/com/android/email/mail/store/imap/ImapString.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapString.java rename to provider_src/com/android/email/mail/store/imap/ImapString.java diff --git a/src/com/android/email/mail/store/imap/ImapTempFileLiteral.java b/provider_src/com/android/email/mail/store/imap/ImapTempFileLiteral.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapTempFileLiteral.java rename to provider_src/com/android/email/mail/store/imap/ImapTempFileLiteral.java diff --git a/src/com/android/email/mail/store/imap/ImapUtility.java b/provider_src/com/android/email/mail/store/imap/ImapUtility.java similarity index 100% rename from src/com/android/email/mail/store/imap/ImapUtility.java rename to provider_src/com/android/email/mail/store/imap/ImapUtility.java diff --git a/src/com/android/email/mail/transport/DiscourseLogger.java b/provider_src/com/android/email/mail/transport/DiscourseLogger.java similarity index 100% rename from src/com/android/email/mail/transport/DiscourseLogger.java rename to provider_src/com/android/email/mail/transport/DiscourseLogger.java diff --git a/src/com/android/email/mail/transport/MailTransport.java b/provider_src/com/android/email/mail/transport/MailTransport.java similarity index 100% rename from src/com/android/email/mail/transport/MailTransport.java rename to provider_src/com/android/email/mail/transport/MailTransport.java diff --git a/src/com/android/email/provider/AccountBackupRestore.java b/provider_src/com/android/email/provider/AccountBackupRestore.java similarity index 100% rename from src/com/android/email/provider/AccountBackupRestore.java rename to provider_src/com/android/email/provider/AccountBackupRestore.java diff --git a/src/com/android/email/provider/AccountReconciler.java b/provider_src/com/android/email/provider/AccountReconciler.java similarity index 97% rename from src/com/android/email/provider/AccountReconciler.java rename to provider_src/com/android/email/provider/AccountReconciler.java index 251c59a37..8031f17c9 100644 --- a/src/com/android/email/provider/AccountReconciler.java +++ b/provider_src/com/android/email/provider/AccountReconciler.java @@ -29,8 +29,9 @@ import android.provider.CalendarContract; import android.provider.ContactsContract; import android.text.TextUtils; -import com.android.email.NotificationController; import com.android.email.R; +import com.android.email.NotificationController; +import com.android.email.NotificationControllerCreatorHolder; import com.android.email.SecurityPolicy; import com.android.email.service.EmailServiceUtils; import com.android.email.service.EmailServiceUtils.EmailServiceInfo; @@ -206,7 +207,11 @@ public class AccountReconciler { exchangeAccountDeleted = true; } // Cancel all notifications for this account - NotificationController.cancelNotifications(context, providerAccount); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(context); + if (nc != null) { + nc.cancelNotifications(context, providerAccount); + } context.getContentResolver().delete( EmailProvider.uiUri("uiaccount", providerAccount.mId), null, null); diff --git a/src/com/android/email/provider/AttachmentProvider.java b/provider_src/com/android/email/provider/AttachmentProvider.java similarity index 100% rename from src/com/android/email/provider/AttachmentProvider.java rename to provider_src/com/android/email/provider/AttachmentProvider.java diff --git a/src/com/android/email/provider/ContentCache.java b/provider_src/com/android/email/provider/ContentCache.java similarity index 100% rename from src/com/android/email/provider/ContentCache.java rename to provider_src/com/android/email/provider/ContentCache.java diff --git a/src/com/android/email/provider/DBHelper.java b/provider_src/com/android/email/provider/DBHelper.java similarity index 100% rename from src/com/android/email/provider/DBHelper.java rename to provider_src/com/android/email/provider/DBHelper.java diff --git a/src/com/android/email/provider/EmailConversationCursor.java b/provider_src/com/android/email/provider/EmailConversationCursor.java similarity index 100% rename from src/com/android/email/provider/EmailConversationCursor.java rename to provider_src/com/android/email/provider/EmailConversationCursor.java diff --git a/src/com/android/email/provider/EmailMessageCursor.java b/provider_src/com/android/email/provider/EmailMessageCursor.java similarity index 100% rename from src/com/android/email/provider/EmailMessageCursor.java rename to provider_src/com/android/email/provider/EmailMessageCursor.java diff --git a/src/com/android/email/provider/EmailProvider.java b/provider_src/com/android/email/provider/EmailProvider.java similarity index 98% rename from src/com/android/email/provider/EmailProvider.java rename to provider_src/com/android/email/provider/EmailProvider.java index 893fecc4d..52e796b3a 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/provider_src/com/android/email/provider/EmailProvider.java @@ -33,6 +33,7 @@ import android.content.PeriodicSync; import android.content.SharedPreferences; import android.content.UriMatcher; import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; @@ -66,15 +67,14 @@ import com.android.common.content.ProjectionMap; import com.android.email.DebugUtils; import com.android.email.Preferences; import com.android.email.R; +import com.android.email.NotificationControllerCreatorHolder; +import com.android.email.NotificationController; import com.android.email.SecurityPolicy; import com.android.email.activity.setup.AccountSecurity; -import com.android.email.activity.setup.AccountSettingsFragment; import com.android.email.activity.setup.AccountSettingsUtils; -import com.android.email.activity.setup.HeadlessAccountSettingsLoader; import com.android.email.service.AttachmentService; import com.android.email.service.EmailServiceUtils; import com.android.email.service.EmailServiceUtils.EmailServiceInfo; -import com.android.email2.ui.MailActivityEmail; import com.android.emailcommon.Logging; import com.android.emailcommon.mail.Address; import com.android.emailcommon.provider.Account; @@ -106,6 +106,7 @@ import com.android.emailcommon.service.IEmailService; import com.android.emailcommon.service.SearchParams; import com.android.emailcommon.utility.AttachmentUtilities; import com.android.emailcommon.utility.EmailAsyncTask; +import com.android.emailcommon.utility.IntentUtilities; import com.android.emailcommon.utility.Utility; import com.android.ex.photo.provider.PhotoContract; import com.android.mail.preferences.MailPrefs; @@ -168,6 +169,9 @@ public class EmailProvider extends ContentProvider private static final String BACKUP_DATABASE_NAME = "EmailProviderBackup.db"; private static final String ACCOUNT_MANAGER_JSON_TAG = "accountJson"; + + private static final String PREFERENCE_FRAGMENT_CLASS_NAME = + "com.android.email.activity.setup.AccountSettingsFragment"; /** * Notifies that changes happened. Certain UI components, e.g., widgets, can register for this * {@link android.content.Intent} and update accordingly. However, this can be very broad and @@ -1015,7 +1019,7 @@ public class EmailProvider extends ContentProvider init(context); DebugUtils.init(context); // Do this last, so that EmailContent/EmailProvider are initialized - MailActivityEmail.setServicesEnabledAsync(context); + setServicesEnabledAsync(context); reconcileAccountsAsync(context); // Update widgets @@ -3439,8 +3443,7 @@ public class EmailProvider extends ContentProvider } if (projectionColumns.contains(UIProvider.AccountColumns.REAUTHENTICATION_INTENT_URI)) { values.put(UIProvider.AccountColumns.REAUTHENTICATION_INTENT_URI, - HeadlessAccountSettingsLoader.getIncomingSettingsUri(accountId) - .toString()); + getIncomingSettingsUri(accountId).toString()); } if (projectionColumns.contains(UIProvider.AccountColumns.MIME_TYPE)) { values.put(UIProvider.AccountColumns.MIME_TYPE, EMAIL_APP_MIME_TYPE); @@ -3566,7 +3569,7 @@ public class EmailProvider extends ContentProvider } if (projectionColumns.contains(UIProvider.AccountColumns.SETTINGS_FRAGMENT_CLASS)) { values.put(UIProvider.AccountColumns.SETTINGS_FRAGMENT_CLASS, - AccountSettingsFragment.class.getName()); + PREFERENCE_FRAGMENT_CLASS_NAME); } if (projectionColumns.contains(UIProvider.AccountColumns.SettingsColumns.REPLY_BEHAVIOR)) { values.put(UIProvider.AccountColumns.SettingsColumns.REPLY_BEHAVIOR, @@ -5917,7 +5920,7 @@ public class EmailProvider extends ContentProvider // Clean up AccountBackupRestore.backup(context); SecurityPolicy.getInstance(context).reducePolicies(); - MailActivityEmail.setServicesEnabledSync(context); + setServicesEnabledSync(context); // TODO: We ought to reconcile accounts here, but some callers do this in a loop, // which would be a problem when the first account reconciliation shuts us down. return 1; @@ -6185,4 +6188,90 @@ public class EmailProvider extends ContentProvider notifyUI(UIPROVIDER_ALL_ACCOUNTS_NOTIFIER, null); } } + + /** + * Asynchronous version of {@link #setServicesEnabledSync(Context)}. Use when calling from + * UI thread (or lifecycle entry points.) + */ + public static void setServicesEnabledAsync(final Context context) { + if (context.getResources().getBoolean(R.bool.enable_services)) { + EmailAsyncTask.runAsyncParallel(new Runnable() { + @Override + public void run() { + setServicesEnabledSync(context); + } + }); + } + } + + /** + * Called throughout the application when the number of accounts has changed. This method + * enables or disables the Compose activity, the boot receiver and the service based on + * whether any accounts are configured. + * + * Blocking call - do not call from UI/lifecycle threads. + * + * @return true if there are any accounts configured. + */ + public static boolean setServicesEnabledSync(Context context) { + // Make sure we're initialized + EmailContent.init(context); + Cursor c = null; + try { + c = context.getContentResolver().query( + Account.CONTENT_URI, + Account.ID_PROJECTION, + null, null, null); + boolean enable = c != null && c.getCount() > 0; + setServicesEnabled(context, enable); + return enable; + } finally { + if (c != null) { + c.close(); + } + } + } + + private static void setServicesEnabled(Context context, boolean enabled) { + PackageManager pm = context.getPackageManager(); + pm.setComponentEnabledSetting( + new ComponentName(context, AttachmentService.class), + enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + PackageManager.DONT_KILL_APP); + + // Start/stop the various services depending on whether there are any accounts + // TODO: Make sure that the AttachmentService responds to this request as it + // expects a particular set of data in the intents that it receives or it ignores. + startOrStopService(enabled, context, new Intent(context, AttachmentService.class)); + final NotificationController controller = + NotificationControllerCreatorHolder.getInstance(context); + + if (controller != null) { + controller.watchForMessages(); + } + } + + /** + * Starts or stops the service as necessary. + * @param enabled If {@code true}, the service will be started. Otherwise, it will be stopped. + * @param context The context to manage the service with. + * @param intent The intent of the service to be managed. + */ + private static void startOrStopService(boolean enabled, Context context, Intent intent) { + if (enabled) { + context.startService(intent); + } else { + context.stopService(intent); + } + } + + + public static Uri getIncomingSettingsUri(long accountId) { + final Uri.Builder baseUri = Uri.parse("auth://" + EmailContent.EMAIL_PACKAGE_NAME + + ".ACCOUNT_SETTINGS/incoming/").buildUpon(); + IntentUtilities.setAccountId(baseUri, accountId); + return baseUri.build(); + } + } diff --git a/src/com/android/email/provider/FolderPickerActivity.java b/provider_src/com/android/email/provider/FolderPickerActivity.java similarity index 100% rename from src/com/android/email/provider/FolderPickerActivity.java rename to provider_src/com/android/email/provider/FolderPickerActivity.java diff --git a/src/com/android/email/provider/FolderPickerCallback.java b/provider_src/com/android/email/provider/FolderPickerCallback.java similarity index 100% rename from src/com/android/email/provider/FolderPickerCallback.java rename to provider_src/com/android/email/provider/FolderPickerCallback.java diff --git a/src/com/android/email/provider/FolderPickerDialog.java b/provider_src/com/android/email/provider/FolderPickerDialog.java similarity index 100% rename from src/com/android/email/provider/FolderPickerDialog.java rename to provider_src/com/android/email/provider/FolderPickerDialog.java diff --git a/src/com/android/email/provider/FolderPickerSelectorAdapter.java b/provider_src/com/android/email/provider/FolderPickerSelectorAdapter.java similarity index 100% rename from src/com/android/email/provider/FolderPickerSelectorAdapter.java rename to provider_src/com/android/email/provider/FolderPickerSelectorAdapter.java diff --git a/src/com/android/email/provider/RefreshStatusMonitor.java b/provider_src/com/android/email/provider/RefreshStatusMonitor.java similarity index 100% rename from src/com/android/email/provider/RefreshStatusMonitor.java rename to provider_src/com/android/email/provider/RefreshStatusMonitor.java diff --git a/src/com/android/email/provider/Utilities.java b/provider_src/com/android/email/provider/Utilities.java similarity index 100% rename from src/com/android/email/provider/Utilities.java rename to provider_src/com/android/email/provider/Utilities.java diff --git a/src/com/android/email/provider/WidgetProvider.java b/provider_src/com/android/email/provider/WidgetProvider.java similarity index 100% rename from src/com/android/email/provider/WidgetProvider.java rename to provider_src/com/android/email/provider/WidgetProvider.java diff --git a/src/com/android/email/service/AccountService.java b/provider_src/com/android/email/service/AccountService.java similarity index 100% rename from src/com/android/email/service/AccountService.java rename to provider_src/com/android/email/service/AccountService.java diff --git a/src/com/android/email/service/AttachmentService.java b/provider_src/com/android/email/service/AttachmentService.java similarity index 99% rename from src/com/android/email/service/AttachmentService.java rename to provider_src/com/android/email/service/AttachmentService.java index f8871688a..065262314 100644 --- a/src/com/android/email/service/AttachmentService.java +++ b/provider_src/com/android/email/service/AttachmentService.java @@ -34,6 +34,7 @@ import android.text.format.DateUtils; import com.android.email.AttachmentInfo; import com.android.email.EmailConnectivityManager; +import com.android.email.NotificationControllerCreatorHolder; import com.android.email.NotificationController; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.EmailContent; @@ -1133,8 +1134,11 @@ public class AttachmentService extends Service implements Runnable { // message never get sent EmailContent.delete(this, Attachment.CONTENT_URI, attachment.mId); // TODO: Talk to UX about whether this is even worth doing - NotificationController nc = NotificationController.getInstance(this); - nc.showDownloadForwardFailedNotificationSynchronous(attachment); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(this); + if (nc != null) { + nc.showDownloadForwardFailedNotificationSynchronous(attachment); + } deleted = true; LogUtils.w(LOG_TAG, "Deleting forwarded attachment #%d for message #%d", attachmentId, attachment.mMessageKey); diff --git a/src/com/android/email/service/AuthenticatorService.java b/provider_src/com/android/email/service/AuthenticatorService.java similarity index 96% rename from src/com/android/email/service/AuthenticatorService.java rename to provider_src/com/android/email/service/AuthenticatorService.java index c69bb93e6..8490a8c23 100644 --- a/src/com/android/email/service/AuthenticatorService.java +++ b/provider_src/com/android/email/service/AuthenticatorService.java @@ -16,8 +16,8 @@ package com.android.email.service; -import com.android.email.activity.setup.AccountSetupFinal; import com.android.email.service.EmailServiceUtils.EmailServiceInfo; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.emailcommon.provider.EmailContent; import android.accounts.AbstractAccountAuthenticator; @@ -109,8 +109,8 @@ public class AuthenticatorService extends Service { } else { Bundle b = new Bundle(); Intent intent = - AccountSetupFinal.actionGetCreateAccountIntent(AuthenticatorService.this, - accountType); + AuthenticatorSetupIntentHelper.actionGetCreateAccountIntent( + AuthenticatorService.this, accountType); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); b.putParcelable(AccountManager.KEY_INTENT, intent); return b; diff --git a/src/com/android/email/service/EasAuthenticatorService.java b/provider_src/com/android/email/service/EasAuthenticatorService.java similarity index 100% rename from src/com/android/email/service/EasAuthenticatorService.java rename to provider_src/com/android/email/service/EasAuthenticatorService.java diff --git a/src/com/android/email/service/EasAuthenticatorServiceAlternate.java b/provider_src/com/android/email/service/EasAuthenticatorServiceAlternate.java similarity index 100% rename from src/com/android/email/service/EasAuthenticatorServiceAlternate.java rename to provider_src/com/android/email/service/EasAuthenticatorServiceAlternate.java diff --git a/src/com/android/email/service/EasTestAuthenticatorService.java b/provider_src/com/android/email/service/EasTestAuthenticatorService.java similarity index 95% rename from src/com/android/email/service/EasTestAuthenticatorService.java rename to provider_src/com/android/email/service/EasTestAuthenticatorService.java index c8d853b93..ad8da826c 100644 --- a/src/com/android/email/service/EasTestAuthenticatorService.java +++ b/provider_src/com/android/email/service/EasTestAuthenticatorService.java @@ -27,7 +27,7 @@ import android.content.Intent; import android.os.Bundle; import android.os.IBinder; -import com.android.email.activity.setup.AccountSetupFinal; +import com.android.email.setup.AuthenticatorSetupIntentHelper; /** * Anauthenticator service for reconciliation tests; it simply adds the account to AccountManager @@ -67,8 +67,8 @@ public class EasTestAuthenticatorService extends Service { } else { Bundle b = new Bundle(); Intent intent = - AccountSetupFinal.actionGetCreateAccountIntent( - EasTestAuthenticatorService.this, accountType); + AuthenticatorSetupIntentHelper.actionGetCreateAccountIntent( + EasTestAuthenticatorService.this, accountType); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); b.putParcelable(AccountManager.KEY_INTENT, intent); return b; diff --git a/src/com/android/email/service/EmailBroadcastProcessorService.java b/provider_src/com/android/email/service/EmailBroadcastProcessorService.java similarity index 100% rename from src/com/android/email/service/EmailBroadcastProcessorService.java rename to provider_src/com/android/email/service/EmailBroadcastProcessorService.java diff --git a/src/com/android/email/service/EmailBroadcastReceiver.java b/provider_src/com/android/email/service/EmailBroadcastReceiver.java similarity index 100% rename from src/com/android/email/service/EmailBroadcastReceiver.java rename to provider_src/com/android/email/service/EmailBroadcastReceiver.java diff --git a/src/com/android/email/service/EmailServiceStub.java b/provider_src/com/android/email/service/EmailServiceStub.java similarity index 98% rename from src/com/android/email/service/EmailServiceStub.java rename to provider_src/com/android/email/service/EmailServiceStub.java index 595d524de..aa73d29dc 100644 --- a/src/com/android/email/service/EmailServiceStub.java +++ b/provider_src/com/android/email/service/EmailServiceStub.java @@ -27,6 +27,7 @@ import android.os.RemoteException; import com.android.email.DebugUtils; import com.android.email.NotificationController; +import com.android.email.NotificationControllerCreatorHolder; import com.android.email.mail.Sender; import com.android.email.mail.Store; import com.android.email.service.EmailServiceUtils.EmailServiceInfo; @@ -424,7 +425,8 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm return; } TrafficStats.setThreadStatsTag(TrafficFlags.getSmtpFlags(context, account)); - final NotificationController nc = NotificationController.getInstance(context); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(context); // 1. Loop through all messages in the account's outbox final long outboxId = Mailbox.findMailboxOfType(context, account.mId, Mailbox.TYPE_OUTBOX); if (outboxId == Mailbox.NO_MAILBOX) { @@ -471,7 +473,7 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm sender.sendMessage(messageId); } catch (MessagingException me) { // report error for this message, but keep trying others - if (me instanceof AuthenticationFailedException) { + if (me instanceof AuthenticationFailedException && nc != null) { nc.showLoginFailedNotificationSynchronous(account.mId, false /* incoming */); } @@ -507,9 +509,11 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm resolver.delete(syncedUri, null, null); } } - nc.cancelLoginFailedNotification(account.mId); + if (nc != null) { + nc.cancelLoginFailedNotification(account.mId); + } } catch (MessagingException me) { - if (me instanceof AuthenticationFailedException) { + if (me instanceof AuthenticationFailedException && nc != null) { nc.showLoginFailedNotificationSynchronous(account.mId, false /* incoming */); } } finally { diff --git a/src/com/android/email/service/EmailServiceUtils.java b/provider_src/com/android/email/service/EmailServiceUtils.java similarity index 100% rename from src/com/android/email/service/EmailServiceUtils.java rename to provider_src/com/android/email/service/EmailServiceUtils.java diff --git a/src/com/android/email/service/EmailUpgradeBroadcastReceiver.java b/provider_src/com/android/email/service/EmailUpgradeBroadcastReceiver.java similarity index 100% rename from src/com/android/email/service/EmailUpgradeBroadcastReceiver.java rename to provider_src/com/android/email/service/EmailUpgradeBroadcastReceiver.java diff --git a/src/com/android/email/service/ImapAuthenticatorService.java b/provider_src/com/android/email/service/ImapAuthenticatorService.java similarity index 100% rename from src/com/android/email/service/ImapAuthenticatorService.java rename to provider_src/com/android/email/service/ImapAuthenticatorService.java diff --git a/src/com/android/email/service/ImapService.java b/provider_src/com/android/email/service/ImapService.java similarity index 99% rename from src/com/android/email/service/ImapService.java rename to provider_src/com/android/email/service/ImapService.java index f7f2517d0..d2dcd5469 100644 --- a/src/com/android/email/service/ImapService.java +++ b/provider_src/com/android/email/service/ImapService.java @@ -33,6 +33,7 @@ import android.text.format.DateUtils; import com.android.email.DebugUtils; import com.android.email.LegacyConversions; import com.android.email.NotificationController; +import com.android.email.NotificationControllerCreatorHolder; import com.android.email.R; import com.android.email.mail.Store; import com.android.email.provider.Utilities; @@ -164,7 +165,8 @@ public class ImapService extends Service { final Account account, final Mailbox folder, final boolean loadMore, final boolean uiRefresh) throws MessagingException { TrafficStats.setThreadStatsTag(TrafficFlags.getSyncFlags(context, account)); - NotificationController nc = NotificationController.getInstance(context); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(context); Store remoteStore = null; try { remoteStore = Store.getInstance(account, context); diff --git a/src/com/android/email/service/ImapTempFileLiteral.java b/provider_src/com/android/email/service/ImapTempFileLiteral.java similarity index 100% rename from src/com/android/email/service/ImapTempFileLiteral.java rename to provider_src/com/android/email/service/ImapTempFileLiteral.java diff --git a/src/com/android/email/service/LegacyEasAuthenticatorService.java b/provider_src/com/android/email/service/LegacyEasAuthenticatorService.java similarity index 100% rename from src/com/android/email/service/LegacyEasAuthenticatorService.java rename to provider_src/com/android/email/service/LegacyEasAuthenticatorService.java diff --git a/src/com/android/email/service/LegacyEmailAuthenticatorService.java b/provider_src/com/android/email/service/LegacyEmailAuthenticatorService.java similarity index 100% rename from src/com/android/email/service/LegacyEmailAuthenticatorService.java rename to provider_src/com/android/email/service/LegacyEmailAuthenticatorService.java diff --git a/src/com/android/email/service/LegacyImapAuthenticatorService.java b/provider_src/com/android/email/service/LegacyImapAuthenticatorService.java similarity index 100% rename from src/com/android/email/service/LegacyImapAuthenticatorService.java rename to provider_src/com/android/email/service/LegacyImapAuthenticatorService.java diff --git a/src/com/android/email/service/LegacyImapSyncAdapterService.java b/provider_src/com/android/email/service/LegacyImapSyncAdapterService.java similarity index 100% rename from src/com/android/email/service/LegacyImapSyncAdapterService.java rename to provider_src/com/android/email/service/LegacyImapSyncAdapterService.java diff --git a/src/com/android/email/service/PolicyService.java b/provider_src/com/android/email/service/PolicyService.java similarity index 100% rename from src/com/android/email/service/PolicyService.java rename to provider_src/com/android/email/service/PolicyService.java diff --git a/src/com/android/email/service/Pop3AuthenticatorService.java b/provider_src/com/android/email/service/Pop3AuthenticatorService.java similarity index 100% rename from src/com/android/email/service/Pop3AuthenticatorService.java rename to provider_src/com/android/email/service/Pop3AuthenticatorService.java diff --git a/src/com/android/email/service/Pop3Service.java b/provider_src/com/android/email/service/Pop3Service.java similarity index 98% rename from src/com/android/email/service/Pop3Service.java rename to provider_src/com/android/email/service/Pop3Service.java index 40b3ca695..36e88d705 100644 --- a/src/com/android/email/service/Pop3Service.java +++ b/provider_src/com/android/email/service/Pop3Service.java @@ -30,6 +30,7 @@ import android.os.RemoteException; import com.android.email.DebugUtils; import com.android.email.NotificationController; +import com.android.email.NotificationControllerCreatorHolder; import com.android.email.mail.Store; import com.android.email.mail.store.Pop3Store; import com.android.email.mail.store.Pop3Store.Pop3Folder; @@ -107,16 +108,19 @@ public class Pop3Service extends Service { public static int synchronizeMailboxSynchronous(Context context, final Account account, final Mailbox folder, final int deltaMessageCount) throws MessagingException { TrafficStats.setThreadStatsTag(TrafficFlags.getSyncFlags(context, account)); - NotificationController nc = NotificationController.getInstance(context); + final NotificationController nc = + NotificationControllerCreatorHolder.getInstance(context); try { synchronizePop3Mailbox(context, account, folder, deltaMessageCount); // Clear authentication notification for this account - nc.cancelLoginFailedNotification(account.mId); + if (nc != null) { + nc.cancelLoginFailedNotification(account.mId); + } } catch (MessagingException e) { if (Logging.LOGD) { LogUtils.v(Logging.LOG_TAG, "synchronizeMailbox", e); } - if (e instanceof AuthenticationFailedException) { + if (e instanceof AuthenticationFailedException && nc != null) { // Generate authentication notification nc.showLoginFailedNotificationSynchronous(account.mId, true /* incoming */); } diff --git a/src/com/android/email/service/Pop3SyncAdapterService.java b/provider_src/com/android/email/service/Pop3SyncAdapterService.java similarity index 100% rename from src/com/android/email/service/Pop3SyncAdapterService.java rename to provider_src/com/android/email/service/Pop3SyncAdapterService.java diff --git a/src/com/android/email/service/PopImapSyncAdapterService.java b/provider_src/com/android/email/service/PopImapSyncAdapterService.java similarity index 100% rename from src/com/android/email/service/PopImapSyncAdapterService.java rename to provider_src/com/android/email/service/PopImapSyncAdapterService.java diff --git a/provider_src/com/android/email/setup/AuthenticatorSetupIntentHelper.java b/provider_src/com/android/email/setup/AuthenticatorSetupIntentHelper.java new file mode 100644 index 000000000..fc36f7bec --- /dev/null +++ b/provider_src/com/android/email/setup/AuthenticatorSetupIntentHelper.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.email.setup; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; + + +public class AuthenticatorSetupIntentHelper { + // NORMAL is the standard entry from the Email app; EAS and POP_IMAP are used when entering via + // Settings -> Accounts + public static final int FLOW_MODE_UNSPECIFIED = -1; + public static final int FLOW_MODE_NORMAL = 0; + public static final int FLOW_MODE_ACCOUNT_MANAGER = 1; + public static final int FLOW_MODE_EDIT = 3; + public static final int FLOW_MODE_FORCE_CREATE = 4; + + public static final int FLOW_MODE_NO_ACCOUNTS = 8; + + + public static final String EXTRA_FLOW_MODE = "FLOW_MODE"; + public static final String EXTRA_FLOW_ACCOUNT_TYPE = "FLOW_ACCOUNT_TYPE"; + + + public static Intent actionNewAccountIntent(final Context context) { + final Intent i = new Intent(); + i.setComponent( + new ComponentName(context, "com.android.email.activity.setup.AccountSetupFinal")); + i.putExtra(EXTRA_FLOW_MODE, FLOW_MODE_NORMAL); + return i; + } + + public static Intent actionNewAccountWithResultIntent(final Context context) { + final Intent i = new Intent(); + i.setComponent( + new ComponentName(context, "com.android.email.activity.setup.AccountSetupFinal")); + i.putExtra(EXTRA_FLOW_MODE, FLOW_MODE_NO_ACCOUNTS); + return i; + } + + public static Intent actionGetCreateAccountIntent( + final Context context, final String accountManagerType) { + final Intent i = new Intent(); + i.setComponent( + new ComponentName(context, "com.android.email.activity.setup.AccountSetupFinal")); + i.putExtra(EXTRA_FLOW_MODE, FLOW_MODE_ACCOUNT_MANAGER); + i.putExtra(EXTRA_FLOW_ACCOUNT_TYPE, accountManagerType); + return i; + } +} \ No newline at end of file diff --git a/src/com/android/email/EmailApplication.java b/src/com/android/email/EmailApplication.java index 224ac490c..6e7586435 100644 --- a/src/com/android/email/EmailApplication.java +++ b/src/com/android/email/EmailApplication.java @@ -62,5 +62,13 @@ public class EmailApplication extends Application { }); PublicPreferenceActivity.sPreferenceActivityClass = EmailPreferenceActivity.class; + + NotificationControllerCreatorHolder.setNotificationControllerCreator( + new NotificationControllerCreator() { + @Override + public NotificationController getInstance(Context context){ + return EmailNotificationController.getInstance(context); + } + }); } } diff --git a/src/com/android/email/NotificationController.java b/src/com/android/email/EmailNotificationController.java similarity index 97% rename from src/com/android/email/NotificationController.java rename to src/com/android/email/EmailNotificationController.java index 675140632..e57b41833 100644 --- a/src/com/android/email/NotificationController.java +++ b/src/com/android/email/EmailNotificationController.java @@ -62,7 +62,7 @@ import java.util.Set; /** * Class that manages notifications. */ -public class NotificationController { +public class EmailNotificationController implements NotificationController { private static final String LOG_TAG = LogTag.getLogTag(); private static final int NOTIFICATION_ID_ATTACHMENT_WARNING = 3; @@ -76,7 +76,7 @@ public class NotificationController { private static NotificationThread sNotificationThread; private static Handler sNotificationHandler; - private static NotificationController sInstance; + private static EmailNotificationController sInstance; private final Context mContext; private final NotificationManager mNotificationManager; private final Clock mClock; @@ -86,7 +86,7 @@ public class NotificationController { private ContentObserver mAccountObserver; /** Constructor */ - protected NotificationController(Context context, Clock clock) { + protected EmailNotificationController(Context context, Clock clock) { mContext = context.getApplicationContext(); EmailContent.init(context); mNotificationManager = (NotificationManager) context.getSystemService( @@ -95,9 +95,9 @@ public class NotificationController { } /** Singleton access */ - public static synchronized NotificationController getInstance(Context context) { + public static synchronized EmailNotificationController getInstance(Context context) { if (sInstance == null) { - sInstance = new NotificationController(context, Clock.INSTANCE); + sInstance = new EmailNotificationController(context, Clock.INSTANCE); } return sInstance; } @@ -182,6 +182,7 @@ public class NotificationController { * notification shown to the user. And, when we start observing database changes, we restore * the saved state. */ + @Override public void watchForMessages() { ensureHandlerExists(); // Run this on the message notification handler @@ -386,6 +387,7 @@ public class NotificationController { * * NOTE: DO NOT CALL THIS METHOD FROM THE UI THREAD (DATABASE ACCESS) */ + @Override public void showDownloadForwardFailedNotificationSynchronous(Attachment attachment) { final Message message = Message.restoreMessageWithId(mContext, attachment.mMessageKey); if (message == null) return; @@ -410,6 +412,7 @@ public class NotificationController { * * NOTE: DO NOT CALL THIS METHOD FROM THE UI THREAD (DATABASE ACCESS) */ + @Override public void showLoginFailedNotificationSynchronous(long accountId, boolean incoming) { final Account account = Account.restoreAccountWithId(mContext, accountId); if (account == null) return; @@ -420,7 +423,7 @@ public class NotificationController { final Intent settingsIntent; if (incoming) { settingsIntent = new Intent(Intent.ACTION_VIEW, - HeadlessAccountSettingsLoader.getIncomingSettingsUri(accountId)); + EmailProvider.getIncomingSettingsUri(accountId)); } else { settingsIntent = new Intent(Intent.ACTION_VIEW, HeadlessAccountSettingsLoader.getOutgoingSettingsUri(accountId)); @@ -436,6 +439,7 @@ public class NotificationController { /** * Cancels the login failed notification for the given account. */ + @Override public void cancelLoginFailedNotification(long accountId) { mNotificationManager.cancel(getLoginFailedNotificationId(accountId)); } @@ -446,6 +450,7 @@ public class NotificationController { * * NOTE: DO NOT CALL THIS METHOD FROM THE UI THREAD (DATABASE ACCESS) */ + @Override public void showPasswordExpiringNotificationSynchronous(long accountId) { final Account account = Account.restoreAccountWithId(mContext, accountId); if (account == null) return; @@ -466,6 +471,7 @@ public class NotificationController { * * NOTE: DO NOT CALL THIS METHOD FROM THE UI THREAD (DATABASE ACCESS) */ + @Override public void showPasswordExpiredNotificationSynchronous(long accountId) { final Account account = Account.restoreAccountWithId(mContext, accountId); if (account == null) return; @@ -482,6 +488,7 @@ public class NotificationController { /** * Cancels any password expire notifications [both expired & expiring]. */ + @Override public void cancelPasswordExpirationNotifications() { mNotificationManager.cancel(NOTIFICATION_ID_PASSWORD_EXPIRING); mNotificationManager.cancel(NOTIFICATION_ID_PASSWORD_EXPIRED); @@ -491,6 +498,7 @@ public class NotificationController { * Show (or update) a security needed notification. If tapped, the user is taken to a * dialog asking whether he wants to update his settings. */ + @Override public void showSecurityNeededNotification(Account account) { Intent intent = AccountSecurity.actionUpdateSecurityIntent(mContext, account.mId, true); String accountName = account.getDisplayName(); @@ -505,9 +513,10 @@ public class NotificationController { * Show (or update) a security changed notification. If tapped, the user is taken to the * account settings screen where he can view the list of enforced policies */ + @Override public void showSecurityChangedNotification(Account account) { final Intent intent = new Intent(Intent.ACTION_VIEW, - HeadlessAccountSettingsLoader.getIncomingSettingsUri(account.getId())); + EmailProvider.getIncomingSettingsUri(account.getId())); final String accountName = account.getDisplayName(); final String ticker = mContext.getString(R.string.security_changed_ticker_fmt, accountName); @@ -521,9 +530,10 @@ public class NotificationController { * Show (or update) a security unsupported notification. If tapped, the user is taken to the * account settings screen where he can view the list of unsupported policies */ + @Override public void showSecurityUnsupportedNotification(Account account) { final Intent intent = new Intent(Intent.ACTION_VIEW, - HeadlessAccountSettingsLoader.getIncomingSettingsUri(account.getId())); + EmailProvider.getIncomingSettingsUri(account.getId())); final String accountName = account.getDisplayName(); final String ticker = mContext.getString(R.string.security_unsupported_ticker_fmt, accountName); @@ -536,6 +546,7 @@ public class NotificationController { /** * Cancels all security needed notifications. */ + @Override public void cancelSecurityNeededNotification() { EmailAsyncTask.runAsyncParallel(new Runnable() { @Override @@ -559,7 +570,8 @@ public class NotificationController { * Cancels all notifications for the specified account id. This includes new mail notifications, * as well as special login/security notifications. */ - public static void cancelNotifications(final Context context, final Account account) { + @Override + public void cancelNotifications(final Context context, final Account account) { final EmailServiceUtils.EmailServiceInfo serviceInfo = EmailServiceUtils.getServiceInfoForAccount(context, account.mId); if (serviceInfo == null) { @@ -646,7 +658,8 @@ public class NotificationController { } } - public static void handleUpdateNotificationIntent(Context context, Intent intent) { + @Override + public void handleUpdateNotificationIntent(Context context, Intent intent) { final Uri accountUri = intent.getParcelableExtra(UIProvider.UpdateNotificationExtras.EXTRA_ACCOUNT); final Uri folderUri = diff --git a/src/com/android/email/activity/setup/AccountCreationFragment.java b/src/com/android/email/activity/setup/AccountCreationFragment.java index e5736774c..1f0d685d7 100644 --- a/src/com/android/email/activity/setup/AccountCreationFragment.java +++ b/src/com/android/email/activity/setup/AccountCreationFragment.java @@ -28,6 +28,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.RemoteException; +import com.android.email.provider.EmailProvider; import com.android.email.service.EmailServiceUtils; import com.android.email2.ui.MailActivityEmail; import com.android.emailcommon.provider.Account; @@ -298,7 +299,7 @@ public class AccountCreationFragment extends Fragment { account.mFlags &= ~Account.FLAGS_SECURITY_HOLD; AccountSettingsUtils.commitSettings(mAppContext, account); // Start up services based on new account(s) - MailActivityEmail.setServicesEnabledSync(mAppContext); + EmailProvider.setServicesEnabledSync(mAppContext); EmailServiceUtils .startService(mAppContext, account.mHostAuthRecv.mProtocol); return account; diff --git a/src/com/android/email/activity/setup/AccountServerSettingsActivity.java b/src/com/android/email/activity/setup/AccountServerSettingsActivity.java index b0782570e..f119219bb 100644 --- a/src/com/android/email/activity/setup/AccountServerSettingsActivity.java +++ b/src/com/android/email/activity/setup/AccountServerSettingsActivity.java @@ -26,6 +26,7 @@ import android.content.Intent; import android.os.Bundle; import com.android.email.R; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.emailcommon.provider.Account; import com.android.mail.utils.LogUtils; @@ -65,7 +66,7 @@ public class AccountServerSettingsActivity extends AccountSetupActivity implemen public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mSetupData.setFlowMode(SetupDataFragment.FLOW_MODE_EDIT); + mSetupData.setFlowMode(AuthenticatorSetupIntentHelper.FLOW_MODE_EDIT); setContentView(R.layout.account_server_settings); setFinishOnTouchOutside(false); diff --git a/src/com/android/email/activity/setup/AccountSettingsFragment.java b/src/com/android/email/activity/setup/AccountSettingsFragment.java index f6ea75614..91e14d608 100644 --- a/src/com/android/email/activity/setup/AccountSettingsFragment.java +++ b/src/com/android/email/activity/setup/AccountSettingsFragment.java @@ -52,7 +52,6 @@ import com.android.email.provider.EmailProvider; import com.android.email.provider.FolderPickerActivity; import com.android.email.service.EmailServiceUtils; import com.android.email.service.EmailServiceUtils.EmailServiceInfo; -import com.android.email2.ui.MailActivityEmail; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.EmailContent; import com.android.emailcommon.provider.EmailContent.AccountColumns; @@ -402,7 +401,7 @@ public class AccountSettingsFragment extends MailAccountPrefsFragment } if (cv.size() > 0) { new UpdateTask().run(mContext.getContentResolver(), mAccount.getUri(), cv, null, null); - MailActivityEmail.setServicesEnabledAsync(mContext); + EmailProvider.setServicesEnabledAsync(mContext); } return false; } diff --git a/src/com/android/email/activity/setup/AccountSetupFinal.java b/src/com/android/email/activity/setup/AccountSetupFinal.java index 85ee24e99..ed33a5f5d 100644 --- a/src/com/android/email/activity/setup/AccountSetupFinal.java +++ b/src/com/android/email/activity/setup/AccountSetupFinal.java @@ -43,6 +43,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.Toast; import com.android.email.R; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.email.service.EmailServiceUtils; import com.android.emailcommon.VendorPolicyLoader; import com.android.emailcommon.provider.Account; @@ -97,8 +98,6 @@ public class AccountSetupFinal extends AccountSetupActivity * and the appropriate incoming/outgoing information will be filled in automatically. */ private static String INTENT_FORCE_CREATE_ACCOUNT; - private static final String EXTRA_FLOW_MODE = "FLOW_MODE"; - private static final String EXTRA_FLOW_ACCOUNT_TYPE = "FLOW_ACCOUNT_TYPE"; private static final String EXTRA_CREATE_ACCOUNT_EMAIL = "EMAIL"; private static final String EXTRA_CREATE_ACCOUNT_USER = "USER"; private static final String EXTRA_CREATE_ACCOUNT_PASSWORD = "PASSWORD"; @@ -180,26 +179,6 @@ public class AccountSetupFinal extends AccountSetupActivity private static final int EXISTING_ACCOUNTS_LOADER_ID = 1; private Map mExistingAccountsMap; - public static Intent actionNewAccountIntent(final Context context) { - final Intent i = new Intent(context, AccountSetupFinal.class); - i.putExtra(EXTRA_FLOW_MODE, SetupDataFragment.FLOW_MODE_NORMAL); - return i; - } - - public static Intent actionNewAccountWithResultIntent(final Context context) { - final Intent i = new Intent(context, AccountSetupFinal.class); - i.putExtra(EXTRA_FLOW_MODE, SetupDataFragment.FLOW_MODE_NO_ACCOUNTS); - return i; - } - - public static Intent actionGetCreateAccountIntent(final Context context, - final String accountManagerType) { - final Intent i = new Intent(context, AccountSetupFinal.class); - i.putExtra(EXTRA_FLOW_MODE, SetupDataFragment.FLOW_MODE_ACCOUNT_MANAGER); - i.putExtra(EXTRA_FLOW_ACCOUNT_TYPE, accountManagerType); - return i; - } - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -250,11 +229,13 @@ public class AccountSetupFinal extends AccountSetupActivity // Initialize the SetupDataFragment if (INTENT_FORCE_CREATE_ACCOUNT.equals(action)) { - mSetupData.setFlowMode(SetupDataFragment.FLOW_MODE_FORCE_CREATE); + mSetupData.setFlowMode(AuthenticatorSetupIntentHelper.FLOW_MODE_FORCE_CREATE); } else { - final int intentFlowMode = intent.getIntExtra(EXTRA_FLOW_MODE, - SetupDataFragment.FLOW_MODE_UNSPECIFIED); - final String flowAccountType = intent.getStringExtra(EXTRA_FLOW_ACCOUNT_TYPE); + final int intentFlowMode = intent.getIntExtra( + AuthenticatorSetupIntentHelper.EXTRA_FLOW_MODE, + AuthenticatorSetupIntentHelper.FLOW_MODE_UNSPECIFIED); + final String flowAccountType = intent.getStringExtra( + AuthenticatorSetupIntentHelper.EXTRA_FLOW_ACCOUNT_TYPE); mSetupData.setAmProtocol( EmailServiceUtils.getProtocolFromAccountType(this, flowAccountType)); mSetupData.setFlowMode(intentFlowMode); @@ -273,8 +254,8 @@ public class AccountSetupFinal extends AccountSetupActivity mPasswordFailed = false; } - if (!mIsProcessing - && mSetupData.getFlowMode() == SetupDataFragment.FLOW_MODE_FORCE_CREATE) { + if (!mIsProcessing && mSetupData.getFlowMode() == + AuthenticatorSetupIntentHelper.FLOW_MODE_FORCE_CREATE) { /** * To support continuous testing, we allow the forced creation of accounts. * This works in a manner fairly similar to automatic setup, in which the complete @@ -679,7 +660,8 @@ public class AccountSetupFinal extends AccountSetupActivity case STATE_CREATING: mState = STATE_NAMES; updateContentFragment(true /* addToBackstack */); - if (mSetupData.getFlowMode() == SetupDataFragment.FLOW_MODE_FORCE_CREATE) { + if (mSetupData.getFlowMode() == + AuthenticatorSetupIntentHelper.FLOW_MODE_FORCE_CREATE) { getFragmentManager().executePendingTransactions(); initiateAccountFinalize(); } diff --git a/src/com/android/email/activity/setup/AccountSetupNamesFragment.java b/src/com/android/email/activity/setup/AccountSetupNamesFragment.java index 363de9bf6..f9c20dc6a 100644 --- a/src/com/android/email/activity/setup/AccountSetupNamesFragment.java +++ b/src/com/android/email/activity/setup/AccountSetupNamesFragment.java @@ -33,6 +33,7 @@ import android.widget.EditText; import com.android.email.R; import com.android.email.activity.UiUtilities; import com.android.email.service.EmailServiceUtils; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.emailcommon.provider.Account; public class AccountSetupNamesFragment extends AccountSetupFragment { @@ -81,8 +82,8 @@ public class AccountSetupNamesFragment extends AccountSetupFragment { final Account account = setupData.getAccount(); - if (flowMode != SetupDataFragment.FLOW_MODE_FORCE_CREATE - && flowMode != SetupDataFragment.FLOW_MODE_EDIT) { + if (flowMode != AuthenticatorSetupIntentHelper.FLOW_MODE_FORCE_CREATE + && flowMode != AuthenticatorSetupIntentHelper.FLOW_MODE_EDIT) { final String accountEmail = account.mEmailAddress; mDescription.setText(accountEmail); @@ -99,8 +100,8 @@ public class AccountSetupNamesFragment extends AccountSetupFragment { } else { if (account.getSenderName() != null) { mName.setText(account.getSenderName()); - } else if (flowMode != SetupDataFragment.FLOW_MODE_FORCE_CREATE - && flowMode != SetupDataFragment.FLOW_MODE_EDIT) { + } else if (flowMode != AuthenticatorSetupIntentHelper.FLOW_MODE_FORCE_CREATE + && flowMode != AuthenticatorSetupIntentHelper.FLOW_MODE_EDIT) { // Attempt to prefill the name field from the profile if we don't have it, final Context loaderContext = getActivity().getApplicationContext(); getLoaderManager().initLoader(0, null, new LoaderManager.LoaderCallbacks() { diff --git a/src/com/android/email/activity/setup/EmailPreferenceActivity.java b/src/com/android/email/activity/setup/EmailPreferenceActivity.java index 4a5dc4ed9..cbb47b922 100644 --- a/src/com/android/email/activity/setup/EmailPreferenceActivity.java +++ b/src/com/android/email/activity/setup/EmailPreferenceActivity.java @@ -27,6 +27,7 @@ import android.view.Menu; import android.view.MenuItem; import com.android.email.R; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.emailcommon.utility.IntentUtilities; import com.android.mail.providers.UIProvider.EditSettingsExtras; import com.android.mail.ui.settings.MailPreferenceActivity; @@ -201,7 +202,7 @@ public class EmailPreferenceActivity extends MailPreferenceActivity { } private void onAddNewAccount() { - final Intent setupIntent = AccountSetupFinal.actionNewAccountIntent(this); + final Intent setupIntent = AuthenticatorSetupIntentHelper.actionNewAccountIntent(this); startActivity(setupIntent); } diff --git a/src/com/android/email/activity/setup/HeadlessAccountSettingsLoader.java b/src/com/android/email/activity/setup/HeadlessAccountSettingsLoader.java index 09eedd9a5..bca6d5545 100644 --- a/src/com/android/email/activity/setup/HeadlessAccountSettingsLoader.java +++ b/src/com/android/email/activity/setup/HeadlessAccountSettingsLoader.java @@ -21,13 +21,6 @@ import com.android.mail.ui.MailAsyncTaskLoader; */ public class HeadlessAccountSettingsLoader extends Activity { - public static Uri getIncomingSettingsUri(long accountId) { - final Uri.Builder baseUri = Uri.parse("auth://" + EmailContent.EMAIL_PACKAGE_NAME + - ".ACCOUNT_SETTINGS/incoming/").buildUpon(); - IntentUtilities.setAccountId(baseUri, accountId); - return baseUri.build(); - } - public static Uri getOutgoingSettingsUri(long accountId) { final Uri.Builder baseUri = Uri.parse("auth://" + EmailContent.EMAIL_PACKAGE_NAME + ".ACCOUNT_SETTINGS/outgoing/").buildUpon(); diff --git a/src/com/android/email/activity/setup/SetupDataFragment.java b/src/com/android/email/activity/setup/SetupDataFragment.java index 45b7cf1ad..9824e1b34 100644 --- a/src/com/android/email/activity/setup/SetupDataFragment.java +++ b/src/com/android/email/activity/setup/SetupDataFragment.java @@ -7,6 +7,7 @@ import android.os.Parcel; import android.os.Parcelable; import com.android.email.service.EmailServiceUtils; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.HostAuth; import com.android.emailcommon.provider.Policy; @@ -18,20 +19,12 @@ public class SetupDataFragment extends Fragment implements Parcelable { // The "extra" name for the Bundle saved with SetupData public static final String EXTRA_SETUP_DATA = "com.android.email.setupdata"; - // NORMAL is the standard entry from the Email app; EAS and POP_IMAP are used when entering via - // Settings -> Accounts - public static final int FLOW_MODE_UNSPECIFIED = -1; - public static final int FLOW_MODE_NORMAL = 0; - public static final int FLOW_MODE_ACCOUNT_MANAGER = 1; - public static final int FLOW_MODE_EDIT = 3; - public static final int FLOW_MODE_FORCE_CREATE = 4; // The following two modes are used to "pop the stack" and return from the setup flow. We // either return to the caller (if we're in an account type flow) or go to the message list // TODO: figure out if we still care about these public static final int FLOW_MODE_RETURN_TO_CALLER = 5; public static final int FLOW_MODE_RETURN_TO_MESSAGE_LIST = 6; public static final int FLOW_MODE_RETURN_NO_ACCOUNTS_RESULT = 7; - public static final int FLOW_MODE_NO_ACCOUNTS = 8; // Mode bits for AccountSetupCheckSettings, indicating the type of check requested public static final int CHECK_INCOMING = 1; @@ -49,7 +42,7 @@ public class SetupDataFragment extends Fragment implements Parcelable { private static final String SAVESTATE_AM_PROTOCOL = "SetupDataFragment.amProtocol"; // All access will be through getters/setters - private int mFlowMode = FLOW_MODE_NORMAL; + private int mFlowMode = AuthenticatorSetupIntentHelper.FLOW_MODE_NORMAL; private Account mAccount; private String mEmail; private Bundle mCredentialResults; diff --git a/src/com/android/email2/ui/MailActivityEmail.java b/src/com/android/email2/ui/MailActivityEmail.java index b2403de06..23b3facea 100644 --- a/src/com/android/email2/ui/MailActivityEmail.java +++ b/src/com/android/email2/ui/MailActivityEmail.java @@ -26,21 +26,14 @@ import android.database.Cursor; import android.net.Uri; import android.os.Bundle; -import com.android.email.NotificationController; import com.android.email.Preferences; -import com.android.email.R; import com.android.email.provider.EmailProvider; import com.android.email.service.AttachmentService; import com.android.email.service.EmailServiceUtils; import com.android.emailcommon.Logging; import com.android.emailcommon.TempDirectory; -import com.android.emailcommon.provider.Account; -import com.android.emailcommon.provider.EmailContent; import com.android.emailcommon.provider.Mailbox; -import com.android.emailcommon.service.EmailServiceProxy; -import com.android.emailcommon.utility.EmailAsyncTask; import com.android.emailcommon.utility.IntentUtilities; -import com.android.emailcommon.utility.Utility; import com.android.mail.providers.Folder; import com.android.mail.providers.UIProvider; import com.android.mail.utils.LogTag; @@ -62,78 +55,6 @@ public class MailActivityEmail extends com.android.mail.ui.MailActivity { } - /** - * Asynchronous version of {@link #setServicesEnabledSync(Context)}. Use when calling from - * UI thread (or lifecycle entry points.) - */ - public static void setServicesEnabledAsync(final Context context) { - if (context.getResources().getBoolean(R.bool.enable_services)) { - EmailAsyncTask.runAsyncParallel(new Runnable() { - @Override - public void run() { - setServicesEnabledSync(context); - } - }); - } - } - - /** - * Called throughout the application when the number of accounts has changed. This method - * enables or disables the Compose activity, the boot receiver and the service based on - * whether any accounts are configured. - * - * Blocking call - do not call from UI/lifecycle threads. - * - * @return true if there are any accounts configured. - */ - public static boolean setServicesEnabledSync(Context context) { - // Make sure we're initialized - EmailContent.init(context); - Cursor c = null; - try { - c = context.getContentResolver().query( - Account.CONTENT_URI, - Account.ID_PROJECTION, - null, null, null); - boolean enable = c != null && c.getCount() > 0; - setServicesEnabled(context, enable); - return enable; - } finally { - if (c != null) { - c.close(); - } - } - } - - private static void setServicesEnabled(Context context, boolean enabled) { - PackageManager pm = context.getPackageManager(); - pm.setComponentEnabledSetting( - new ComponentName(context, AttachmentService.class), - enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - PackageManager.DONT_KILL_APP); - - // Start/stop the various services depending on whether there are any accounts - // TODO: Make sure that the AttachmentService responds to this request as it - // expects a particular set of data in the intents that it receives or it ignores. - startOrStopService(enabled, context, new Intent(context, AttachmentService.class)); - NotificationController.getInstance(context).watchForMessages(); - } - - /** - * Starts or stops the service as necessary. - * @param enabled If {@code true}, the service will be started. Otherwise, it will be stopped. - * @param context The context to manage the service with. - * @param intent The intent of the service to be managed. - */ - private static void startOrStopService(boolean enabled, Context context, Intent intent) { - if (enabled) { - context.startService(intent); - } else { - context.stopService(intent); - } - } - @Override public void onCreate(Bundle bundle) { final Intent intent = getIntent(); @@ -163,7 +84,7 @@ public class MailActivityEmail extends com.android.mail.ui.MailActivity { // Make sure all required services are running when the app is started (can prevent // issues after an adb sync/install) - setServicesEnabledAsync(this); + EmailProvider.setServicesEnabledAsync(this); } /** diff --git a/src/com/android/mail/providers/EmailAccountCacheProvider.java b/src/com/android/mail/providers/EmailAccountCacheProvider.java index 118e31dfa..1d25966ee 100644 --- a/src/com/android/mail/providers/EmailAccountCacheProvider.java +++ b/src/com/android/mail/providers/EmailAccountCacheProvider.java @@ -22,6 +22,7 @@ import android.net.Uri; import com.android.email.R; import com.android.email.activity.setup.AccountSetupFinal; +import com.android.email.setup.AuthenticatorSetupIntentHelper; public class EmailAccountCacheProvider extends MailAppProvider { // Content provider for Email @@ -36,6 +37,6 @@ public class EmailAccountCacheProvider extends MailAppProvider { @Override protected Intent getNoAccountsIntent(Context context) { - return AccountSetupFinal.actionNewAccountWithResultIntent(context); + return AuthenticatorSetupIntentHelper.actionNewAccountWithResultIntent(context); } } diff --git a/tests/src/com/android/email/NotificationControllerTest.java b/tests/src/com/android/email/NotificationControllerTest.java deleted file mode 100644 index 9e7f149c5..000000000 --- a/tests/src/com/android/email/NotificationControllerTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.email; - -import android.content.Context; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.Suppress; - -/** - * Test for {@link NotificationController}. - * - * TODO Add tests for all methods. - */ -@Suppress -public class NotificationControllerTest extends AndroidTestCase { - private Context mProviderContext; - private NotificationController mTarget; - - private final MockClock mMockClock = new MockClock(); - private int mRingerMode; - - /** - * Subclass {@link NotificationController} to override un-mockable operations. - */ - protected class NotificationControllerForTest extends NotificationController { - NotificationControllerForTest(Context context) { - super(context, mMockClock); - } - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mProviderContext = DBTestHelper.ProviderContextSetupHelper.getProviderContext(mContext); - mTarget = new NotificationControllerForTest(mProviderContext); - } - - // the ringtone and vibration flags are depracated and the method that we use - // to test notification has been removed in - // https://googleplex-android-review.googlesource.com/#/c/271237/ -} diff --git a/tests/src/com/android/email/activity/ContactStatusLoaderTest.java b/tests/src/com/android/email/activity/ContactStatusLoaderTest.java deleted file mode 100644 index ebc946253..000000000 --- a/tests/src/com/android/email/activity/ContactStatusLoaderTest.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.email.activity; - -import com.android.email.activity.ContactStatusLoader.Result; -import com.android.mail.utils.MatrixCursorWithCachedColumns; - -import android.content.Context; -import android.content.pm.ProviderInfo; -import android.database.Cursor; -import android.database.MatrixCursor; -import android.graphics.Bitmap; -import android.net.Uri; -import android.provider.ContactsContract; -import android.provider.ContactsContract.StatusUpdates; -import android.test.ProviderTestCase2; -import android.test.mock.MockContentProvider; -import android.test.suitebuilder.annotation.SmallTest; - -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.Queue; -import java.util.concurrent.LinkedBlockingQueue; - -import junit.framework.Assert; - -/** - * Test for {@link ContactStatusLoader} - * - * Unfortunately this doesn't check {@link ContactStatusLoader.Result#mLookupUri}, because we don't - * (shouldn't) know how {@link android.provider.ContactsContract.Data#getContactLookupUri} is - * implemented. - */ -@SmallTest -public class ContactStatusLoaderTest - extends ProviderTestCase2 { - private static final String EMAIL = "a@b.c"; - - private MockContactProvider mProvider; - - public ContactStatusLoaderTest() { - super(MockContactProvider.class, ContactsContract.AUTHORITY); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mProvider = getProvider(); - } - - // Contact doesn't exist - public void brokentestContactNotFound() { - // Insert empty cursor - mProvider.mCursors.offer(new MatrixCursorWithCachedColumns( - ContactStatusLoader.PROJECTION_PHOTO_ID_PRESENCE)); - - // Load! - ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL); - Result r = l.loadInBackground(); - - // Check input to the provider - assertEquals(1, mProvider.mUris.size()); - assertEquals("content://com.android.contacts/data/emails/lookup/a%40b.c", - mProvider.mUris.get(0)); - - // Check result - assertNull(r.mPhoto); - assertEquals(ContactStatusLoader.PRESENCE_UNKNOWN_RESOURCE_ID, r.mPresenceResId); - } - - // Contact doesn't exist -- provider returns null for the first query - public void brokentestNull() { - // No cursor prepared. (Mock provider will return null) - - // Load! - ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL); - Result r = l.loadInBackground(); - - // Check result - assertNull(r.mPhoto); - assertEquals(ContactStatusLoader.PRESENCE_UNKNOWN_RESOURCE_ID, r.mPresenceResId); - } - - // Contact exists, but no photo - public void brokentestNoPhoto() { - // Result for the first query (the one for photo-id) - MatrixCursor cursor1 = - new MatrixCursorWithCachedColumns(ContactStatusLoader.PROJECTION_PHOTO_ID_PRESENCE); - cursor1.addRow(new Object[]{12345, StatusUpdates.AWAY}); - mProvider.mCursors.offer(cursor1); - - // Empty cursor for the second query - mProvider.mCursors.offer( - new MatrixCursorWithCachedColumns(ContactStatusLoader.PHOTO_PROJECTION)); - - // Load! - ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL); - Result r = l.loadInBackground(); - - // Check input to the provider - // We should have had at least two queries from loadInBackground. - // There can be extra queries from getContactLookupUri(), but this test shouldn't know - // the details, so use ">= 2". - assertTrue(mProvider.mUris.size() >= 2); - assertEquals("content://com.android.contacts/data/emails/lookup/a%40b.c", - mProvider.mUris.get(0)); - assertEquals("content://com.android.contacts/data/12345", - mProvider.mUris.get(1)); - - // Check result - assertNull(r.mPhoto); // no photo - assertEquals(android.R.drawable.presence_away, r.mPresenceResId); - } - - // Contact exists, but no photo (provider returns null for the second query) - public void brokentestNull2() { - // Result for the first query (the one for photo-id) - MatrixCursor cursor1 = - new MatrixCursorWithCachedColumns(ContactStatusLoader.PROJECTION_PHOTO_ID_PRESENCE); - cursor1.addRow(new Object[]{12345, StatusUpdates.AWAY}); - mProvider.mCursors.offer(cursor1); - - // No cursor for the second query - - // Load! - ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL); - Result r = l.loadInBackground(); - - // Check result - assertNull(r.mPhoto); // no photo - assertEquals(android.R.drawable.presence_away, r.mPresenceResId); - } - - // Contact exists, with a photo - public void brokentestWithPhoto() { - // Result for the first query (the one for photo-id) - MatrixCursor cursor1 = - new MatrixCursorWithCachedColumns(ContactStatusLoader.PROJECTION_PHOTO_ID_PRESENCE); - cursor1.addRow(new Object[]{12345, StatusUpdates.AWAY}); - mProvider.mCursors.offer(cursor1); - - // Prepare for the second query. - MatrixCursor cursor2 = new PhotoCursor(createJpegData(10, 20)); - mProvider.mCursors.offer(cursor2); - - // Load! - ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL); - Result r = l.loadInBackground(); - - // Check result - assertNotNull(r.mPhoto); - assertEquals(10, r.mPhoto.getWidth()); - assertEquals(android.R.drawable.presence_away, r.mPresenceResId); - } - - private static byte[] createJpegData(int width, int height) { - Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out); - return out.toByteArray(); - } - - // MatrixCursor doesn't support getBlob, so use this... - private static class PhotoCursor extends MatrixCursorWithCachedColumns { - private final byte[] mBlob; - - public PhotoCursor(byte[] blob) { - super(ContactStatusLoader.PHOTO_PROJECTION); - mBlob = blob; - addRow(new Object[] {null}); // Add dummy row - } - - @Override - public byte[] getBlob(int column) { - Assert.assertEquals(0, column); - return mBlob; - } - } - - public static class MockContactProvider extends MockContentProvider { - public ArrayList mUris = new ArrayList(); - - public final Queue mCursors = new LinkedBlockingQueue(); - - @Override - public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, - String sortOrder) { - mUris.add(uri.toString()); - return mCursors.poll(); - } - - @Override - public void attachInfo(Context context, ProviderInfo info) { - } - } -} diff --git a/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java b/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java index bac1e68de..2e1566546 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java @@ -26,6 +26,7 @@ import android.view.View; import android.widget.EditText; import com.android.email.R; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.HostAuth; @@ -198,7 +199,7 @@ public class AccountSetupIncomingTests extends auth.setHostAuthFromString(storeUriString); final SetupDataFragment setupDataFragment = new SetupDataFragment(); - setupDataFragment.setFlowMode(SetupDataFragment.FLOW_MODE_NORMAL); + setupDataFragment.setFlowMode(AuthenticatorSetupIntentHelper.FLOW_MODE_NORMAL); setupDataFragment.setAccount(account); final Intent i = new Intent(AccountSetupFinal.ACTION_JUMP_TO_INCOMING); i.putExtra(SetupDataFragment.EXTRA_SETUP_DATA, setupDataFragment); diff --git a/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java b/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java index f1f9ae043..1e9ad8c1a 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java @@ -27,6 +27,7 @@ import android.widget.Spinner; import android.widget.SpinnerAdapter; import com.android.email.R; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.HostAuth; @@ -173,7 +174,7 @@ public class AccountSetupOptionsTests auth.setHostAuthFromString(storeUri); final SetupDataFragment setupDataFragment = new SetupDataFragment(); - setupDataFragment.setFlowMode(SetupDataFragment.FLOW_MODE_NORMAL); + setupDataFragment.setFlowMode(AuthenticatorSetupIntentHelper.FLOW_MODE_NORMAL); setupDataFragment.setAccount(account); final Intent i = new Intent(AccountSetupFinal.ACTION_JUMP_TO_OPTIONS); i.putExtra(SetupDataFragment.EXTRA_SETUP_DATA, setupDataFragment); diff --git a/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java b/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java index 5cb6a949c..54b1e906c 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java @@ -26,6 +26,7 @@ import android.widget.CheckBox; import android.widget.EditText; import com.android.email.R; +import com.android.email.setup.AuthenticatorSetupIntentHelper; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.HostAuth; @@ -203,7 +204,7 @@ public class AccountSetupOutgoingTests extends auth.setHostAuthFromString(senderUriString); final SetupDataFragment setupDataFragment = new SetupDataFragment(); - setupDataFragment.setFlowMode(SetupDataFragment.FLOW_MODE_NORMAL); + setupDataFragment.setFlowMode(AuthenticatorSetupIntentHelper.FLOW_MODE_NORMAL); setupDataFragment.setAccount(account); final Intent i = new Intent(AccountSetupFinal.ACTION_JUMP_TO_OUTGOING); i.putExtra(SetupDataFragment.EXTRA_SETUP_DATA, setupDataFragment);