Home | History | Annotate | Download | only in accounts

Lines Matching refs:accounts

17 package com.android.server.accounts;
20 import android.accounts.AbstractAccountAuthenticator;
21 import android.accounts.Account;
22 import android.accounts.AccountAndUser;
23 import android.accounts.AccountAuthenticatorResponse;
24 import android.accounts.AccountManager;
25 import android.accounts.AuthenticatorDescription;
26 import android.accounts.CantAddAccountActivity;
27 import android.accounts.GrantCredentialsPermissionActivity;
28 import android.accounts.IAccountAuthenticator;
29 import android.accounts.IAccountAuthenticatorResponse;
30 import android.accounts.IAccountManager;
31 import android.accounts.IAccountManagerResponse;
107 * accounts on the device. Some of these calls are implemented with the help of the corresponding
118 private static final String DATABASE_NAME = "accounts.db";
137 private static final String TABLE_ACCOUNTS = "accounts";
187 AUTHTOKENS_ACCOUNTS_ID + "=(select _id FROM accounts WHERE name=? AND type=?)";
193 EXTRAS_ACCOUNTS_ID + "=(select _id FROM accounts WHERE name=? AND type=?)";
227 * want to know if the accounts they care about have been renamed.
230 * we can distinguish between those accounts with no previous names and
286 // Don't delete accounts when updating a authenticator's
351 * Validate internal set of accounts against installed authenticators for
355 final UserAccounts accounts = getUserAccounts(userId);
359 validateAccountsInternal(accounts, true /* invalidateAuthenticatorCache */);
363 * Validate internal set of accounts against installed authenticators for
367 UserAccounts accounts, boolean invalidateAuthenticatorCache) {
369 mAuthenticatorCache.invalidateCache(accounts.userId);
374 mAuthenticatorCache.getAllServices(accounts.userId)) {
378 synchronized (accounts.cacheLock) {
379 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
385 accounts.accountCache.clear();
400 accountId, accounts);
403 accounts.userDataCache.remove(account);
404 accounts.authTokenCache.remove(account);
405 accounts.accountTokenCaches.remove(account);
425 accounts.accountCache.put(accountType, accountsForType);
430 sendAccountsChangedBroadcast(accounts.userId);
442 UserAccounts accounts = mUsers.get(userId);
443 if (accounts == null) {
444 accounts = new UserAccounts(mContext, userId);
446 accounts.openHelper.getWritableDatabase(), accounts);
447 mUsers.append(userId, accounts);
448 purgeOldGrants(accounts);
449 validateAccountsInternal(accounts, true /* invalidateAuthenticatorCache */);
451 return accounts;
463 private void purgeOldGrants(UserAccounts accounts) {
464 synchronized (accounts.cacheLock) {
465 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
491 UserAccounts accounts;
493 accounts = mUsers.get(userId);
496 if (accounts == null) {
502 synchronized (accounts.cacheLock) {
503 accounts.openHelper.close();
516 Account[] accounts = getAccountsAsUser(null, userId, mContext.getOpPackageName());
518 if (ArrayUtils.contains(accounts, sa)) continue;
541 "uid %s cannot get secrets for accounts of type: %s",
548 UserAccounts accounts = getUserAccounts(userId);
549 return readPasswordInternal(accounts, account);
555 private String readPasswordInternal(UserAccounts accounts, Account account) {
560 synchronized (accounts.cacheLock) {
561 final SQLiteDatabase db = accounts.openHelper.getReadableDatabase();
587 UserAccounts accounts = getUserAccounts(userId);
588 return readPreviousNameInternal(accounts, account);
594 private String readPreviousNameInternal(UserAccounts accounts, Account account) {
598 synchronized (accounts.cacheLock) {
599 AtomicReference<String> previousNameRef = accounts.previousNameCache.get(account);
601 final SQLiteDatabase db = accounts.openHelper.getReadableDatabase();
614 accounts.previousNameCache.put(account, previousNameRef);
641 "uid %s cannot get user data for accounts of type: %s",
648 UserAccounts accounts = getUserAccounts(userId);
649 return readUserDataInternal(accounts, account, key);
664 // Only allow the system process to read accounts of other users
721 "uid %s cannot explicitly add accounts of type: %s",
727 * Child users are not allowed to add accounts. Only the accounts that are
730 * TODO: Only allow accounts that were shared to be added by
737 UserAccounts accounts = getUserAccounts(userId);
738 return addAccountInternal(accounts, account, password, extras, false, callingUid);
817 "uid %s cannot notify authentication for accounts of type: %s",
829 UserAccounts accounts = getUserAccounts(userId);
837 final UserAccounts accounts = getUserAccountsForCaller();
838 synchronized (accounts.cacheLock) {
841 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
906 private boolean addAccountInternal(UserAccounts accounts, Account account, String password,
911 synchronized (accounts.cacheLock) {
912 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
948 accounts, callingUid);
950 insertAccountIntoCacheLocked(accounts, account);
954 sendAccountsChangedBroadcast(accounts.userId);
956 if (accounts.userId == UserHandle.USER_OWNER) {
963 * Adds the account to all limited users as shared accounts. If the user is currently
1013 UserAccounts accounts = getUserAccounts(userId);
1014 new TestFeaturesSession(accounts, response, account, features).bind();
1024 public TestFeaturesSession(UserAccounts accounts, IAccountManagerResponse response,
1026 super(accounts, response, account.type, false /* expectActivityLaunch */,
1089 "uid %s cannot rename accounts of type: %s",
1096 UserAccounts accounts = getUserAccounts(userId);
1097 Account resultingAccount = renameAccountInternal(accounts, accountToRename, newName);
1112 UserAccounts accounts, Account accountToRename, String newName) {
1124 getSigninRequiredNotificationId(accounts, accountToRename),
1125 new UserHandle(accounts.userId));
1126 synchronized(accounts.credentialsPermissionNotificationIds) {
1128 accounts.credentialsPermissionNotificationIds.keySet()) {
1130 int id = accounts.credentialsPermissionNotificationIds.get(pair);
1131 cancelNotification(id, new UserHandle(accounts.userId));
1135 synchronized (accounts.cacheLock) {
1136 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
1151 accounts);
1160 insertAccountIntoCacheLocked(accounts, renamedAccount);
1166 HashMap<String, String> tmpData = accounts.userDataCache.get(accountToRename);
1167 HashMap<String, String> tmpTokens = accounts.authTokenCache.get(accountToRename);
1168 removeAccountFromCacheLocked(accounts, accountToRename);
1173 accounts.userDataCache.put(renamedAccount, tmpData);
1174 accounts.authTokenCache.put(renamedAccount, tmpTokens);
1175 accounts.previousNameCache.put(
1180 if (accounts.userId == UserHandle.USER_OWNER) {
1192 sendAccountsChangedBroadcast(accounts.userId);
1222 // Only allow the system process to modify accounts of other users
1231 * Only the system or authenticator should be allowed to remove accounts for that
1232 * authenticator. This will let users remove accounts (via Settings in the system) but not
1239 "uid %s cannot remove accounts of type: %s",
1247 "User cannot modify accounts");
1255 "User cannot modify accounts of this type (policy).");
1261 UserAccounts accounts = getUserAccounts(userId);
1262 cancelNotification(getSigninRequiredNotificationId(accounts, account), user);
1263 synchronized(accounts.credentialsPermissionNotificationIds) {
1265 accounts.credentialsPermissionNotificationIds.keySet()) {
1267 int id = accounts.credentialsPermissionNotificationIds.get(pair);
1273 logRecord(accounts, DebugDbHelper.ACTION_CALLED_ACCOUNT_REMOVE, TABLE_ACCOUNTS);
1276 new RemoveAccountSession(accounts, response, account, expectActivityLaunch).bind();
1293 * Null accounts should result in returning false, as per
1300 "uid %s cannot explicitly add accounts of type: %s",
1305 UserAccounts accounts = getUserAccountsForCaller();
1309 logRecord(accounts, DebugDbHelper.ACTION_CALLED_ACCOUNT_REMOVE, TABLE_ACCOUNTS);
1312 return removeAccountInternal(accounts, account);
1320 public RemoveAccountSession(UserAccounts accounts, IAccountManagerResponse response,
1322 super(accounts, response, account.type, expectActivityLaunch,
1371 private boolean removeAccountInternal(UserAccounts accounts, Account account) {
1373 synchronized (accounts.cacheLock) {
1374 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
1379 removeAccountFromCacheLocked(accounts, account);
1380 sendAccountsChangedBroadcast(accounts.userId);
1382 logRecord(db, DebugDbHelper.ACTION_ACCOUNT_REMOVE, TABLE_ACCOUNTS, accountId, accounts);
1384 if (accounts.userId == UserHandle.USER_OWNER) {
1416 UserAccounts accounts = getUserAccounts(userId);
1417 synchronized (accounts.cacheLock) {
1418 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
1421 invalidateAuthTokenLocked(accounts, db, accountType, authToken);
1422 invalidateCustomTokenLocked(accounts, accountType, authToken);
1434 UserAccounts accounts,
1441 accounts.accountTokenCaches.remove(accountType, authToken);
1444 private void invalidateAuthTokenLocked(UserAccounts accounts, SQLiteDatabase db,
1467 accounts,
1479 UserAccounts accounts,
1490 cancelNotification(getSigninRequiredNotificationId(accounts, account),
1491 new UserHandle(accounts.userId));
1492 synchronized (accounts.cacheLock) {
1493 accounts.accountTokenCaches.put(
1498 private boolean saveAuthTokenToDatabase(UserAccounts accounts, Account account, String type,
1503 cancelNotification(getSigninRequiredNotificationId(accounts, account),
1504 new UserHandle(accounts.userId));
1505 synchronized (accounts.cacheLock) {
1506 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
1522 writeAuthTokenIntoCacheLocked(accounts, db, account, type, authToken);
1546 "uid %s cannot peek the authtokens associated with accounts of type: %s",
1553 UserAccounts accounts = getUserAccounts(userId);
1554 return readAuthTokenInternal(accounts, account, authTokenType);
1574 "uid %s cannot set auth tokens associated with accounts of type: %s",
1581 UserAccounts accounts = getUserAccounts(userId);
1582 saveAuthTokenToDatabase(accounts, account, authTokenType, authToken);
1600 "uid %s cannot set secrets for accounts of type: %s",
1607 UserAccounts accounts = getUserAccounts(userId);
1608 setPasswordInternal(accounts, account, password, callingUid);
1614 private void setPasswordInternal(UserAccounts accounts, Account account, String password,
1619 synchronized (accounts.cacheLock) {
1620 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
1630 accounts.authTokenCache.remove(account);
1631 accounts.accountTokenCaches.remove(account);
1637 logRecord(db, action, TABLE_ACCOUNTS, accountId, accounts, callingUid);
1642 sendAccountsChangedBroadcast(accounts.userId);
1647 Log.i(TAG, "the accounts changed, sending broadcast of "
1664 "uid %s cannot clear passwords for accounts of type: %s",
1671 UserAccounts accounts = getUserAccounts(userId);
1672 setPasswordInternal(accounts, account, null, callingUid);
1692 "uid %s cannot set user data for accounts of type: %s",
1699 UserAccounts accounts = getUserAccounts(userId);
1700 setUserdataInternal(accounts, account, key, value);
1706 private void setUserdataInternal(UserAccounts accounts, Account account, String key,
1711 synchronized (accounts.cacheLock) {
1712 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
1733 writeUserDataIntoCacheLocked(accounts, db, account, key, value);
1775 UserAccounts accounts = getUserAccounts(userId);
1776 new Session(accounts, response, accountType, false /* expectActivityLaunch */,
1844 final UserAccounts accounts;
1847 accounts = getUserAccounts(userId);
1849 AuthenticatorDescription.newKey(account.type), accounts.userId);
1895 String authToken = readAuthTokenInternal(accounts, account, authTokenType);
1913 accounts,
1931 new Session(accounts, response, account.type, expectActivityLaunch,
2005 intent, accounts.userId);
2089 UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid));
2090 synchronized (accounts.credentialsPermissionNotificationIds) {
2094 id = accounts.credentialsPermissionNotificationIds.get(key);
2097 accounts.credentialsPermissionNotificationIds.put(key, id);
2103 private Integer getSigninRequiredNotificationId(UserAccounts accounts, Account account) {
2105 synchronized (accounts.signinRequiredNotificationIds) {
2106 id = accounts.signinRequiredNotificationIds.get(account);
2109 accounts.signinRequiredNotificationIds.put(account, id);
2131 // Is user disallowed from modifying accounts?
2145 "User cannot modify accounts of this type (policy).");
2162 UserAccounts accounts = getUserAccounts(usrId);
2164 accounts, DebugDbHelper.ACTION_CALLED_ACCOUNT_ADD, TABLE_ACCOUNTS, uid);
2165 new Session(accounts, response, accountType, expectActivityLaunch,
2206 // Only allow the system process to add accounts of other users
2215 // Is user disallowed from modifying accounts?
2228 "User cannot modify accounts of this type (policy).");
2244 UserAccounts accounts = getUserAccounts(userId);
2246 accounts, DebugDbHelper.ACTION_CALLED_ACCOUNT_ADD, TABLE_ACCOUNTS, userId);
2247 new Session(accounts, response, accountType, expectActivityLaunch,
2298 // Only allow the system process to read accounts of other users
2310 UserAccounts accounts = getUserAccounts(userId);
2311 new Session(accounts, response, account.type, expectActivityLaunch,
2347 UserAccounts accounts = getUserAccounts(userId);
2348 new Session(accounts, response, account.type, expectActivityLaunch,
2392 UserAccounts accounts = getUserAccounts(userId);
2393 new Session(accounts, response, accountType, expectActivityLaunch,
2418 public GetAccountsByTypeAndFeatureSession(UserAccounts accounts,
2420 super(accounts, response, type, false /* expectActivityLaunch */,
2483 Account[] accounts = new Account[mAccountsWithFeatures.size()];
2484 for (int i = 0; i < accounts.length; i++) {
2485 accounts[i] = mAccountsWithFeatures.get(i);
2492 result.putParcelableArray(AccountManager.KEY_ACCOUNTS, accounts);
2512 * Returns the accounts visible to the client within the context of a specific user
2524 UserAccounts accounts = getUserAccounts(userId);
2526 accounts,
2536 * Returns accounts for all running users.
2567 Account[] accounts = getAccountsFromCacheLocked(userAccounts, null,
2569 for (int a = 0; a < accounts.length; a++) {
2570 runningAccounts.add(new AccountAndUser(accounts[a], userId));
2591 // Only allow the system process to read accounts of other users
2622 } // else aggregate all the visible accounts (it won't matter if the
2627 UserAccounts accounts = getUserAccounts(userId);
2629 accounts,
2663 UserAccounts accounts = getUserAccounts(userId);
2664 SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
2676 logRecord(db, DebugDbHelper.ACTION_ACCOUNT_ADD, TABLE_SHARED_ACCOUNTS, accountId, accounts);
2683 UserAccounts accounts = getUserAccounts(userId);
2684 SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
2697 sharedTableAccountId, accounts, callingUid);
2699 renameAccountInternal(accounts, account, newName);
2711 UserAccounts accounts = getUserAccounts(userId);
2712 SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
2718 sharedTableAccountId, accounts, callingUid);
2719 removeAccountInternal(accounts, account);
2727 UserAccounts accounts = getUserAccounts(userId);
2731 cursor = accounts.openHelper.getReadableDatabase()
2805 // Need to return just the accounts that are from matching signatures.
2818 Account[] accounts;
2820 accounts = getAccountsFromCacheLocked(userAccounts, type, callingUid, null);
2823 result.putParcelableArray(AccountManager.KEY_ACCOUNTS, accounts);
2902 public Session(UserAccounts accounts, IAccountManagerResponse response, String accountType,
2905 this(accounts, response, accountType, expectActivityLaunch, stripAuthTokenFromResult,
2909 public Session(UserAccounts accounts, IAccountManagerResponse response, String accountType,
2915 mAccounts = accounts;
3320 private void logRecord(UserAccounts accounts, String action, String tableName) {
3321 SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
3322 logRecord(db, action, tableName, -1, accounts);
3325 private void logRecordWithUid(UserAccounts accounts, String action, String tableName, int uid) {
3326 SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
3327 logRecord(db, action, tableName, -1, accounts, uid);
3610 Account[] accounts = getAccountsFromCacheLocked(userAccounts, null /* type */,
3612 fout.println("Accounts: " + accounts.length);
3613 for (Account account : accounts) {
3622 fout.println("Accounts History");
3649 private void doNotification(UserAccounts accounts, Account account, CharSequence message,
3662 final Integer notificationId = getSigninRequiredNotificationId(accounts, account);
3838 UserAccounts accounts = getUserAccountsForCaller();
3839 synchronized (accounts.cacheLock) {
3840 final SQLiteDatabase db = accounts.openHelper.getReadableDatabase();
3892 "caller uid %s cannot access %s accounts",
3951 UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid));
3952 synchronized (accounts.cacheLock) {
3953 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
3969 new UserHandle(accounts.userId));
3986 UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid));
3987 synchronized (accounts.cacheLock) {
3988 final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
4004 new UserHandle(accounts.userId));
4012 private void removeAccountFromCacheLocked(UserAccounts accounts, Account account) {
4013 final Account[] oldAccountsForType = accounts.accountCache.get(account.type);
4022 accounts.accountCache.remove(account.type);
4026 accounts.accountCache.put(account.type, newAccountsForType);
4029 accounts.userDataCache.remove(account);
4030 accounts.authTokenCache.remove(account);
4031 accounts.previousNameCache.remove(account);
4037 private void insertAccountIntoCacheLocked(UserAccounts accounts, Account account) {
4038 Account[] accountsForType = accounts.accountCache.get(account.type);
4045 accounts.accountCache.put(account.type, newAccountsForType);
4058 // otherwise return non-shared accounts only.
4073 // opted in to see restricted accounts.
4116 * packageName can be null. If not null, it should be used to filter out restricted accounts
4122 final Account[] accounts = userAccounts.accountCache.get(accountType);
4123 if (accounts == null) {
4126 return filterSharedAccounts(userAccounts, Arrays.copyOf(accounts, accounts.length),
4131 for (Account[] accounts : userAccounts.accountCache.values()) {
4132 totalLength += accounts.length;
4137 Account[] accounts = new Account[totalLength];
4140 System.arraycopy(accountsOfType, 0, accounts, totalLength,
4144 return filterSharedAccounts(userAccounts, accounts, callingUid, callingPackage);
4148 protected void writeUserDataIntoCacheLocked(UserAccounts accounts, final SQLiteDatabase db,
4150 HashMap<String, String> userDataForAccount = accounts.userDataCache.get(account);
4153 accounts.userDataCache.put(account, userDataForAccount);
4163 UserAccounts accounts,
4168 synchronized (accounts.cacheLock) {
4169 return accounts.accountTokenCaches.get(
4174 protected void writeAuthTokenIntoCacheLocked(UserAccounts accounts, final SQLiteDatabase db,
4176 HashMap<String, String> authTokensForAccount = accounts.authTokenCache.get(account);
4179 accounts.authTokenCache.put(account, authTokensForAccount);
4188 protected String readAuthTokenInternal(UserAccounts accounts, Account account,
4190 synchronized (accounts.cacheLock) {
4191 HashMap<String, String> authTokensForAccount = accounts.authTokenCache.get(account);
4194 final SQLiteDatabase db = accounts.openHelper.getReadableDatabase();
4196 accounts.authTokenCache.put(account, authTokensForAccount);
4202 protected String readUserDataInternal(UserAccounts accounts, Account account, String key) {
4203 synchronized (accounts.cacheLock) {
4204 HashMap<String, String> userDataForAccount = accounts.userDataCache.get(account);
4207 final SQLiteDatabase db = accounts.openHelper.getReadableDatabase();
4209 accounts.userDataCache.put(account, userDataForAccount);