Use AccountManager for POP/IMAP; refactor setup classes
There are two major, interrelated parts to this CL:
1) Clean up the activities to reduce the use of Intents to pass
information between activities; instead, we use a common
SetupData structure that automatically saved/restored as necessary
during the setup flow. A fair amount of code and inconsistent
use of Bundle extras has been eliminated in the process.
* Create SetupData structure, setters/getters, and initialization
methods to simplify the preservation of state during setup flow
* Remove all state/flow extras from Intents; Intents now only
specify the Activity to be started, which should greatly simplify
the transition to Fragments.
* Remove all state/flow fields from Activities
* Modify existing setup activity unit tests and confirm tests pass
2) Create AccountManager accounts for POP/IMAP email accounts to
provide consistency in user experience. Also, internal flows are
now identical as between account types.
* Move account reconciliation from SyncManager to MailService, so
that reconciliation is consistent between email and exchange
accounts; move unit tests as appropriate
* Add a "Sync Email" setting for POP/IMAP/EAS
* Change MailService to respect the "Sync Email" setting in
Settings -> Accounts & sync
* Create PopImapSyncAdapterService to handle manual POP/IMAP sync as
requested by SyncManager; add EmailSyncAdapterService to perform
the same function for EAS
* Use new PopImapAuthenticatorService to add AccountManager accounts
for POP/IMAP accounts; setup appropriate stanzas in AndroidManifest
and add related xml files
* Update AccountSettings to use SetupData
Miscellaneous other changes:
* Only allow valid port numbers in incoming/outgoing setup
Bug: 1712475
Change-Id: Ibdac52fb2c5578b86bf3992ddb1acd10f162391a
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a5b3973..dc5437b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -277,7 +277,45 @@
</service>
<!--EXCHANGE-REMOVE-SECTION-START-->
- <!--Required stanza to register the ContactsSyncAdapterService with SyncManager -->
+ <!--Required stanza to register the PopImapAuthenticatorService with AccountManager -->
+ <service
+ android:name=".service.PopImapAuthenticatorService"
+ android:exported="true"
+ android:enabled="true"
+ >
+ <intent-filter>
+ <action android:name="android.accounts.AccountAuthenticator" />
+ </intent-filter>
+ <meta-data
+ android:name="android.accounts.AccountAuthenticator"
+ android:resource="@xml/pop_imap_authenticator"
+ />
+ </service>
+
+ <!--Required stanza to register the PopImapSyncAdapterService with SyncManager -->
+ <service
+ android:name="com.android.email.service.PopImapSyncAdapterService"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.content.SyncAdapter" />
+ </intent-filter>
+ <meta-data android:name="android.content.SyncAdapter"
+ android:resource="@xml/syncadapter_pop_imap" />
+ </service>
+
+ <!--EXCHANGE-REMOVE-SECTION-START-->
+ <!--Required stanza to register the EAS EmailSyncAdapterService with SyncManager -->
+ <service
+ android:name="com.android.exchange.EmailSyncAdapterService"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.content.SyncAdapter" />
+ </intent-filter>
+ <meta-data android:name="android.content.SyncAdapter"
+ android:resource="@xml/syncadapter_email" />
+ </service>
+
+ <!--Required stanza to register the EAS ContactsSyncAdapterService with SyncManager -->
<service
android:name="com.android.exchange.ContactsSyncAdapterService"
android:exported="true">
@@ -288,7 +326,7 @@
android:resource="@xml/syncadapter_contacts" />
</service>
- <!--Required stanza to register the CalendarSyncAdapterService with SyncManager -->
+ <!--Required stanza to register the EAS CalendarSyncAdapterService with SyncManager -->
<service
android:name="com.android.exchange.CalendarSyncAdapterService"
android:exported="true">
@@ -317,7 +355,7 @@
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
- android:resource="@xml/authenticator"
+ android:resource="@xml/eas_authenticator"
/>
</service>
<!--
@@ -354,6 +392,7 @@
android:authorities="com.android.email.provider"
android:multiprocess="true"
android:permission="com.android.email.permission.ACCESS_PROVIDER"
+ android:label="@string/app_name"
/>
<!--EXCHANGE-REMOVE-SECTION-START-->