Loading services/core/java/com/android/server/pm/UserManagerService.java +3 −0 Original line number Diff line number Diff line Loading @@ -2633,6 +2633,9 @@ public class UserManagerService extends IUserManager.Stub { /** @return a specific user restriction that's in effect currently. */ @Override public boolean hasUserRestriction(String restrictionKey, @UserIdInt int userId) { if (!userExists(userId)) { return false; } checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "hasUserRestriction"); return mLocalService.hasUserRestriction(restrictionKey, userId); } Loading services/tests/servicestests/src/com/android/server/pm/UserManagerServiceTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,13 @@ public class UserManagerServiceTest { assertThat(mUserManagerService.hasUserRestriction(DISALLOW_USER_SWITCH, userId)).isFalse(); } @Test public void testHasUserRestriction_NonExistentUserReturnsFalse() { int nonExistentUserId = UserHandle.USER_NULL; assertThat(mUserManagerService.hasUserRestriction(DISALLOW_USER_SWITCH, nonExistentUserId)) .isFalse(); } @Test public void testSetUserRestrictionWithIncorrectID() throws Exception { int incorrectId = 1; Loading Loading
services/core/java/com/android/server/pm/UserManagerService.java +3 −0 Original line number Diff line number Diff line Loading @@ -2633,6 +2633,9 @@ public class UserManagerService extends IUserManager.Stub { /** @return a specific user restriction that's in effect currently. */ @Override public boolean hasUserRestriction(String restrictionKey, @UserIdInt int userId) { if (!userExists(userId)) { return false; } checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "hasUserRestriction"); return mLocalService.hasUserRestriction(restrictionKey, userId); } Loading
services/tests/servicestests/src/com/android/server/pm/UserManagerServiceTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,13 @@ public class UserManagerServiceTest { assertThat(mUserManagerService.hasUserRestriction(DISALLOW_USER_SWITCH, userId)).isFalse(); } @Test public void testHasUserRestriction_NonExistentUserReturnsFalse() { int nonExistentUserId = UserHandle.USER_NULL; assertThat(mUserManagerService.hasUserRestriction(DISALLOW_USER_SWITCH, nonExistentUserId)) .isFalse(); } @Test public void testSetUserRestrictionWithIncorrectID() throws Exception { int incorrectId = 1; Loading