summaryrefslogtreecommitdiffstats
path: root/core/java/android/os
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2014-10-07 17:11:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-07 17:11:34 +0000
commit41bb3455e44dc8fde4569bbfd56fa20c6da8a27d (patch)
treed6c0fa9a305a64adc70aef79a7c9c2b1b0e0fe73 /core/java/android/os
parent0d334365c6123388a0df81438b82122be29d19ab (diff)
parentaa6634eaca707f7cbf5f5a1d75b90d8d775d254b (diff)
downloadframeworks_base-41bb3455e44dc8fde4569bbfd56fa20c6da8a27d.zip
frameworks_base-41bb3455e44dc8fde4569bbfd56fa20c6da8a27d.tar.gz
frameworks_base-41bb3455e44dc8fde4569bbfd56fa20c6da8a27d.tar.bz2
Merge "Set the default user restrictions to disallow calling and sms" into lmp-dev
Diffstat (limited to 'core/java/android/os')
-rw-r--r--core/java/android/os/UserManager.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 37294e7..984f12f 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -721,6 +721,39 @@ public class UserManager {
}
/**
+ * Creates a secondary user with the specified name and options and configures it with default
+ * restrictions.
+ * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
+ *
+ * @param name the user's name
+ * @param flags flags that identify the type of user and other properties.
+ * @see UserInfo
+ *
+ * @return the UserInfo object for the created user, or null if the user could not be created.
+ * @hide
+ */
+ public UserInfo createSecondaryUser(String name, int flags) {
+ try {
+ UserInfo user = mService.createUser(name, flags);
+ if (user == null) {
+ return null;
+ }
+ Bundle userRestrictions = mService.getUserRestrictions(user.id);
+ addDefaultUserRestrictions(userRestrictions);
+ mService.setUserRestrictions(userRestrictions, user.id);
+ return user;
+ } catch (RemoteException re) {
+ Log.w(TAG, "Could not create a user", re);
+ return null;
+ }
+ }
+
+ private static void addDefaultUserRestrictions(Bundle restrictions) {
+ restrictions.putBoolean(DISALLOW_OUTGOING_CALLS, true);
+ restrictions.putBoolean(DISALLOW_SMS, true);
+ }
+
+ /**
* Creates a user with the specified name and options as a profile of another user.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
*