am 552bebe0: am 35bbbc6c: Merge "Launch account addition activity from Settings instead of from AccountManager" into jb-mr1-dev

* commit '552bebe04f221966ab5d002c285e765ef60c664b':
  Launch account addition activity from Settings instead of from AccountManager
This commit is contained in:
Amith Yamasani
2012-10-11 17:11:45 -07:00
committed by Android Git Automerger

View File

@@ -67,18 +67,31 @@ public class AddAccountSettings extends Activity {
static final String EXTRA_HAS_MULTIPLE_USERS = "hasMultipleUsers";
private static final int CHOOSE_ACCOUNT_REQUEST = 1;
private static final int ADD_ACCOUNT_REQUEST = 2;
private PendingIntent mPendingIntent;
private AccountManagerCallback<Bundle> mCallback = new AccountManagerCallback<Bundle>() {
public void run(AccountManagerFuture<Bundle> future) {
boolean done = true;
try {
Bundle bundle = future.getResult();
bundle.keySet();
setResult(RESULT_OK);
if (mPendingIntent != null) {
mPendingIntent.cancel();
//bundle.keySet();
Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
if (intent != null) {
done = false;
Bundle addAccountOptions = new Bundle();
addAccountOptions.putParcelable(KEY_CALLER_IDENTITY, mPendingIntent);
addAccountOptions.putBoolean(EXTRA_HAS_MULTIPLE_USERS,
Utils.hasMultipleUsers(AddAccountSettings.this));
intent.putExtras(addAccountOptions);
startActivityForResult(intent, ADD_ACCOUNT_REQUEST);
} else {
setResult(RESULT_OK);
if (mPendingIntent != null) {
mPendingIntent.cancel();
mPendingIntent = null;
}
}
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "account added: " + bundle);
@@ -89,7 +102,9 @@ public class AddAccountSettings extends Activity {
} catch (AuthenticatorException e) {
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "addAccount failed: " + e);
} finally {
finish();
if (done) {
finish();
}
}
}
};
@@ -136,6 +151,14 @@ public class AddAccountSettings extends Activity {
// Go to account setup screen. finish() is called inside mCallback.
addAccount(data.getStringExtra(EXTRA_SELECTED_ACCOUNT));
break;
case ADD_ACCOUNT_REQUEST:
setResult(resultCode);
if (mPendingIntent != null) {
mPendingIntent.cancel();
mPendingIntent = null;
}
finish();
break;
}
}
@@ -155,7 +178,7 @@ public class AddAccountSettings extends Activity {
null, /* authTokenType */
null, /* requiredFeatures */
addAccountOptions,
this,
null,
mCallback,
null /* handler */);
mAddAccountCalled = true;