BinTianqi / OwnDroid

Own your Android! 使用Device owner管理你的安卓设备。Manage your device with Device owner privilege
https://owndroid.pages.dev
GNU General Public License v3.0
351 stars 13 forks source link

Create multiple/unlimited, clone users #17

Closed vsex7 closed 4 months ago

vsex7 commented 4 months ago

Type android.os.usertype.profile.CLONE Please provide support

BinTianqi commented 4 months ago

I will not provide support for it.

UserManager#USER_TYPE_PROFILE_CLONE

@SystemApi
public static final String USER_TYPE_PROFILE_CLONE = "android.os.usertype.profile.CLONE";

UserManager#createProfileForUser

/**
* Creates a user with the specified name and options as a profile of another user.
*
* @param name the user's name
* @param userType the type of user, such as {@link UserManager#USER_TYPE_PROFILE_MANAGED}.
* @param flags UserInfo flags that specify user properties.
* @param userId new user will be a profile of this user.
*
* @return the {@link UserInfo} object for the created user, or null if the user could not be created.
* @hide
*/
@RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, Manifest.permission.CREATE_USERS})
public @Nullable UserInfo createProfileForUser(String name, @NonNull String userType, @UserInfoFlag int flags, @UserIdInt int userId) {
    return createProfileForUser(name, userType, flags, userId, null);
}
  1. Android SDK don't provide it for me, because this method is a hidden system API. That is to say, only system apps can call this method.
  2. This function is belonged to UserManager, not DevicePolicyManager, I won't dig into it.

If you want to create mutiple/unlimited users with OwnDroid, you can activate OwnDroid as Device owner, then create managed users in User manager.