summaryrefslogtreecommitdiffstats
path: root/services/devicepolicy/java
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2014-07-09 19:57:08 -0400
committerJason Monk <jmonk@google.com>2014-07-10 11:05:07 -0400
commit582d9111d76632027fed7af10d05d4b44df16c0c (patch)
treeb08b77a59762dbdc49b1b2831ca0da6c4fdc8e81 /services/devicepolicy/java
parentc09a04da297ff85b97aa6ec0a457e9292b8bf7fa (diff)
downloadframeworks_base-582d9111d76632027fed7af10d05d4b44df16c0c.zip
frameworks_base-582d9111d76632027fed7af10d05d4b44df16c0c.tar.gz
frameworks_base-582d9111d76632027fed7af10d05d4b44df16c0c.tar.bz2
Add API for device owner to switch users
Once verified that caller is device owner just calls through to the activity manager and acts like that call. Change-Id: I34023313cd6742b73d2105655ec6b631879aa37a
Diffstat (limited to 'services/devicepolicy/java')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java24
1 files changed, 24 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 61f09f6..5445dc0 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -3592,6 +3592,30 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
@Override
+ public boolean switchUser(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 {
+ int userId = UserHandle.USER_OWNER;
+ if (userHandle != null) {
+ userId = userHandle.getIdentifier();
+ }
+ return ActivityManagerNative.getDefault().switchUser(userId);
+ } catch (RemoteException e) {
+ Log.e(LOG_TAG, "Couldn't switch user", e);
+ return false;
+ } finally {
+ restoreCallingIdentity(id);
+ }
+ }
+ }
+
+ @Override
public Bundle getApplicationRestrictions(ComponentName who, String packageName) {
final UserHandle userHandle = new UserHandle(UserHandle.getCallingUserId());