diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-01-15 13:56:36 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-01-15 13:56:36 +0000 |
| commit | 23374d63ecfd076c41c855bc59f63570cf265a7c (patch) | |
| tree | e5c894005881dae572c88c19848593950edf41e5 /core/java | |
| parent | 1fc0927d4a3ff03d107f7bfd2d99528cc3761e05 (diff) | |
| parent | b6ef86985dd79923c08ea6ecb1c8c56fa76b5193 (diff) | |
Merge "Move startUserInBackground to standalone and avoid user from being stopped unnecessarily"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/ActivityManagerInternal.java | 5 | ||||
| -rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 57 | ||||
| -rw-r--r-- | core/java/android/app/admin/IDevicePolicyManager.aidl | 1 |
3 files changed, 41 insertions, 22 deletions
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java index 60a5a110193a..972ffcbf527f 100644 --- a/core/java/android/app/ActivityManagerInternal.java +++ b/core/java/android/app/ActivityManagerInternal.java @@ -319,4 +319,9 @@ public abstract class ActivityManagerInternal { } public abstract void registerScreenObserver(ScreenObserver observer); + + /** + * Returns if more users can be started without stopping currently running users. + */ + public abstract boolean canStartMoreUsers(); } diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 10539d19d563..e334aab7005e 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -6506,12 +6506,6 @@ public class DevicePolicyManager { public static final int MAKE_USER_DEMO = 0x0004; /** - * Flag used by {@link #createAndManageUser} to specify that the newly created user should be - * started in the background as part of the user creation. - */ - public static final int START_USER_IN_BACKGROUND = 0x0008; - - /** * Flag used by {@link #createAndManageUser} to specify that the newly created user should skip * the disabling of system apps during provisioning. */ @@ -6524,7 +6518,6 @@ public class DevicePolicyManager { SKIP_SETUP_WIZARD, MAKE_USER_EPHEMERAL, MAKE_USER_DEMO, - START_USER_IN_BACKGROUND, LEAVE_ALL_SYSTEM_APPS_ENABLED }) @Retention(RetentionPolicy.SOURCE) @@ -6553,7 +6546,8 @@ public class DevicePolicyManager { * IllegalArgumentException is thrown. * @param adminExtras Extras that will be passed to onEnable of the admin receiver on the new * user. - * @param flags {@link #SKIP_SETUP_WIZARD} is supported. + * @param flags {@link #SKIP_SETUP_WIZARD}, {@link #MAKE_USER_EPHEMERAL} and + * {@link #LEAVE_ALL_SYSTEM_APPS_ENABLED} are supported. * @see UserHandle * @return the {@link android.os.UserHandle} object for the created user, or {@code null} if the * user could not be created. @@ -6572,8 +6566,8 @@ public class DevicePolicyManager { } /** - * Called by a device owner to remove a user and all associated data. The primary user can not - * be removed. + * Called by a device owner to remove a user/profile 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. @@ -6590,14 +6584,14 @@ public class DevicePolicyManager { } /** - * Called by a device owner to switch the specified user to the foreground. - * <p> This cannot be used to switch to a managed profile. + * Called by a device owner to switch the specified secondary user to the foreground. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param userHandle the user to switch to; null will switch to primary. * @return {@code true} if the switch was successful, {@code false} otherwise. * @throws SecurityException if {@code admin} is not a device owner. * @see Intent#ACTION_USER_FOREGROUND + * @see #getSecondaryUsers(ComponentName) */ public boolean switchUser(@NonNull ComponentName admin, @Nullable UserHandle userHandle) { throwIfParentInstance("switchUser"); @@ -6609,13 +6603,32 @@ public class DevicePolicyManager { } /** + * Called by a device owner to start the specified secondary user in background. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @param userHandle the user to be stopped. + * @return {@code true} if the user can be started, {@code false} otherwise. + * @throws SecurityException if {@code admin} is not a device owner. + * @see #getSecondaryUsers(ComponentName) + */ + public boolean startUserInBackground( + @NonNull ComponentName admin, @NonNull UserHandle userHandle) { + throwIfParentInstance("startUserInBackground"); + try { + return mService.startUserInBackground(admin, userHandle); + } catch (RemoteException re) { + throw re.rethrowFromSystemServer(); + } + } + + /** * Called by a device owner to stop the specified secondary user. - * <p> This cannot be used to stop the primary user or a managed profile. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param userHandle the user to be stopped. * @return {@code true} if the user can be stopped, {@code false} otherwise. * @throws SecurityException if {@code admin} is not a device owner. + * @see #getSecondaryUsers(ComponentName) */ public boolean stopUser(@NonNull ComponentName admin, @NonNull UserHandle userHandle) { throwIfParentInstance("stopUser"); @@ -6627,14 +6640,13 @@ public class DevicePolicyManager { } /** - * Called by a profile owner that is affiliated with the device to stop the calling user - * and switch back to primary. - * <p> This has no effect when called on a managed profile. + * Called by a profile owner of secondary user that is affiliated with the device to stop the + * calling user and switch back to primary. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @return {@code true} if the exit was successful, {@code false} otherwise. * @throws SecurityException if {@code admin} is not a profile owner affiliated with the device. - * @see #isAffiliatedUser + * @see #getSecondaryUsers(ComponentName) */ public boolean logoutUser(@NonNull ComponentName admin) { throwIfParentInstance("logoutUser"); @@ -6646,17 +6658,18 @@ public class DevicePolicyManager { } /** - * Called by a device owner to list all secondary users on the device, excluding managed - * profiles. + * Called by a device owner to list all secondary users on the device. Managed profiles are not + * considered as secondary users. * <p> Used for various user management APIs, including {@link #switchUser}, {@link #removeUser} * and {@link #stopUser}. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @return list of other {@link UserHandle}s on the device. * @throws SecurityException if {@code admin} is not a device owner. - * @see #switchUser - * @see #removeUser - * @see #stopUser + * @see #removeUser(ComponentName, UserHandle) + * @see #switchUser(ComponentName, UserHandle) + * @see #startUserInBackground(ComponentName, UserHandle) + * @see #stopUser(ComponentName, UserHandle) */ public List<UserHandle> getSecondaryUsers(@NonNull ComponentName admin) { throwIfParentInstance("getSecondaryUsers"); diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 1d8ddeebcc26..7154053f593c 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -226,6 +226,7 @@ interface IDevicePolicyManager { UserHandle createAndManageUser(in ComponentName who, in String name, in ComponentName profileOwner, in PersistableBundle adminExtras, in int flags); boolean removeUser(in ComponentName who, in UserHandle userHandle); boolean switchUser(in ComponentName who, in UserHandle userHandle); + boolean startUserInBackground(in ComponentName who, in UserHandle userHandle); boolean stopUser(in ComponentName who, in UserHandle userHandle); boolean logoutUser(in ComponentName who); List<UserHandle> getSecondaryUsers(in ComponentName who); |
