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

Commit c194a7db authored by Adam Bookatz's avatar Adam Bookatz Committed by Android (Google) Code Review
Browse files

Merge "Annotate UserManagerService locks"

parents ebaf7c9f 2aea5551
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -2139,6 +2139,7 @@ public class UserManagerService extends IUserManager.Stub {
     * exist in device policy local restrictions, remove the restrictions bundle for that target
     * exist in device policy local restrictions, remove the restrictions bundle for that target
     * user originating from the specified originating user.
     * user originating from the specified originating user.
     */
     */
    @GuardedBy("mRestrictionsLock")
    private boolean updateLocalRestrictionsForTargetUsersLR(int originatingUserId,
    private boolean updateLocalRestrictionsForTargetUsersLR(int originatingUserId,
            RestrictionsSet local, List<Integer> updatedTargetUserIds) {
            RestrictionsSet local, List<Integer> updatedTargetUserIds) {
        boolean changed = false;
        boolean changed = false;
@@ -2161,6 +2162,7 @@ public class UserManagerService extends IUserManager.Stub {
     *
     *
     * @return restrictions set for a given target user.
     * @return restrictions set for a given target user.
     */
     */
    @GuardedBy("mRestrictionsLock")
    private @NonNull RestrictionsSet getDevicePolicyLocalRestrictionsForTargetUserLR(
    private @NonNull RestrictionsSet getDevicePolicyLocalRestrictionsForTargetUserLR(
            int targetUserId) {
            int targetUserId) {
        RestrictionsSet result = mDevicePolicyLocalUserRestrictions.get(targetUserId);
        RestrictionsSet result = mDevicePolicyLocalUserRestrictions.get(targetUserId);
@@ -2411,6 +2413,7 @@ public class UserManagerService extends IUserManager.Stub {
        mAppliedUserRestrictions.updateRestrictions(userId, new Bundle(effective));
        mAppliedUserRestrictions.updateRestrictions(userId, new Bundle(effective));
    }
    }


    @GuardedBy("mRestrictionsLock")
    private void propagateUserRestrictionsLR(final int userId,
    private void propagateUserRestrictionsLR(final int userId,
            Bundle newRestrictions, Bundle prevRestrictions) {
            Bundle newRestrictions, Bundle prevRestrictions) {
        // Note this method doesn't touch any state, meaning it doesn't require mRestrictionsLock
        // Note this method doesn't touch any state, meaning it doesn't require mRestrictionsLock
@@ -2884,6 +2887,7 @@ public class UserManagerService extends IUserManager.Stub {
        }
        }
    }
    }


    @GuardedBy({"mPackagesLock"})
    private void writeBitmapLP(UserInfo info, Bitmap bitmap) {
    private void writeBitmapLP(UserInfo info, Bitmap bitmap) {
        try {
        try {
            File dir = new File(mUsersDir, Integer.toString(info.id));
            File dir = new File(mUsersDir, Integer.toString(info.id));
@@ -3453,6 +3457,7 @@ public class UserManagerService extends IUserManager.Stub {
        }
        }
    }
    }


    @GuardedBy({"mPackagesLock"})
    private void writeAllTargetUsersLP(int originatingUserId) {
    private void writeAllTargetUsersLP(int originatingUserId) {
        for (int i = 0; i < mDevicePolicyLocalUserRestrictions.size(); i++) {
        for (int i = 0; i < mDevicePolicyLocalUserRestrictions.size(); i++) {
            int targetUserId = mDevicePolicyLocalUserRestrictions.keyAt(i);
            int targetUserId = mDevicePolicyLocalUserRestrictions.keyAt(i);
@@ -3463,6 +3468,7 @@ public class UserManagerService extends IUserManager.Stub {
        }
        }
    }
    }


    @GuardedBy({"mPackagesLock"})
    private void writeUserLP(UserData userData) {
    private void writeUserLP(UserData userData) {
        if (DBG) {
        if (DBG) {
            debug("writeUserLP " + userData);
            debug("writeUserLP " + userData);
@@ -3486,6 +3492,7 @@ public class UserManagerService extends IUserManager.Stub {
     *   <name>Primary</name>
     *   <name>Primary</name>
     * </user>
     * </user>
     */
     */
    @GuardedBy({"mPackagesLock"})
    @VisibleForTesting
    @VisibleForTesting
    void writeUserLP(UserData userData, OutputStream os)
    void writeUserLP(UserData userData, OutputStream os)
            throws IOException, XmlPullParserException {
            throws IOException, XmlPullParserException {
@@ -3638,6 +3645,7 @@ public class UserManagerService extends IUserManager.Stub {
        }
        }
    }
    }


    @GuardedBy({"mPackagesLock"})
    private UserData readUserLP(int id) {
    private UserData readUserLP(int id) {
        FileInputStream fis = null;
        FileInputStream fis = null;
        try {
        try {
@@ -3655,6 +3663,7 @@ public class UserManagerService extends IUserManager.Stub {
        return null;
        return null;
    }
    }


    @GuardedBy({"mPackagesLock"})
    @VisibleForTesting
    @VisibleForTesting
    UserData readUserLP(int id, InputStream is) throws IOException,
    UserData readUserLP(int id, InputStream is) throws IOException,
            XmlPullParserException {
            XmlPullParserException {
@@ -3827,6 +3836,7 @@ public class UserManagerService extends IUserManager.Stub {
     *
     *
     * @return whether there were any restrictions.
     * @return whether there were any restrictions.
     */
     */
    @GuardedBy({"mAppRestrictionsLock"})
    private static boolean cleanAppRestrictionsForPackageLAr(String pkg, @UserIdInt int userId) {
    private static boolean cleanAppRestrictionsForPackageLAr(String pkg, @UserIdInt int userId) {
        final File dir = Environment.getUserSystemDirectory(userId);
        final File dir = Environment.getUserSystemDirectory(userId);
        final File resFile = new File(dir, packageToRestrictionsFileName(pkg));
        final File resFile = new File(dir, packageToRestrictionsFileName(pkg));