Skip protocol choice if user entered from system account manager
b/13475223 Change-Id: Id1ec6259e2b3880f9ce83ffe7795c40aa069466e
This commit is contained in:
parent
282edb95a3
commit
53b64eee54
@ -249,6 +249,8 @@ public class AccountSetupFinal extends AccountSetupActivity
|
||||
SetupDataFragment.FLOW_MODE_UNSPECIFIED);
|
||||
// TODO: do something with this
|
||||
final String flowAccountType = intent.getStringExtra(EXTRA_FLOW_ACCOUNT_TYPE);
|
||||
mSetupData.setAmProtocol(
|
||||
EmailServiceUtils.getProtocolFromAccountType(this, flowAccountType));
|
||||
mSetupData.setFlowMode(intentFlowMode);
|
||||
}
|
||||
|
||||
@ -574,9 +576,18 @@ public class AccountSetupFinal extends AccountSetupActivity
|
||||
} else {
|
||||
mSkipAutoDiscover = false;
|
||||
if (mIsPreConfiguredProvider) {
|
||||
// TODO: check for mismatch between providers.xml and amProtocol
|
||||
mState = STATE_CREDENTIALS;
|
||||
} else {
|
||||
mState = STATE_TYPE;
|
||||
final String amProtocol = mSetupData.getAmProtocol();
|
||||
if (!TextUtils.isEmpty(amProtocol)) {
|
||||
mSetupData.setIncomingProtocol(this, amProtocol);
|
||||
final Account account = mSetupData.getAccount();
|
||||
setDefaultsForProtocol(account);
|
||||
mState = STATE_CREDENTIALS;
|
||||
} else {
|
||||
mState = STATE_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
updateHeadline();
|
||||
|
@ -46,6 +46,7 @@ public class SetupDataFragment extends Fragment implements Parcelable {
|
||||
private static final String SAVESTATE_OUTGOING_LOADED = "SetupDataFragment.outgoingLoaded";
|
||||
private static final String SAVESTATE_POLICY = "SetupDataFragment.policy";
|
||||
private static final String SAVESTATE_INCOMING_PROTOCOL = "SetupDataFragment.incomingProtocol";
|
||||
private static final String SAVESTATE_AM_PROTOCOL = "SetupDataFragment.amProtocol";
|
||||
|
||||
// All access will be through getters/setters
|
||||
private int mFlowMode = FLOW_MODE_NORMAL;
|
||||
@ -61,6 +62,8 @@ public class SetupDataFragment extends Fragment implements Parcelable {
|
||||
// Cache incoming protocol and service info here
|
||||
private EmailServiceUtils.EmailServiceInfo mIncomingServiceInfo;
|
||||
private String mIncomingProtocol;
|
||||
// Protocol the user chose in the account manager "Add an account" screen
|
||||
private String mAmProtocol;
|
||||
|
||||
public interface SetupDataContainer {
|
||||
public SetupDataFragment getSetupData();
|
||||
@ -94,6 +97,7 @@ public class SetupDataFragment extends Fragment implements Parcelable {
|
||||
outState.putBoolean(SAVESTATE_OUTGOING_LOADED, mOutgoingCredLoaded);
|
||||
outState.putParcelable(SAVESTATE_POLICY, mPolicy);
|
||||
outState.putString(SAVESTATE_INCOMING_PROTOCOL, mIncomingProtocol);
|
||||
outState.putString(SAVESTATE_AM_PROTOCOL, mAmProtocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,6 +112,7 @@ public class SetupDataFragment extends Fragment implements Parcelable {
|
||||
mOutgoingCredLoaded = savedInstanceState.getBoolean(SAVESTATE_OUTGOING_LOADED);
|
||||
mPolicy = savedInstanceState.getParcelable(SAVESTATE_POLICY);
|
||||
mIncomingProtocol = savedInstanceState.getString(SAVESTATE_INCOMING_PROTOCOL);
|
||||
mAmProtocol = savedInstanceState.getString(SAVESTATE_AM_PROTOCOL);
|
||||
}
|
||||
setRetainInstance(true);
|
||||
}
|
||||
@ -224,6 +229,14 @@ public class SetupDataFragment extends Fragment implements Parcelable {
|
||||
return recvAuth.mClientCertAlias;
|
||||
}
|
||||
|
||||
public String getAmProtocol() {
|
||||
return mAmProtocol;
|
||||
}
|
||||
|
||||
public void setAmProtocol(String amProtocol) {
|
||||
mAmProtocol = amProtocol;
|
||||
}
|
||||
|
||||
// Parcelable methods
|
||||
@Override
|
||||
public int describeContents() {
|
||||
|
@ -44,6 +44,7 @@ import android.provider.CalendarContract.SyncState;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.ContactsContract.RawContacts;
|
||||
import android.provider.SyncStateContract;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.email.R;
|
||||
import com.android.emailcommon.Api;
|
||||
@ -616,6 +617,28 @@ public class EmailServiceUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a service name into a protocol name, or null if ambiguous
|
||||
* @param context for loading service map
|
||||
* @param accountType sync adapter service name
|
||||
* @return protocol name or null
|
||||
*/
|
||||
public static String getProtocolFromAccountType(final Context context,
|
||||
final String accountType) {
|
||||
final Map <String, EmailServiceInfo> serviceInfoMap = getServiceMap(context);
|
||||
String protocol = null;
|
||||
for (final EmailServiceInfo info : serviceInfoMap.values()) {
|
||||
if (TextUtils.equals(accountType, info.accountType)) {
|
||||
if (!TextUtils.isEmpty(protocol) && !TextUtils.equals(protocol, info.protocol)) {
|
||||
// More than one protocol matches
|
||||
return null;
|
||||
}
|
||||
protocol = info.protocol;
|
||||
}
|
||||
}
|
||||
return protocol;
|
||||
}
|
||||
|
||||
private static Uri asCalendarSyncAdapter(Uri uri, String account, String accountType) {
|
||||
return uri.buildUpon().appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
|
||||
.appendQueryParameter(Calendars.ACCOUNT_NAME, account)
|
||||
|
Loading…
Reference in New Issue
Block a user