Use AccountAuthenticatorResponse properly.
Current implementation ignores callbacks coming from AccountManager, which should be called everytime when this Activity finishes its job. Bug: 3069222 Change-Id: Iea03cf94bdfe8da184e415bf7e759ddeb46ecdd9
This commit is contained in:
parent
02a750dd64
commit
9dac94975f
@ -23,6 +23,8 @@ import com.android.email.activity.Welcome;
|
|||||||
import com.android.email.provider.EmailContent.Account;
|
import com.android.email.provider.EmailContent.Account;
|
||||||
import com.android.email.provider.EmailContent.HostAuth;
|
import com.android.email.provider.EmailContent.HostAuth;
|
||||||
|
|
||||||
|
import android.accounts.AccountAuthenticatorResponse;
|
||||||
|
import android.accounts.AccountManager;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -48,6 +50,12 @@ public class AccountSetupBasics extends AccountSetupActivity
|
|||||||
private boolean mManualButtonDisplayed;
|
private boolean mManualButtonDisplayed;
|
||||||
private boolean mNextButtonEnabled;
|
private boolean mNextButtonEnabled;
|
||||||
|
|
||||||
|
// Used when this Activity is called as part of account authentification flow,
|
||||||
|
// which requires to do extra work before and after the account creation.
|
||||||
|
// See also AccountAuthenticatorActivity.
|
||||||
|
private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null;
|
||||||
|
private Bundle mResultBundle = null;
|
||||||
|
|
||||||
public static void actionNewAccount(Activity fromActivity) {
|
public static void actionNewAccount(Activity fromActivity) {
|
||||||
SetupData.init(SetupData.FLOW_MODE_NORMAL);
|
SetupData.init(SetupData.FLOW_MODE_NORMAL);
|
||||||
fromActivity.startActivity(new Intent(fromActivity, AccountSetupBasics.class));
|
fromActivity.startActivity(new Intent(fromActivity, AccountSetupBasics.class));
|
||||||
@ -132,6 +140,13 @@ public class AccountSetupBasics extends AccountSetupActivity
|
|||||||
|
|
||||||
// Configure fragment
|
// Configure fragment
|
||||||
mFragment.setCallback(this, alternateStrings);
|
mFragment.setCallback(this, alternateStrings);
|
||||||
|
|
||||||
|
mAccountAuthenticatorResponse =
|
||||||
|
getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
|
||||||
|
|
||||||
|
if (mAccountAuthenticatorResponse != null) {
|
||||||
|
mAccountAuthenticatorResponse.onRequestContinued();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -248,4 +263,19 @@ public class AccountSetupBasics extends AccountSetupActivity
|
|||||||
SetupData.setAllowAutodiscover(allowAutoDiscover);
|
SetupData.setAllowAutodiscover(allowAutoDiscover);
|
||||||
AccountSetupAccountType.actionSelectAccountType(this);
|
AccountSetupAccountType.actionSelectAccountType(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
if (mAccountAuthenticatorResponse != null) {
|
||||||
|
// send the result bundle back if set, otherwise send an error.
|
||||||
|
if (mResultBundle != null) {
|
||||||
|
mAccountAuthenticatorResponse.onResult(mResultBundle);
|
||||||
|
} else {
|
||||||
|
mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED,
|
||||||
|
"canceled");
|
||||||
|
}
|
||||||
|
mAccountAuthenticatorResponse = null;
|
||||||
|
}
|
||||||
|
super.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user