Merge "Annotate UserManagerService locks"

This commit is contained in:
Adam Bookatz
2022-05-06 18:20:10 +00:00
committed by Android (Google) Code Review

View File

@@ -2139,6 +2139,7 @@ public class UserManagerService extends IUserManager.Stub {
* exist in device policy local restrictions, remove the restrictions bundle for that target
* user originating from the specified originating user.
*/
@GuardedBy("mRestrictionsLock")
private boolean updateLocalRestrictionsForTargetUsersLR(int originatingUserId,
RestrictionsSet local, List<Integer> updatedTargetUserIds) {
boolean changed = false;
@@ -2161,6 +2162,7 @@ public class UserManagerService extends IUserManager.Stub {
*
* @return restrictions set for a given target user.
*/
@GuardedBy("mRestrictionsLock")
private @NonNull RestrictionsSet getDevicePolicyLocalRestrictionsForTargetUserLR(
int targetUserId) {
RestrictionsSet result = mDevicePolicyLocalUserRestrictions.get(targetUserId);
@@ -2411,6 +2413,7 @@ public class UserManagerService extends IUserManager.Stub {
mAppliedUserRestrictions.updateRestrictions(userId, new Bundle(effective));
}
@GuardedBy("mRestrictionsLock")
private void propagateUserRestrictionsLR(final int userId,
Bundle newRestrictions, Bundle prevRestrictions) {
// 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) {
try {
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) {
for (int i = 0; i < mDevicePolicyLocalUserRestrictions.size(); i++) {
int targetUserId = mDevicePolicyLocalUserRestrictions.keyAt(i);
@@ -3463,6 +3468,7 @@ public class UserManagerService extends IUserManager.Stub {
}
}
@GuardedBy({"mPackagesLock"})
private void writeUserLP(UserData userData) {
if (DBG) {
debug("writeUserLP " + userData);
@@ -3486,6 +3492,7 @@ public class UserManagerService extends IUserManager.Stub {
* <name>Primary</name>
* </user>
*/
@GuardedBy({"mPackagesLock"})
@VisibleForTesting
void writeUserLP(UserData userData, OutputStream os)
throws IOException, XmlPullParserException {
@@ -3638,6 +3645,7 @@ public class UserManagerService extends IUserManager.Stub {
}
}
@GuardedBy({"mPackagesLock"})
private UserData readUserLP(int id) {
FileInputStream fis = null;
try {
@@ -3655,6 +3663,7 @@ public class UserManagerService extends IUserManager.Stub {
return null;
}
@GuardedBy({"mPackagesLock"})
@VisibleForTesting
UserData readUserLP(int id, InputStream is) throws IOException,
XmlPullParserException {
@@ -3827,6 +3836,7 @@ public class UserManagerService extends IUserManager.Stub {
*
* @return whether there were any restrictions.
*/
@GuardedBy({"mAppRestrictionsLock"})
private static boolean cleanAppRestrictionsForPackageLAr(String pkg, @UserIdInt int userId) {
final File dir = Environment.getUserSystemDirectory(userId);
final File resFile = new File(dir, packageToRestrictionsFileName(pkg));