summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2014-05-23 13:08:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-23 13:08:09 +0000
commit0e1dc0f5aab427b2ae9d8bbfd3c440490cc7de88 (patch)
treecdc7746b34939f4dfb3d2b36650be1efdca43e6c /core/java
parent98157e8dbb29bef0d10899d88e87a5c1f8dcd3dc (diff)
parent6cbbe9ec991d04b642b8f4e41f25a593fa71f000 (diff)
downloadframeworks_base-0e1dc0f5aab427b2ae9d8bbfd3c440490cc7de88.zip
frameworks_base-0e1dc0f5aab427b2ae9d8bbfd3c440490cc7de88.tar.gz
frameworks_base-0e1dc0f5aab427b2ae9d8bbfd3c440490cc7de88.tar.bz2
Merge "Create deviceowner gated APIs for creating and removing users in devicepolicymanager." into lmp-preview-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java38
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl4
2 files changed, 42 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 18e2a95..77b1acf 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -32,6 +32,7 @@ import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.os.UserManager;
import android.provider.Settings;
import android.service.trust.TrustAgentService;
import android.util.Log;
@@ -1983,6 +1984,43 @@ public class DevicePolicyManager {
}
/**
+ * Called by a device owner to create a user with the specified name. The UserHandle returned
+ * by this method should not be persisted as user handles are recycled as users are removed and
+ * created. If you need to persist an identifier for this user, use
+ * {@link UserManager#getSerialNumberForUser}.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param name the user's name
+ * @see UserHandle
+ * @return the UserHandle object for the created user, or null if the user could not be created.
+ */
+ public UserHandle createUser(ComponentName admin, String name) {
+ try {
+ return mService.createUser(admin, name);
+ } catch (RemoteException re) {
+ Log.w(TAG, "Could not create a user", re);
+ }
+ return null;
+ }
+
+ /**
+ * Called by a device owner to remove a user and all associated data. The primary user can
+ * not be removed.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param userHandle the user to remove.
+ * @return {@code true} if the user was removed, {@code false} otherwise.
+ */
+ public boolean removeUser(ComponentName admin, UserHandle userHandle) {
+ try {
+ return mService.removeUser(admin, userHandle);
+ } catch (RemoteException re) {
+ Log.w(TAG, "Could not remove user ", re);
+ return false;
+ }
+ }
+
+ /**
* Called by a profile or device owner to get the application restrictions for a given target
* application running in the managed profile.
*
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 7257158..3c08c14 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.RemoteCallback;
+import android.os.UserHandle;
/**
* Internal IPC interface to the device policy service.
@@ -128,6 +129,9 @@ interface IDevicePolicyManager {
int setApplicationsBlocked(in ComponentName admin, in Intent intent, boolean blocked);
boolean isApplicationBlocked(in ComponentName admin, in String packageName);
+ UserHandle createUser(in ComponentName who, in String name);
+ boolean removeUser(in ComponentName who, in UserHandle userHandle);
+
void enableSystemApp(in ComponentName admin, in String packageName);
int enableSystemAppWithIntent(in ComponentName admin, in Intent intent);