use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class AccountManagerService method updateLastAuthenticatedTime.
private boolean updateLastAuthenticatedTime(Account account) {
final UserAccounts accounts = getUserAccountsForCaller();
synchronized (accounts.cacheLock) {
final ContentValues values = new ContentValues();
values.put(ACCOUNTS_LAST_AUTHENTICATE_TIME_EPOCH_MILLIS, System.currentTimeMillis());
final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
int i = db.update(TABLE_ACCOUNTS, values, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE + "=?", new String[] { account.name, account.type });
if (i > 0) {
return true;
}
}
return false;
}
use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class AccountManagerService method addSharedAccountAsUser.
private boolean addSharedAccountAsUser(Account account, int userId) {
userId = handleIncomingUser(userId);
UserAccounts accounts = getUserAccounts(userId);
SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(ACCOUNTS_NAME, account.name);
values.put(ACCOUNTS_TYPE, account.type);
db.delete(TABLE_SHARED_ACCOUNTS, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE + "=?", new String[] { account.name, account.type });
long accountId = db.insert(TABLE_SHARED_ACCOUNTS, ACCOUNTS_NAME, values);
if (accountId < 0) {
Log.w(TAG, "insertAccountIntoDatabase: " + account + ", skipping the DB insert failed");
return false;
}
logRecord(db, DebugDbHelper.ACTION_ACCOUNT_ADD, TABLE_SHARED_ACCOUNTS, accountId, accounts);
return true;
}
use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class AccountManagerService method revokeAppPermission.
/**
* Don't allow callers with the given uid permission to get credentials for
* account/authTokenType.
* <p>
* Although this is public it can only be accessed via the AccountManagerService object
* which is in the system. This means we don't need to protect it with permissions.
* @hide
*/
private void revokeAppPermission(Account account, String authTokenType, int uid) {
if (account == null || authTokenType == null) {
Log.e(TAG, "revokeAppPermission: called with invalid arguments", new Exception());
return;
}
UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid));
synchronized (accounts.cacheLock) {
final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
db.beginTransaction();
try {
long accountId = getAccountIdLocked(db, account);
if (accountId >= 0) {
db.delete(TABLE_GRANTS, GRANTS_ACCOUNTS_ID + "=? AND " + GRANTS_AUTH_TOKEN_TYPE + "=? AND " + GRANTS_GRANTEE_UID + "=?", new String[] { String.valueOf(accountId), authTokenType, String.valueOf(uid) });
db.setTransactionSuccessful();
}
} finally {
db.endTransaction();
}
cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), new UserHandle(accounts.userId));
}
// Listeners are a final CopyOnWriteArrayList, hence no lock needed.
for (AccountManagerInternal.OnAppPermissionChangeListener listener : mAppPermissionChangeListeners) {
mMessageHandler.post(() -> listener.onAppPermissionChanged(account, uid));
}
}
use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class AccountManagerService method syncDeCeAccountsLocked.
private void syncDeCeAccountsLocked(UserAccounts accounts) {
Preconditions.checkState(Thread.holdsLock(mUsers), "mUsers lock must be held");
final SQLiteDatabase db = accounts.openHelper.getReadableDatabaseUserIsUnlocked();
List<Account> accountsToRemove = CeDatabaseHelper.findCeAccountsNotInDe(db);
if (!accountsToRemove.isEmpty()) {
Slog.i(TAG, "Accounts " + accountsToRemove + " were previously deleted while user " + accounts.userId + " was locked. Removing accounts from CE tables");
logRecord(accounts, DebugDbHelper.ACTION_SYNC_DE_CE_ACCOUNTS, TABLE_ACCOUNTS);
for (Account account : accountsToRemove) {
removeAccountInternal(accounts, account, Process.myUid());
}
}
}
use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.
the class AccountManagerService method invalidateAuthToken.
@Override
public void invalidateAuthToken(String accountType, String authToken) {
int callerUid = Binder.getCallingUid();
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "invalidateAuthToken: accountType " + accountType + ", caller's uid " + callerUid + ", pid " + Binder.getCallingPid());
}
if (accountType == null)
throw new IllegalArgumentException("accountType is null");
if (authToken == null)
throw new IllegalArgumentException("authToken is null");
int userId = UserHandle.getCallingUserId();
long identityToken = clearCallingIdentity();
try {
UserAccounts accounts = getUserAccounts(userId);
synchronized (accounts.cacheLock) {
final SQLiteDatabase db = accounts.openHelper.getWritableDatabaseUserIsUnlocked();
db.beginTransaction();
try {
invalidateAuthTokenLocked(accounts, db, accountType, authToken);
invalidateCustomTokenLocked(accounts, accountType, authToken);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
} finally {
restoreCallingIdentity(identityToken);
}
}
Aggregations