summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/pm/UserManagerService.java5
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java14
2 files changed, 19 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index ac52f9f48def..385dfcb8e4ec 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -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);
@@ -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);
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java
index 0664ab8f5519..d32b6be4a198 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java
@@ -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;
@@ -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);