Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40047fa1 authored by Fred Quintana's avatar Fred Quintana Committed by Android Git Automerger
Browse files

am 272101b3: Merge "Fix a bug in the account chooser where relaunching an...

am 272101b3: Merge "Fix a bug in the account chooser where relaunching an in-progress flow results in a blank screen." into ics-factoryrom

* commit '272101b3':
  Fix a bug in the account chooser where relaunching an in-progress flow results in a blank screen.
parents 55b039f1 272101b3
Loading
Loading
Loading
Loading
+13 −41
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.widget.ListView;
import android.widget.TextView;
import com.android.internal.R;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -43,7 +42,7 @@ import java.util.Set;
/**
 * @hide
 */
public class ChooseAccountTypeActivity extends Activity implements AccountManagerCallback<Bundle> {
public class ChooseAccountTypeActivity extends Activity {
    private static final String TAG = "AccountManager";

    private HashMap<String, AuthInfo> mTypeToAuthenticatorInfo = new HashMap<String, AuthInfo>();
@@ -52,7 +51,6 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.choose_account_type);

        // Read the validAccountTypes, if present, and add them to the setOfAllowableAccountTypes
        Set<String> setOfAllowableAccountTypes = null;
@@ -90,10 +88,11 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage
        }

        if (mAuthenticatorInfosToDisplay.size() == 1) {
            runAddAccountForAuthenticator(mAuthenticatorInfosToDisplay.get(0));
            setResultAndFinish(mAuthenticatorInfosToDisplay.get(0).desc.type);
            return;
        }

        setContentView(R.layout.choose_account_type);
        // Setup the list
        ListView list = (ListView) findViewById(android.R.id.list);
        // Use an existing ListAdapter that will map an array of strings to TextViews
@@ -103,11 +102,20 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage
        list.setTextFilterEnabled(false);
        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                runAddAccountForAuthenticator(mAuthenticatorInfosToDisplay.get(position));
                setResultAndFinish(mAuthenticatorInfosToDisplay.get(position).desc.type);
            }
        });
    }

    private void setResultAndFinish(final String type) {
        Bundle bundle = new Bundle();
        bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, type);
        setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
        Log.d(TAG, "ChooseAccountTypeActivity.setResultAndFinish: "
                + "selected account type " + type);
        finish();
    }

    private void buildTypeToAuthDescriptionMap() {
        for(AuthenticatorDescription desc : AccountManager.get(this).getAuthenticatorTypes()) {
            String name = null;
@@ -136,42 +144,6 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage
        }
    }

    protected void runAddAccountForAuthenticator(AuthInfo authInfo) {
        Log.d(TAG, "selected account type " + authInfo.name);
        final Bundle options = getIntent().getBundleExtra(
                ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE);
        final String[] requiredFeatures = getIntent().getStringArrayExtra(
                ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY);
        final String authTokenType = getIntent().getStringExtra(
                ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING);
        AccountManager.get(this).addAccount(authInfo.desc.type, authTokenType, requiredFeatures,
                options, this, this, null /* Handler */);
    }

    public void run(final AccountManagerFuture<Bundle> accountManagerFuture) {
        try {
            Bundle accountManagerResult = accountManagerFuture.getResult();
            Bundle bundle = new Bundle();
            bundle.putString(AccountManager.KEY_ACCOUNT_NAME,
                    accountManagerResult.getString(AccountManager.KEY_ACCOUNT_NAME));
            bundle.putString(AccountManager.KEY_ACCOUNT_TYPE,
                    accountManagerResult.getString(AccountManager.KEY_ACCOUNT_TYPE));
            setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
            finish();
            return;
        } catch (OperationCanceledException e) {
            setResult(Activity.RESULT_CANCELED);
            finish();
            return;
        } catch (IOException e) {
        } catch (AuthenticatorException e) {
        }
        Bundle bundle = new Bundle();
        bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "error communicating with server");
        setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
        finish();
    }

    private static class AuthInfo {
        final AuthenticatorDescription desc;
        final String name;
+43 −4
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.widget.ListView;
import android.widget.TextView;
import com.android.internal.R;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -44,7 +45,8 @@ import java.util.Set;
/**
 * @hide
 */
public class ChooseTypeAndAccountActivity extends Activity {
public class ChooseTypeAndAccountActivity extends Activity
        implements AccountManagerCallback<Bundle> {
    private static final String TAG = "AccountManager";

    /**
@@ -211,10 +213,9 @@ public class ChooseTypeAndAccountActivity extends Activity {
    protected void onActivityResult(final int requestCode, final int resultCode,
            final Intent data) {
        if (resultCode == RESULT_OK && data != null) {
            String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            String accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
            if (accountName != null && accountType != null) {
                setResultAndFinish(accountName, accountType);
            if (accountType != null) {
                runAddAccountForAuthenticator(accountType);
                return;
            }
        }
@@ -223,6 +224,43 @@ public class ChooseTypeAndAccountActivity extends Activity {
        finish();
    }

    protected void runAddAccountForAuthenticator(String type) {
        Log.d(TAG, "selected account type " + type);
        final Bundle options = getIntent().getBundleExtra(
                ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE);
        final String[] requiredFeatures = getIntent().getStringArrayExtra(
                ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY);
        final String authTokenType = getIntent().getStringExtra(
                ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING);
        AccountManager.get(this).addAccount(type, authTokenType, requiredFeatures,
                options, this, this, null /* Handler */);
    }

    public void run(final AccountManagerFuture<Bundle> accountManagerFuture) {
        try {
            final Bundle accountManagerResult = accountManagerFuture.getResult();
            final String name = accountManagerResult.getString(AccountManager.KEY_ACCOUNT_NAME);
            final String type = accountManagerResult.getString(AccountManager.KEY_ACCOUNT_TYPE);
            if (name != null && type != null) {
                final Bundle bundle = new Bundle();
                bundle.putString(AccountManager.KEY_ACCOUNT_NAME, name);
                bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, type);
                setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
                finish();
                return;
            }
        } catch (OperationCanceledException e) {
            setResult(Activity.RESULT_CANCELED);
            finish();
            return;
        } catch (IOException e) {
        } catch (AuthenticatorException e) {
        }
        Bundle bundle = new Bundle();
        bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "error communicating with server");
        setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
        finish();
    }

    private Drawable getDrawableForType(
            final HashMap<String, AuthenticatorDescription> typeToAuthDescription,
@@ -266,6 +304,7 @@ public class ChooseTypeAndAccountActivity extends Activity {

    private void startChooseAccountTypeActivity() {
        final Intent intent = new Intent(this, ChooseAccountTypeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        intent.putExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY,
                getIntent().getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY));
        intent.putExtra(EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE,