DevicePolicyManager#createAndManageUser.
BUG:
24883058
Change-Id: I225ee6f1f6692663349040676e7a6c742b3ede79
public static final int SKIP_SETUP_WIZARD = 0x0001;
/**
+ * Flag used by {@link #createAndManageUser} to specify that the user should be created
+ * ephemeral.
+ * @hide
+ */
+ public static final int MAKE_USER_EPHEMERAL = 0x0002;
+
+ /**
* Called by a device owner to create a user with the specified name and a given component of
* the calling package as profile owner. 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
final long id = mInjector.binderClearCallingIdentity();
try {
- UserInfo userInfo = mUserManager.createUser(name, 0 /* flags */);
+ int userInfoFlags = 0;
+ if ((flags & DevicePolicyManager.MAKE_USER_EPHEMERAL) != 0) {
+ userInfoFlags |= UserInfo.FLAG_EPHEMERAL;
+ }
+ UserInfo userInfo = mUserManager.createUser(name, userInfoFlags);
if (userInfo != null) {
user = userInfo.getUserHandle();
}