Skip to content

Commit b483a99

Browse files
author
Amith Yamasani
committed
Preserve account list in order of creation in the database.
This makes it possible to retrieve the account list in the order of creation, if we want to display them in the account settings screen in that order. Bug: 6579937 Change-Id: I2025aaa8b770fbb78be978dfde64ef95823fd5aa
1 parent 5ab6e12 commit b483a99

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/java/android/accounts/AccountManagerService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ static class UserAccounts {
163163
new HashMap<Account, Integer>();
164164
private final Object cacheLock = new Object();
165165
/** protected by the {@link #cacheLock} */
166-
private final HashMap<String, Account[]> accountCache = new HashMap<String, Account[]>();
166+
private final HashMap<String, Account[]> accountCache =
167+
new LinkedHashMap<String, Account[]>();
167168
/** protected by the {@link #cacheLock} */
168169
private HashMap<Account, HashMap<String, String>> userDataCache =
169170
new HashMap<Account, HashMap<String, String>>();
@@ -296,7 +297,7 @@ private void validateAccountsAndPopulateCache(UserAccounts accounts) {
296297
try {
297298
accounts.accountCache.clear();
298299
final HashMap<String, ArrayList<String>> accountNamesByType =
299-
new HashMap<String, ArrayList<String>>();
300+
new LinkedHashMap<String, ArrayList<String>>();
300301
while (cursor.moveToNext()) {
301302
final long accountId = cursor.getLong(0);
302303
final String accountType = cursor.getString(1);

0 commit comments

Comments
 (0)