summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk1
-rw-r--r--proguard.flags2
-rw-r--r--provider_src/com/android/email/AttachmentInfo.java (renamed from src/com/android/email/AttachmentInfo.java)0
-rw-r--r--provider_src/com/android/email/DebugUtils.java (renamed from src/com/android/email/DebugUtils.java)0
-rw-r--r--provider_src/com/android/email/EmailConnectivityManager.java (renamed from src/com/android/email/EmailConnectivityManager.java)0
-rw-r--r--provider_src/com/android/email/EmailIntentService.java (renamed from src/com/android/email/EmailIntentService.java)6
-rw-r--r--provider_src/com/android/email/FixedLengthInputStream.java (renamed from src/com/android/email/FixedLengthInputStream.java)0
-rw-r--r--provider_src/com/android/email/LegacyConversions.java (renamed from src/com/android/email/LegacyConversions.java)0
-rw-r--r--provider_src/com/android/email/NotificationController.java39
-rw-r--r--provider_src/com/android/email/NotificationControllerCreator.java23
-rw-r--r--provider_src/com/android/email/NotificationControllerCreatorHolder.java42
-rw-r--r--provider_src/com/android/email/PeekableInputStream.java (renamed from src/com/android/email/PeekableInputStream.java)0
-rw-r--r--provider_src/com/android/email/Preferences.java (renamed from src/com/android/email/Preferences.java)0
-rw-r--r--provider_src/com/android/email/ResourceHelper.java (renamed from src/com/android/email/ResourceHelper.java)0
-rw-r--r--provider_src/com/android/email/SecurityPolicy.java (renamed from src/com/android/email/SecurityPolicy.java)42
-rw-r--r--provider_src/com/android/email/activity/setup/AccountSecurity.java (renamed from src/com/android/email/activity/setup/AccountSecurity.java)0
-rw-r--r--provider_src/com/android/email/activity/setup/AccountSettingsUtils.java (renamed from src/com/android/email/activity/setup/AccountSettingsUtils.java)0
-rw-r--r--provider_src/com/android/email/activity/setup/ForwardingIntent.java (renamed from src/com/android/email/activity/setup/ForwardingIntent.java)0
-rw-r--r--provider_src/com/android/email/mail/Sender.java (renamed from src/com/android/email/mail/Sender.java)0
-rw-r--r--provider_src/com/android/email/mail/Store.java (renamed from src/com/android/email/mail/Store.java)0
-rw-r--r--provider_src/com/android/email/mail/internet/AuthenticationCache.java (renamed from src/com/android/email/mail/internet/AuthenticationCache.java)0
-rw-r--r--provider_src/com/android/email/mail/internet/OAuthAuthenticator.java (renamed from src/com/android/email/mail/internet/OAuthAuthenticator.java)0
-rw-r--r--provider_src/com/android/email/mail/store/ImapConnection.java (renamed from src/com/android/email/mail/store/ImapConnection.java)0
-rw-r--r--provider_src/com/android/email/mail/store/ImapFolder.java (renamed from src/com/android/email/mail/store/ImapFolder.java)0
-rw-r--r--provider_src/com/android/email/mail/store/ImapStore.java (renamed from src/com/android/email/mail/store/ImapStore.java)0
-rw-r--r--provider_src/com/android/email/mail/store/Pop3Store.java (renamed from src/com/android/email/mail/store/Pop3Store.java)0
-rw-r--r--provider_src/com/android/email/mail/store/ServiceStore.java (renamed from src/com/android/email/mail/store/ServiceStore.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapConstants.java (renamed from src/com/android/email/mail/store/imap/ImapConstants.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapElement.java (renamed from src/com/android/email/mail/store/imap/ImapElement.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapList.java (renamed from src/com/android/email/mail/store/imap/ImapList.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapMemoryLiteral.java (renamed from src/com/android/email/mail/store/imap/ImapMemoryLiteral.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapResponse.java (renamed from src/com/android/email/mail/store/imap/ImapResponse.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapResponseParser.java (renamed from src/com/android/email/mail/store/imap/ImapResponseParser.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapSimpleString.java (renamed from src/com/android/email/mail/store/imap/ImapSimpleString.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapString.java (renamed from src/com/android/email/mail/store/imap/ImapString.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapTempFileLiteral.java (renamed from src/com/android/email/mail/store/imap/ImapTempFileLiteral.java)0
-rw-r--r--provider_src/com/android/email/mail/store/imap/ImapUtility.java (renamed from src/com/android/email/mail/store/imap/ImapUtility.java)0
-rw-r--r--provider_src/com/android/email/mail/transport/DiscourseLogger.java (renamed from src/com/android/email/mail/transport/DiscourseLogger.java)0
-rw-r--r--provider_src/com/android/email/mail/transport/MailTransport.java (renamed from src/com/android/email/mail/transport/MailTransport.java)0
-rw-r--r--provider_src/com/android/email/provider/AccountBackupRestore.java (renamed from src/com/android/email/provider/AccountBackupRestore.java)0
-rw-r--r--provider_src/com/android/email/provider/AccountReconciler.java (renamed from src/com/android/email/provider/AccountReconciler.java)9
-rw-r--r--provider_src/com/android/email/provider/AttachmentProvider.java (renamed from src/com/android/email/provider/AttachmentProvider.java)0
-rw-r--r--provider_src/com/android/email/provider/ContentCache.java (renamed from src/com/android/email/provider/ContentCache.java)0
-rw-r--r--provider_src/com/android/email/provider/DBHelper.java (renamed from src/com/android/email/provider/DBHelper.java)0
-rw-r--r--provider_src/com/android/email/provider/EmailConversationCursor.java (renamed from src/com/android/email/provider/EmailConversationCursor.java)0
-rw-r--r--provider_src/com/android/email/provider/EmailMessageCursor.java (renamed from src/com/android/email/provider/EmailMessageCursor.java)0
-rw-r--r--provider_src/com/android/email/provider/EmailProvider.java (renamed from src/com/android/email/provider/EmailProvider.java)105
-rw-r--r--provider_src/com/android/email/provider/FolderPickerActivity.java (renamed from src/com/android/email/provider/FolderPickerActivity.java)0
-rw-r--r--provider_src/com/android/email/provider/FolderPickerCallback.java (renamed from src/com/android/email/provider/FolderPickerCallback.java)0
-rw-r--r--provider_src/com/android/email/provider/FolderPickerDialog.java (renamed from src/com/android/email/provider/FolderPickerDialog.java)0
-rw-r--r--provider_src/com/android/email/provider/FolderPickerSelectorAdapter.java (renamed from src/com/android/email/provider/FolderPickerSelectorAdapter.java)0
-rw-r--r--provider_src/com/android/email/provider/RefreshStatusMonitor.java (renamed from src/com/android/email/provider/RefreshStatusMonitor.java)0
-rw-r--r--provider_src/com/android/email/provider/Utilities.java (renamed from src/com/android/email/provider/Utilities.java)0
-rw-r--r--provider_src/com/android/email/provider/WidgetProvider.java (renamed from src/com/android/email/provider/WidgetProvider.java)0
-rw-r--r--provider_src/com/android/email/service/AccountService.java (renamed from src/com/android/email/service/AccountService.java)0
-rw-r--r--provider_src/com/android/email/service/AttachmentService.java (renamed from src/com/android/email/service/AttachmentService.java)8
-rw-r--r--provider_src/com/android/email/service/AuthenticatorService.java (renamed from src/com/android/email/service/AuthenticatorService.java)6
-rw-r--r--provider_src/com/android/email/service/EasAuthenticatorService.java (renamed from src/com/android/email/service/EasAuthenticatorService.java)0
-rw-r--r--provider_src/com/android/email/service/EasAuthenticatorServiceAlternate.java (renamed from src/com/android/email/service/EasAuthenticatorServiceAlternate.java)0
-rw-r--r--provider_src/com/android/email/service/EasTestAuthenticatorService.java (renamed from src/com/android/email/service/EasTestAuthenticatorService.java)6
-rw-r--r--provider_src/com/android/email/service/EmailBroadcastProcessorService.java (renamed from src/com/android/email/service/EmailBroadcastProcessorService.java)0
-rw-r--r--provider_src/com/android/email/service/EmailBroadcastReceiver.java (renamed from src/com/android/email/service/EmailBroadcastReceiver.java)0
-rw-r--r--provider_src/com/android/email/service/EmailServiceStub.java (renamed from src/com/android/email/service/EmailServiceStub.java)12
-rw-r--r--provider_src/com/android/email/service/EmailServiceUtils.java (renamed from src/com/android/email/service/EmailServiceUtils.java)0
-rw-r--r--provider_src/com/android/email/service/EmailUpgradeBroadcastReceiver.java (renamed from src/com/android/email/service/EmailUpgradeBroadcastReceiver.java)0
-rw-r--r--provider_src/com/android/email/service/ImapAuthenticatorService.java (renamed from src/com/android/email/service/ImapAuthenticatorService.java)0
-rw-r--r--provider_src/com/android/email/service/ImapService.java (renamed from src/com/android/email/service/ImapService.java)4
-rw-r--r--provider_src/com/android/email/service/ImapTempFileLiteral.java (renamed from src/com/android/email/service/ImapTempFileLiteral.java)0
-rw-r--r--provider_src/com/android/email/service/LegacyEasAuthenticatorService.java (renamed from src/com/android/email/service/LegacyEasAuthenticatorService.java)0
-rw-r--r--provider_src/com/android/email/service/LegacyEmailAuthenticatorService.java (renamed from src/com/android/email/service/LegacyEmailAuthenticatorService.java)0
-rw-r--r--provider_src/com/android/email/service/LegacyImapAuthenticatorService.java (renamed from src/com/android/email/service/LegacyImapAuthenticatorService.java)0
-rw-r--r--provider_src/com/android/email/service/LegacyImapSyncAdapterService.java (renamed from src/com/android/email/service/LegacyImapSyncAdapterService.java)0
-rw-r--r--provider_src/com/android/email/service/PolicyService.java (renamed from src/com/android/email/service/PolicyService.java)0
-rw-r--r--provider_src/com/android/email/service/Pop3AuthenticatorService.java (renamed from src/com/android/email/service/Pop3AuthenticatorService.java)0
-rw-r--r--provider_src/com/android/email/service/Pop3Service.java (renamed from src/com/android/email/service/Pop3Service.java)10
-rw-r--r--provider_src/com/android/email/service/Pop3SyncAdapterService.java (renamed from src/com/android/email/service/Pop3SyncAdapterService.java)0
-rw-r--r--provider_src/com/android/email/service/PopImapSyncAdapterService.java (renamed from src/com/android/email/service/PopImapSyncAdapterService.java)0
-rw-r--r--provider_src/com/android/email/setup/AuthenticatorSetupIntentHelper.java65
-rw-r--r--src/com/android/email/EmailApplication.java8
-rw-r--r--src/com/android/email/EmailNotificationController.java (renamed from src/com/android/email/NotificationController.java)33
-rw-r--r--src/com/android/email/activity/setup/AccountCreationFragment.java3
-rw-r--r--src/com/android/email/activity/setup/AccountServerSettingsActivity.java3
-rw-r--r--src/com/android/email/activity/setup/AccountSettingsFragment.java3
-rw-r--r--src/com/android/email/activity/setup/AccountSetupFinal.java40
-rw-r--r--src/com/android/email/activity/setup/AccountSetupNamesFragment.java9
-rw-r--r--src/com/android/email/activity/setup/EmailPreferenceActivity.java3
-rw-r--r--src/com/android/email/activity/setup/HeadlessAccountSettingsLoader.java7
-rw-r--r--src/com/android/email/activity/setup/SetupDataFragment.java11
-rw-r--r--src/com/android/email2/ui/MailActivityEmail.java81
-rw-r--r--src/com/android/mail/providers/EmailAccountCacheProvider.java3
-rw-r--r--tests/src/com/android/email/NotificationControllerTest.java55
-rw-r--r--tests/src/com/android/email/activity/ContactStatusLoaderTest.java210
-rw-r--r--tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java3
-rw-r--r--tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java3
-rw-r--r--tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java3
95 files changed, 402 insertions, 456 deletions
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
index 13ff068f7..13ff068f7 100644
--- a/src/com/android/email/AttachmentInfo.java
+++ b/provider_src/com/android/email/AttachmentInfo.java
diff --git a/src/com/android/email/DebugUtils.java b/provider_src/com/android/email/DebugUtils.java
index 94ce78e75..94ce78e75 100644
--- a/src/com/android/email/DebugUtils.java
+++ b/provider_src/com/android/email/DebugUtils.java
diff --git a/src/com/android/email/EmailConnectivityManager.java b/provider_src/com/android/email/EmailConnectivityManager.java
index 90a511f06..90a511f06 100644
--- a/src/com/android/email/EmailConnectivityManager.java
+++ b/provider_src/com/android/email/EmailConnectivityManager.java
diff --git a/src/com/android/email/EmailIntentService.java b/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
index 753c03181..753c03181 100644
--- a/src/com/android/email/FixedLengthInputStream.java
+++ b/provider_src/com/android/email/FixedLengthInputStream.java
diff --git a/src/com/android/email/LegacyConversions.java b/provider_src/com/android/email/LegacyConversions.java
index 3de9b68cc..3de9b68cc 100644
--- a/src/com/android/email/LegacyConversions.java
+++ b/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
index e1c35a2bd..e1c35a2bd 100644
--- a/src/com/android/email/PeekableInputStream.java
+++ b/provider_src/com/android/email/PeekableInputStream.java
diff --git a/src/com/android/email/Preferences.java b/provider_src/com/android/email/Preferences.java
index 49df5fa33..49df5fa33 100644
--- a/src/com/android/email/Preferences.java
+++ b/provider_src/com/android/email/Preferences.java
diff --git a/src/com/android/email/ResourceHelper.java b/provider_src/com/android/email/ResourceHelper.java
index e3c15c12e..e3c15c12e 100644
--- a/src/com/android/email/ResourceHelper.java
+++ b/provider_src/com/android/email/ResourceHelper.java
diff --git a/src/com/android/email/SecurityPolicy.java b/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
index c2be45928..c2be45928 100644
--- a/src/com/android/email/activity/setup/AccountSecurity.java
+++ b/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
index dbbd51ee7..dbbd51ee7 100644
--- a/src/com/android/email/activity/setup/AccountSettingsUtils.java
+++ b/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
index 1fc913ef7..1fc913ef7 100644
--- a/src/com/android/email/activity/setup/ForwardingIntent.java
+++ b/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
index 4e85d70fa..4e85d70fa 100644
--- a/src/com/android/email/mail/Sender.java
+++ b/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
index 377b59448..377b59448 100644
--- a/src/com/android/email/mail/Store.java
+++ b/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
index 21508af35..21508af35 100644
--- a/src/com/android/email/mail/internet/AuthenticationCache.java
+++ b/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
index c3e255b5c..c3e255b5c 100644
--- a/src/com/android/email/mail/internet/OAuthAuthenticator.java
+++ b/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
index 3e71774fb..3e71774fb 100644
--- a/src/com/android/email/mail/store/ImapConnection.java
+++ b/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
index 3a9081131..3a9081131 100644
--- a/src/com/android/email/mail/store/ImapFolder.java
+++ b/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
index d45188837..d45188837 100644
--- a/src/com/android/email/mail/store/ImapStore.java
+++ b/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
index 4ea75ccf3..4ea75ccf3 100644
--- a/src/com/android/email/mail/store/Pop3Store.java
+++ b/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
index ae568f516..ae568f516 100644
--- a/src/com/android/email/mail/store/ServiceStore.java
+++ b/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
index 9f4d59290..9f4d59290 100644
--- a/src/com/android/email/mail/store/imap/ImapConstants.java
+++ b/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
index 80bb6cd99..80bb6cd99 100644
--- a/src/com/android/email/mail/store/imap/ImapElement.java
+++ b/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
index e28355989..e28355989 100644
--- a/src/com/android/email/mail/store/imap/ImapList.java
+++ b/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
index 26f5e6c9c..26f5e6c9c 100644
--- a/src/com/android/email/mail/store/imap/ImapMemoryLiteral.java
+++ b/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
index 05bf594e6..05bf594e6 100644
--- a/src/com/android/email/mail/store/imap/ImapResponse.java
+++ b/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
index 8dd1cf610..8dd1cf610 100644
--- a/src/com/android/email/mail/store/imap/ImapResponseParser.java
+++ b/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
index 190c5237f..190c5237f 100644
--- a/src/com/android/email/mail/store/imap/ImapSimpleString.java
+++ b/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
index d74a7cf0e..d74a7cf0e 100644
--- a/src/com/android/email/mail/store/imap/ImapString.java
+++ b/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
index 4feccc760..4feccc760 100644
--- a/src/com/android/email/mail/store/imap/ImapTempFileLiteral.java
+++ b/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
index dc024cce7..dc024cce7 100644
--- a/src/com/android/email/mail/store/imap/ImapUtility.java
+++ b/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
index 67f4e115b..67f4e115b 100644
--- a/src/com/android/email/mail/transport/DiscourseLogger.java
+++ b/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
index 213fbfc99..213fbfc99 100644
--- a/src/com/android/email/mail/transport/MailTransport.java
+++ b/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
index cb615618a..cb615618a 100644
--- a/src/com/android/email/provider/AccountBackupRestore.java
+++ b/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
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
index c64fb4e4c..c64fb4e4c 100644
--- a/src/com/android/email/provider/AttachmentProvider.java
+++ b/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
index 65021faba..65021faba 100644
--- a/src/com/android/email/provider/ContentCache.java
+++ b/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
index dbeca637c..dbeca637c 100644
--- a/src/com/android/email/provider/DBHelper.java
+++ b/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
index 4a49caa9d..4a49caa9d 100644
--- a/src/com/android/email/provider/EmailConversationCursor.java
+++ b/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
index d57fb1e34..d57fb1e34 100644
--- a/src/com/android/email/provider/EmailMessageCursor.java
+++ b/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
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
index 8e0598b24..8e0598b24 100644
--- a/src/com/android/email/provider/FolderPickerActivity.java
+++ b/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
index a1e127641..a1e127641 100644
--- a/src/com/android/email/provider/FolderPickerCallback.java
+++ b/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
index 37a7ed71f..37a7ed71f 100644
--- a/src/com/android/email/provider/FolderPickerDialog.java
+++ b/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
index e832b4579..e832b4579 100644
--- a/src/com/android/email/provider/FolderPickerSelectorAdapter.java
+++ b/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
index 604d5c1dc..604d5c1dc 100644
--- a/src/com/android/email/provider/RefreshStatusMonitor.java
+++ b/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
index c3b7ec93a..c3b7ec93a 100644
--- a/src/com/android/email/provider/Utilities.java
+++ b/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
index 6909e8902..6909e8902 100644
--- a/src/com/android/email/provider/WidgetProvider.java
+++ b/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
index c8d94a19a..c8d94a19a 100644
--- a/src/com/android/email/service/AccountService.java
+++ b/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
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
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
index 4dbca7f0c..4dbca7f0c 100644
--- a/src/com/android/email/service/EasAuthenticatorService.java
+++ b/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
index 28d8fb72f..28d8fb72f 100644
--- a/src/com/android/email/service/EasAuthenticatorServiceAlternate.java
+++ b/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
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
index 3b15904d7..3b15904d7 100644
--- a/src/com/android/email/service/EmailBroadcastProcessorService.java
+++ b/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
index ce7221043..ce7221043 100644
--- a/src/com/android/email/service/EmailBroadcastReceiver.java
+++ b/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
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
index 3532689c4..3532689c4 100644
--- a/src/com/android/email/service/EmailServiceUtils.java
+++ b/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
index fe48e33a6..fe48e33a6 100644
--- a/src/com/android/email/service/EmailUpgradeBroadcastReceiver.java
+++ b/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
index 975583da3..975583da3 100644
--- a/src/com/android/email/service/ImapAuthenticatorService.java
+++ b/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
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
index b521036f3..b521036f3 100644
--- a/src/com/android/email/service/ImapTempFileLiteral.java
+++ b/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
index d90497c4c..d90497c4c 100644
--- a/src/com/android/email/service/LegacyEasAuthenticatorService.java
+++ b/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
index c5b56444d..c5b56444d 100644
--- a/src/com/android/email/service/LegacyEmailAuthenticatorService.java
+++ b/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
index 8480d1e8d..8480d1e8d 100644
--- a/src/com/android/email/service/LegacyImapAuthenticatorService.java
+++ b/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
index 1f6b6195e..1f6b6195e 100644
--- a/src/com/android/email/service/LegacyImapSyncAdapterService.java
+++ b/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
index c045fabab..c045fabab 100644
--- a/src/com/android/email/service/PolicyService.java
+++ b/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
index f3076ee6b..f3076ee6b 100644
--- a/src/com/android/email/service/Pop3AuthenticatorService.java
+++ b/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
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
index a939f41f9..a939f41f9 100644
--- a/src/com/android/email/service/Pop3SyncAdapterService.java
+++ b/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
index 4fae4d0a9..4fae4d0a9 100644
--- a/src/com/android/email/service/PopImapSyncAdapterService.java
+++ b/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
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<String, String> 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<Cursor>() {
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<ContactStatusLoaderTest.MockContactProvider> {
- 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<String> mUris = new ArrayList<String>();
-
- public final Queue<Cursor> mCursors = new LinkedBlockingQueue<Cursor>();
-
- @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);