From aa6634eaca707f7cbf5f5a1d75b90d8d775d254b Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Mon, 6 Oct 2014 14:20:28 -0700 Subject: Set the default user restrictions to disallow calling and sms When creating a user via the UI, disallow phone calls and SMS by default. Primary user must explicitly enable it via Settings. Bug: 17832802 Change-Id: I18cad4be8493ddc8890b5d90da2df256cb3f1ec9 --- .../com/android/server/pm/UserManagerService.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'services') diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 26e0db3..0cf2249 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -119,7 +119,7 @@ public class UserManagerService extends IUserManager.Stub { private static final int MIN_USER_ID = 10; - private static final int USER_VERSION = 4; + private static final int USER_VERSION = 5; private static final long EPOCH_PLUS_30_YEARS = 30L * 365 * 24 * 60 * 60 * 1000L; // ms @@ -462,6 +462,17 @@ public class UserManagerService extends IUserManager.Stub { } } + /** + * If default guest restrictions haven't been initialized yet, add the basic + * restrictions. + */ + private void initDefaultGuestRestrictions() { + if (mGuestRestrictions.isEmpty()) { + mGuestRestrictions.putBoolean(UserManager.DISALLOW_OUTGOING_CALLS, true); + writeUserListLocked(); + } + } + @Override public Bundle getDefaultGuestRestrictions() { checkManageUsersPermission("getDefaultGuestRestrictions"); @@ -693,6 +704,11 @@ public class UserManagerService extends IUserManager.Stub { userVersion = 4; } + if (userVersion < 5) { + initDefaultGuestRestrictions(); + userVersion = 5; + } + if (userVersion < USER_VERSION) { Slog.w(LOG_TAG, "User version " + mUserVersion + " didn't upgrade as expected to " + USER_VERSION); @@ -715,6 +731,7 @@ public class UserManagerService extends IUserManager.Stub { mUserRestrictions.append(UserHandle.USER_OWNER, restrictions); updateUserIdsLocked(); + initDefaultGuestRestrictions(); writeUserListLocked(); writeUserLocked(primary); -- cgit v1.1