diff options
author | Fred Quintana <fredq@google.com> | 2011-10-17 21:04:47 -0700 |
---|---|---|
committer | Fred Quintana <fredq@google.com> | 2011-10-17 21:06:30 -0700 |
commit | 01df6a8ee2fd0ec76bddaaa2e3e66f6e9748a4ce (patch) | |
tree | 3de68def197c5462aa24478b6cb2d8f2d375e117 /core/java/android/accounts | |
parent | 11116b80d88b72e14e4f6b7ad3ab312096f8eea5 (diff) | |
download | frameworks_base-01df6a8ee2fd0ec76bddaaa2e3e66f6e9748a4ce.zip frameworks_base-01df6a8ee2fd0ec76bddaaa2e3e66f6e9748a4ce.tar.gz frameworks_base-01df6a8ee2fd0ec76bddaaa2e3e66f6e9748a4ce.tar.bz2 |
fix bug where the instance saving of the ChooseTypeAndAccountActivity
would only work in the case where onSaveInstanceState was called.
- combined mExistingAccounts and mSavedAccounts into one field
- set this field when starting the addAccount request
- write this to the instance state if the request state
is ADDING_ACCOUNT
- read this field from the instance state, if any,
when the request state is ADDING_ACCOUNT
Bug: 5459669
Change-Id: I5a7b4943de8e706cc8a21ff9f54fce4258f18b19
Diffstat (limited to 'core/java/android/accounts')
-rw-r--r-- | core/java/android/accounts/ChooseTypeAndAccountActivity.java | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/core/java/android/accounts/ChooseTypeAndAccountActivity.java b/core/java/android/accounts/ChooseTypeAndAccountActivity.java index 5f38eb4..c3c9d16 100644 --- a/core/java/android/accounts/ChooseTypeAndAccountActivity.java +++ b/core/java/android/accounts/ChooseTypeAndAccountActivity.java @@ -72,7 +72,7 @@ public class ChooseTypeAndAccountActivity extends Activity * This is passed as the requiredFeatures parameter in AccountManager.addAccount() * if it is called. */ - public static final String EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY = + public static final String EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY = "addAccountRequiredFeatures"; /** @@ -110,7 +110,6 @@ public class ChooseTypeAndAccountActivity extends Activity private ArrayList<AccountInfo> mAccountInfos; private int mPendingRequest = REQUEST_NULL; private Parcelable[] mExistingAccounts = null; - private Parcelable[] mSavedAccounts = null; @Override public void onCreate(Bundle savedInstanceState) { @@ -124,12 +123,10 @@ public class ChooseTypeAndAccountActivity extends Activity if (savedInstanceState != null) { mPendingRequest = savedInstanceState.getInt(KEY_INSTANCE_STATE_PENDING_REQUEST); - mSavedAccounts = + mExistingAccounts = savedInstanceState.getParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS); - mExistingAccounts = null; } else { mPendingRequest = REQUEST_NULL; - mSavedAccounts = null; mExistingAccounts = null; } @@ -246,7 +243,9 @@ public class ChooseTypeAndAccountActivity extends Activity protected void onSaveInstanceState(final Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(KEY_INSTANCE_STATE_PENDING_REQUEST, mPendingRequest); - outState.putParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS, mExistingAccounts); + if (mPendingRequest == REQUEST_ADD_ACCOUNT) { + outState.putParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS, mExistingAccounts); + } } // Called when the choose account type activity (for adding an account) returns. @@ -264,7 +263,6 @@ public class ChooseTypeAndAccountActivity extends Activity // we got our result, so clear the fact that we had a pending request mPendingRequest = REQUEST_NULL; - mExistingAccounts = null; if (resultCode == RESULT_CANCELED) { return; @@ -293,7 +291,7 @@ public class ChooseTypeAndAccountActivity extends Activity if (accountName == null || accountType == null) { Account[] currentAccounts = AccountManager.get(this).getAccounts(); Set<Account> preExistingAccounts = new HashSet<Account>(); - for (Parcelable accountParcel : mSavedAccounts) { + for (Parcelable accountParcel : mExistingAccounts) { preExistingAccounts.add((Account) accountParcel); } for (Account account : currentAccounts) { |