List of usage examples for android.os UserManager isSplitSystemUser
@TestApi public static boolean isSplitSystemUser()
From source file:com.android.managedprovisioning.DeviceOwnerProvisioningService.java
/** * This is the core method of this class. It goes through every provisioning step. * Each task checks if it is required and executes if it is. *///from w w w . ja v a 2 s.c o m private void startDeviceOwnerProvisioning(final ProvisioningParams params) { if (DEBUG) ProvisionLogger.logd("Starting device owner provisioning"); // Construct Tasks. Do not start them yet. mAddWifiNetworkTask = new AddWifiNetworkTask(this, params.wifiInfo, new AddWifiNetworkTask.Callback() { @Override public void onSuccess() { progressUpdate(R.string.progress_download); mDownloadPackageTask.run(); } @Override public void onError() { error(R.string.device_owner_error_wifi, false /* do not require factory reset */); } }); mDownloadPackageTask = new DownloadPackageTask(this, new DownloadPackageTask.Callback() { @Override public void onSuccess() { progressUpdate(R.string.progress_install); mInstallPackageTask.addInstallIfNecessary(params.inferDeviceAdminPackageName(), mDownloadPackageTask.getDownloadedPackageLocation(DEVICE_OWNER)); mInstallPackageTask.run(); } @Override public void onError(int errorCode) { switch (errorCode) { case DownloadPackageTask.ERROR_HASH_MISMATCH: error(R.string.device_owner_error_hash_mismatch); break; case DownloadPackageTask.ERROR_DOWNLOAD_FAILED: error(R.string.device_owner_error_download_failed); break; default: error(R.string.device_owner_error_general); break; } } }); // Add packages to download to the DownloadPackageTask. mDownloadPackageTask.addDownloadIfNecessary(params.inferDeviceAdminPackageName(), params.deviceAdminDownloadInfo, DEVICE_OWNER); mInstallPackageTask = new InstallPackageTask(this, new InstallPackageTask.Callback() { @Override public void onSuccess() { progressUpdate(R.string.progress_set_owner); try { // Now that the app has been installed, we can look for the device admin // component in it. mSetDevicePolicyTask .run(mParams.inferDeviceAdminComponentName(DeviceOwnerProvisioningService.this)); } catch (IllegalProvisioningArgumentException e) { error(R.string.device_owner_error_general); ProvisionLogger.loge("Failed to infer the device admin component name", e); return; } } @Override public void onError(int errorCode) { switch (errorCode) { case InstallPackageTask.ERROR_PACKAGE_INVALID: error(R.string.device_owner_error_package_invalid); break; case InstallPackageTask.ERROR_INSTALLATION_FAILED: error(R.string.device_owner_error_installation_failed); break; default: error(R.string.device_owner_error_general); break; } } }); mSetDevicePolicyTask = new SetDevicePolicyTask(this, getResources().getString(R.string.default_owned_device_username), new SetDevicePolicyTask.Callback() { @Override public void onSuccess() { mDeleteNonRequiredAppsTask.run(); } @Override public void onError() { error(R.string.device_owner_error_general); } }); // For split system user devices that will have a system device owner, don't adjust the set // of enabled packages in the system user as we expect the right set of packages to be // enabled for the system user out of the box. For other devices, the set of available // packages can vary depending on management state. boolean leaveAllSystemAppsEnabled = params.leaveAllSystemAppsEnabled || params.provisioningAction.equals(ACTION_PROVISION_MANAGED_SHAREABLE_DEVICE); mDeleteNonRequiredAppsTask = new DeleteNonRequiredAppsTask(this, params.inferDeviceAdminPackageName(), DeleteNonRequiredAppsTask.DEVICE_OWNER, true /* creating new profile */, UserHandle.myUserId(), leaveAllSystemAppsEnabled, new DeleteNonRequiredAppsTask.Callback() { @Override public void onSuccess() { mDisallowAddUserTask.maybeDisallowAddUsers(); // Done with provisioning. Success. onProvisioningSuccess(); } @Override public void onError() { error(R.string.device_owner_error_general); } }); mDisallowAddUserTask = new DisallowAddUserTask((UserManager) getSystemService(USER_SERVICE), UserHandle.myUserId(), UserManager.isSplitSystemUser()); // Start first task, which starts next task in its callback, etc. progressUpdate(R.string.progress_connect_to_wifi); mAddWifiNetworkTask.run(); }
From source file:com.android.managedprovisioning.DeviceOwnerProvisioningService.java
private void maybeCopyAccount() { if (!UserManager.isSplitSystemUser()) { // Only one user involved in this case. return;/* w w w. j av a2s .c om*/ } mUtils.maybeCopyAccount(DeviceOwnerProvisioningService.this, mParams.accountToMigrate, UserHandle.SYSTEM, Process.myUserHandle()); }