public static void requestProfileOwnerSetupWithRoot(final Activity activity) {
		final ProgressDialog progress = ProgressDialog.show(activity, null, "Setup Island...", true);
		// Phase 1: Create profile		TODO: Skip profile creation or remove existent profile first, if profile is already present (probably left by unsuccessful setup)
		final List<String> commands = Arrays.asList("setprop fw.max_users 10",
				"pm create-user --profileOf " + Users.toId(Process.myUserHandle()) + " --managed Island", "echo END");
		SafeAsyncTask.execute(activity, context -> Shell.SU.run(commands), (context, result) -> {
			final List<UserInfo> profiles = Hack.into(requireNonNull(context.getSystemService(Context.USER_SERVICE)))
					.with(UserManagerHack.class).getProfiles(Users.toId(Users.current()));
			final Optional<UserHandle> profile_pending_setup = profiles.stream().map(UserInfo::getUserHandle)
					.filter(profile -> ! profile.equals(Users.current()) && isProfileWithoutOwner(context, profile)).findFirst();	// Not yet set up as profile owner
			if (! profile_pending_setup.isPresent()) {		// Profile creation failed
				if (result == null || result.isEmpty()) return;		// Just root failure
				Analytics.$().event("setup_island_root_failed").withRaw("commands", commands.stream().collect(joining("\n")))
						.withRaw("fw_max_users", String.valueOf(getSysPropMaxUsers()))
						.withRaw("config_multiuserMaximumUsers", String.valueOf(getResConfigMaxUsers()))
						.with(CONTENT, result.stream().collect(joining("\n"))).send();
				dismissProgressAndShowError(context, progress, 1);
				return;
			}

			installIslandInProfileWithRoot(context, progress, profile_pending_setup.get());
		});
	}
Implementation of Island / Mainland setup & shutdown.

Created by Oasis on 2017/3/8.
mobile/src/main/java/com/oasisfeng/island/setup/IslandSetup.java