diff options
author | Julia Reynolds <juliacr@google.com> | 2014-05-16 14:25:21 -0400 |
---|---|---|
committer | Julia Reynolds <juliacr@google.com> | 2014-05-23 11:14:34 +0000 |
commit | 6cbbe9ec991d04b642b8f4e41f25a593fa71f000 (patch) | |
tree | e01f7934a70bac2945e0d62f54004e9aa4195422 /core/java/android/app | |
parent | d57f8fc42d9b121b6dbe1a64b96d5c3e502b309d (diff) | |
download | frameworks_base-6cbbe9ec991d04b642b8f4e41f25a593fa71f000.zip frameworks_base-6cbbe9ec991d04b642b8f4e41f25a593fa71f000.tar.gz frameworks_base-6cbbe9ec991d04b642b8f4e41f25a593fa71f000.tar.bz2 |
Create deviceowner gated APIs for creating and removing users in devicepolicymanager.
This will allow DMAgent to manage users for EDU's cart model user case.
Bug: 15015887
Change-Id: I1eadf1701cb75fc4b50eb1a0df1525eff818286e
(cherry picked from commit be9f43b9618ec25121b151d247eb0285fb6554b3)
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 38 | ||||
-rw-r--r-- | core/java/android/app/admin/IDevicePolicyManager.aidl | 4 |
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); |