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

Commit 8cd927d8 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Introduced additional lock - dbLock

Right now it is always used with cacheLock. In the future, we will be
adding optimizations to reduce cacheLock contention by only holding it
when updating the cache.

This change is non-functional and doesn't change the current locking
contract

Test: Manual + AccountManagerServiceTest
Bug: 36485175
Change-Id: Iebc437463958d33b32fc1273a84680c22ac60825
parent 55bea5e3
Loading
Loading
Loading
Loading
+51 −46
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ public final class AccountManagerBackupHelper {
            Account account = null;
            AccountManagerService.UserAccounts accounts = mAccountManagerService
                    .getUserAccounts(userId);
            synchronized (accounts.dbLock) {
                synchronized (accounts.cacheLock) {
                    for (Account[] accountsPerType : accounts.accountCache.values()) {
                        for (Account accountPerType : accountsPerType) {
@@ -114,6 +115,7 @@ public final class AccountManagerBackupHelper {
                        }
                    }
                }
            }
            if (account == null) {
                return false;
            }
@@ -141,6 +143,7 @@ public final class AccountManagerBackupHelper {
    public byte[] backupAccountAccessPermissions(int userId) {
        final AccountManagerService.UserAccounts accounts = mAccountManagerService
                .getUserAccounts(userId);
        synchronized (accounts.dbLock) {
            synchronized (accounts.cacheLock) {
                List<Pair<String, Integer>> allAccountGrants = accounts.accountsDb
                        .findAllAccountGrants();
@@ -154,7 +157,8 @@ public final class AccountManagerBackupHelper {
                    serializer.startDocument(null, true);
                    serializer.startTag(null, TAG_PERMISSIONS);

                PackageManager packageManager = mAccountManagerService.mContext.getPackageManager();
                    PackageManager packageManager = mAccountManagerService.mContext
                            .getPackageManager();
                    for (Pair<String, Integer> grant : allAccountGrants) {
                        final String accountName = grant.first;
                        final int uid = grant.second;
@@ -187,6 +191,7 @@ public final class AccountManagerBackupHelper {
                }
            }
        }
    }

    public void restoreAccountAccessPermissions(byte[] data, int userId) {
        try {
+529 −445

File changed.

Preview size limit exceeded, changes collapsed.