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

Commit f81dc1cf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not synchronize if not necessary"

parents 180a0e13 538b3611
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -376,7 +376,7 @@ public class RoleUserState {

            version = mVersion;
            packagesHash = mPackagesHash;
            roles = getRoleHolders();
            roles = snapshotRolesLocked();
        }

        AtomicFile atomicFile = new AtomicFile(getFile(mUserId), "roles-" + mUserId);
@@ -541,7 +541,7 @@ public class RoleUserState {

            version = mVersion;
            packagesHash = mPackagesHash;
            roles = getRoleHolders();
            roles = snapshotRolesLocked();
        }

        long fieldToken = dumpOutputStream.start(fieldName, fieldId);
@@ -578,6 +578,12 @@ public class RoleUserState {
    @NonNull
    public ArrayMap<String, ArraySet<String>> getRoleHolders() {
        synchronized (mLock) {
            return snapshotRolesLocked();
        }
    }

    @GuardedBy("mLock")
    private ArrayMap<String, ArraySet<String>> snapshotRolesLocked() {
        ArrayMap<String, ArraySet<String>> roles = new ArrayMap<>();
        for (int i = 0, size = CollectionUtils.size(mRoles); i < size; ++i) {
            String roleName = mRoles.keyAt(i);
@@ -588,7 +594,6 @@ public class RoleUserState {
        }
        return roles;
    }
    }

    /**
     * Destroy this user state and delete the corresponding file. Any pending writes to the file