Loading services/core/java/com/android/server/pm/UserManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -4882,6 +4882,7 @@ public class UserManagerService extends IUserManager.Stub { UserManager.USER_OPERATION_ERROR_LOW_STORAGE); } final boolean isMainUser = (flags & UserInfo.FLAG_MAIN) != 0; final boolean isProfile = userTypeDetails.isProfile(); final boolean isGuest = UserManager.isUserTypeGuest(userType); final boolean isRestricted = UserManager.isUserTypeRestricted(userType); Loading Loading @@ -5028,6 +5029,10 @@ public class UserManagerService extends IUserManager.Stub { } } else { userTypeDetails.addDefaultRestrictionsTo(restrictions); if (isMainUser) { restrictions.remove(UserManager.DISALLOW_OUTGOING_CALLS); restrictions.remove(UserManager.DISALLOW_SMS); } } synchronized (mRestrictionsLock) { mBaseUserRestrictions.updateRestrictions(userId, restrictions); Loading services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -15,7 +15,10 @@ */ package com.android.server.pm; import static android.os.UserManager.DISALLOW_OUTGOING_CALLS; import static android.os.UserManager.DISALLOW_SMS; import static android.os.UserManager.DISALLOW_USER_SWITCH; import static android.os.UserManager.USER_TYPE_FULL_SECONDARY; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; Loading Loading @@ -490,6 +493,17 @@ public final class UserManagerServiceTest { assertThat(mUms.isUserSwitcherEnabled(USER_ID)).isTrue(); } @Test public void testMainUser_hasNoCallsOrSMSRestrictionsByDefault() { UserInfo mainUser = mUms.createUserWithThrow("main user", USER_TYPE_FULL_SECONDARY, UserInfo.FLAG_FULL | UserInfo.FLAG_MAIN); assertThat(mUms.hasUserRestriction(DISALLOW_OUTGOING_CALLS, mainUser.id)) .isFalse(); assertThat(mUms.hasUserRestriction(DISALLOW_SMS, mainUser.id)) .isFalse(); } private void resetUserSwitcherEnabled() { mUms.putUserInfo(new UserInfo(USER_ID, "Test User", 0)); mUms.setUserRestriction(DISALLOW_USER_SWITCH, false, USER_ID); Loading Loading
services/core/java/com/android/server/pm/UserManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -4882,6 +4882,7 @@ public class UserManagerService extends IUserManager.Stub { UserManager.USER_OPERATION_ERROR_LOW_STORAGE); } final boolean isMainUser = (flags & UserInfo.FLAG_MAIN) != 0; final boolean isProfile = userTypeDetails.isProfile(); final boolean isGuest = UserManager.isUserTypeGuest(userType); final boolean isRestricted = UserManager.isUserTypeRestricted(userType); Loading Loading @@ -5028,6 +5029,10 @@ public class UserManagerService extends IUserManager.Stub { } } else { userTypeDetails.addDefaultRestrictionsTo(restrictions); if (isMainUser) { restrictions.remove(UserManager.DISALLOW_OUTGOING_CALLS); restrictions.remove(UserManager.DISALLOW_SMS); } } synchronized (mRestrictionsLock) { mBaseUserRestrictions.updateRestrictions(userId, restrictions); Loading
services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -15,7 +15,10 @@ */ package com.android.server.pm; import static android.os.UserManager.DISALLOW_OUTGOING_CALLS; import static android.os.UserManager.DISALLOW_SMS; import static android.os.UserManager.DISALLOW_USER_SWITCH; import static android.os.UserManager.USER_TYPE_FULL_SECONDARY; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; Loading Loading @@ -490,6 +493,17 @@ public final class UserManagerServiceTest { assertThat(mUms.isUserSwitcherEnabled(USER_ID)).isTrue(); } @Test public void testMainUser_hasNoCallsOrSMSRestrictionsByDefault() { UserInfo mainUser = mUms.createUserWithThrow("main user", USER_TYPE_FULL_SECONDARY, UserInfo.FLAG_FULL | UserInfo.FLAG_MAIN); assertThat(mUms.hasUserRestriction(DISALLOW_OUTGOING_CALLS, mainUser.id)) .isFalse(); assertThat(mUms.hasUserRestriction(DISALLOW_SMS, mainUser.id)) .isFalse(); } private void resetUserSwitcherEnabled() { mUms.putUserInfo(new UserInfo(USER_ID, "Test User", 0)); mUms.setUserRestriction(DISALLOW_USER_SWITCH, false, USER_ID); Loading