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

Commit 98e9e855 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Always delete from CE table in removeAccountInternal

Test: AMSTest passes
Bug: 32660831
Change-Id: Iad40bf151f885a86eb6b4e074e9ec83159277e47
parent 655d3dcb
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -2136,14 +2136,17 @@ public class AccountManagerService
            try {
            try {
                accountId = accounts.accountsDb.findDeAccountId(account);
                accountId = accounts.accountsDb.findDeAccountId(account);
                if (accountId >= 0) {
                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) {
                if (userUnlocked) {
                        // Delete from CE table
                    long ceAccountId = accounts.accountsDb.findCeAccountId(account);
                        accounts.accountsDb.deleteCeAccount(accountId);
                    if (ceAccountId >= 0) {
                        accounts.accountsDb.deleteCeAccount(ceAccountId);
                    }
                    }
                    accounts.accountsDb.setTransactionSuccessful();
                    isChanged = true;
                }
                }
                accounts.accountsDb.setTransactionSuccessful();
            } finally {
            } finally {
                accounts.accountsDb.endTransaction();
                accounts.accountsDb.endTransaction();
            }
            }
+1 −1
Original line number Original line Diff line number Diff line
@@ -1201,7 +1201,7 @@ class AccountsDb implements AutoCloseable {
    }
    }


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


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


    @SmallTest
    @SmallTest