Initial support for Exchange account creation via AccountManager
* Export AccountSetupBasics so that it can be launched by AccountManager * Update EasAuthenticatorService to return an Intent for AccountSetupBasics * UI needs to be updated to skip account type screen, change welcome, etc.
This commit is contained in:
parent
6d130d6d6d
commit
06275c4207
|
@ -49,9 +49,11 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!-- Must be exported in order for the AccountManager to launch it -->
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.setup.AccountSetupBasics"
|
android:name=".activity.setup.AccountSetupBasics"
|
||||||
android:label="@string/account_setup_basics_title"
|
android:label="@string/account_setup_basics_title"
|
||||||
|
android:exported="true"
|
||||||
>
|
>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.email.service;
|
package com.android.email.service;
|
||||||
|
|
||||||
|
import com.android.email.activity.setup.AccountSetupBasics;
|
||||||
import com.android.exchange.Eas;
|
import com.android.exchange.Eas;
|
||||||
|
|
||||||
import android.accounts.AbstractAccountAuthenticator;
|
import android.accounts.AbstractAccountAuthenticator;
|
||||||
|
@ -48,14 +49,32 @@ public class EasAuthenticatorService extends Service {
|
||||||
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
|
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
|
||||||
String authTokenType, String[] requiredFeatures, Bundle options)
|
String authTokenType, String[] requiredFeatures, Bundle options)
|
||||||
throws NetworkErrorException {
|
throws NetworkErrorException {
|
||||||
// The Bundle we are passed has username and password set
|
// There are two cases here:
|
||||||
AccountManager.get(EasAuthenticatorService.this).blockingAddAccountExplicitly(
|
// 1) We are called with a username/password; this comes from the traditional email
|
||||||
new Account(options.getString(OPTIONS_USERNAME), Eas.ACCOUNT_MANAGER_TYPE),
|
// app UI; we simply create the account and return the proper bundle
|
||||||
options.getString(OPTIONS_PASSWORD), null);
|
if (options != null && options.containsKey(OPTIONS_PASSWORD)
|
||||||
Bundle b = new Bundle();
|
&& options.containsKey(OPTIONS_USERNAME)) {
|
||||||
b.putString(Constants.ACCOUNT_NAME_KEY, options.getString("username"));
|
AccountManager.get(EasAuthenticatorService.this).blockingAddAccountExplicitly(
|
||||||
b.putString(Constants.ACCOUNT_TYPE_KEY, Eas.ACCOUNT_MANAGER_TYPE);
|
new Account(options.getString(OPTIONS_USERNAME), Eas.ACCOUNT_MANAGER_TYPE),
|
||||||
return b;
|
options.getString(OPTIONS_PASSWORD), null);
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putString(Constants.ACCOUNT_NAME_KEY, options.getString(OPTIONS_USERNAME));
|
||||||
|
b.putString(Constants.ACCOUNT_TYPE_KEY, Eas.ACCOUNT_MANAGER_TYPE);
|
||||||
|
return b;
|
||||||
|
// 2) The other case is that we're creating a new account from an Account manager
|
||||||
|
// activity. In this case, we add an intent that will be used to gather the
|
||||||
|
// account information...
|
||||||
|
} else {
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
Intent intent =
|
||||||
|
new Intent(EasAuthenticatorService.this, AccountSetupBasics.class);
|
||||||
|
// Add extras that indicate this is an Exchange account creation
|
||||||
|
// So we'll skip the "account type" activity, and we'll use the response when
|
||||||
|
// we're done
|
||||||
|
intent.putExtra(Constants.ACCOUNT_AUTHENTICATOR_RESPONSE_KEY, response);
|
||||||
|
b.putParcelable(Constants.INTENT_KEY, intent);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -455,7 +455,8 @@ public class SyncManager extends Service implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
if (INSTANCE != null) {
|
if (INSTANCE != null) {
|
||||||
throw new RuntimeException("\n************ ALREADY RUNNING *************\n");
|
Log.d(TAG, "onCreate called on running SyncManager");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
|
|
||||||
|
@ -480,9 +481,6 @@ public class SyncManager extends Service implements Runnable {
|
||||||
MailboxColumns.TYPE + "=?",
|
MailboxColumns.TYPE + "=?",
|
||||||
new String[] {Long.toString(accountId),
|
new String[] {Long.toString(accountId),
|
||||||
Long.toString(Mailbox.TYPE_EAS_ACCOUNT_MAILBOX)}, null);
|
Long.toString(Mailbox.TYPE_EAS_ACCOUNT_MAILBOX)}, null);
|
||||||
//sCallbackProxy.syncMailboxListStatus(accountId, EmailServiceStatus.IN_PROGRESS, 0);
|
|
||||||
//sCallbackProxy.syncMailboxListStatus(accountId, EmailServiceStatus.SUCCESS, 0);
|
|
||||||
// TODO Remove previous two lines; reimplement what's below (this is bug #2026451)
|
|
||||||
try {
|
try {
|
||||||
if (c.moveToFirst()) {
|
if (c.moveToFirst()) {
|
||||||
synchronized(mSyncToken) {
|
synchronized(mSyncToken) {
|
||||||
|
|
Loading…
Reference in New Issue