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 /services | |
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 'services')
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 4e4d127..5395f60 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -3351,6 +3351,44 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override + public UserHandle createUser(ComponentName who, String name) { + synchronized (this) { + if (who == null) { + throw new NullPointerException("ComponentName is null"); + } + getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); + + long id = Binder.clearCallingIdentity(); + try { + UserInfo userInfo = mUserManager.createUser(name, 0 /* flags */); + if (userInfo != null) { + return userInfo.getUserHandle(); + } + return null; + } finally { + restoreCallingIdentity(id); + } + } + } + + @Override + public boolean removeUser(ComponentName who, UserHandle userHandle) { + synchronized (this) { + if (who == null) { + throw new NullPointerException("ComponentName is null"); + } + getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); + + long id = Binder.clearCallingIdentity(); + try { + return mUserManager.removeUser(userHandle.getIdentifier()); + } finally { + restoreCallingIdentity(id); + } + } + } + + @Override public Bundle getApplicationRestrictions(ComponentName who, String packageName) { final UserHandle userHandle = new UserHandle(UserHandle.getCallingUserId()); |