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

Commit 37437b7a authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Android (Google) Code Review
Browse files

Merge "Always delete from CE table in removeAccountInternal"

parents 86009287 98e9e855
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -2136,14 +2136,17 @@ public class AccountManagerService
            try {
                accountId = accounts.accountsDb.findDeAccountId(account);
                if (accountId >= 0) {
                    accounts.accountsDb.deleteDeAccount(accountId);
                    isChanged = accounts.accountsDb.deleteDeAccount(accountId);
                }
                // always delete from CE table if CE storage is available
                // DE account could be removed while CE was locked
                if (userUnlocked) {
                        // Delete from CE table
                        accounts.accountsDb.deleteCeAccount(accountId);
                    long ceAccountId = accounts.accountsDb.findCeAccountId(account);
                    if (ceAccountId >= 0) {
                        accounts.accountsDb.deleteCeAccount(ceAccountId);
                    }
                    accounts.accountsDb.setTransactionSuccessful();
                    isChanged = true;
                }
                accounts.accountsDb.setTransactionSuccessful();
            } finally {
                accounts.accountsDb.endTransaction();
            }
+1 −1
Original line number Diff line number Diff line
@@ -1201,7 +1201,7 @@ class AccountsDb implements AutoCloseable {
    }

    boolean deleteCeAccount(long accountId) {
        SQLiteDatabase db = mDeDatabase.getReadableDatabaseUserIsUnlocked();
        SQLiteDatabase db = mDeDatabase.getWritableDatabaseUserIsUnlocked();
        return db.delete(
                CE_TABLE_ACCOUNTS, ACCOUNTS_ID + "=" + accountId, null) > 0;
    }
+2 −2
Original line number Diff line number Diff line
@@ -254,11 +254,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {

        // Unlock the user and verify that db has been updated
        ams2.onUserUnlocked(newIntentForUser(UserHandle.USER_SYSTEM));
        accountsNumber = readNumberOfAccountsFromDbFile(originalContext, ceDatabaseName);
        assertEquals("CE database should now have 1 account", 2, accountsNumber);
        accounts = ams2.getAccounts(UserHandle.USER_SYSTEM, mContext.getOpPackageName());
        assertEquals(1, accounts.length);
        assertEquals("Only a2 should be returned", a2, accounts[0]);
        accountsNumber = readNumberOfAccountsFromDbFile(originalContext, ceDatabaseName);
        assertEquals("CE database should now have 1 account", 1, accountsNumber);
    }

    @SmallTest