Merge "Allow users to add profile owner after setup if the supervision role is set."

This commit is contained in:
Roman Kalukiewicz
2022-02-10 02:24:17 +00:00
committed by Android (Google) Code Review

View File

@@ -311,11 +311,13 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
return; return;
} }
// othewise, only the defined default supervision profile owner can be set after user // otherwise, only the defined default supervision profile owner or holder of
// setup. // supersvision role can be set after user setup.
final String supervisor = getString( final String supervisor = getString(
com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent); com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent);
if (TextUtils.isEmpty(supervisor)) { final String supervisionRolePackage = getString(
com.android.internal.R.string.config_systemSupervision);
if (TextUtils.isEmpty(supervisor) && TextUtils.isEmpty(supervisionRolePackage)) {
Log.w(TAG, "Unable to set profile owner post-setup, no default supervisor" Log.w(TAG, "Unable to set profile owner post-setup, no default supervisor"
+ "profile owner defined"); + "profile owner defined");
finish(); finish();
@@ -324,7 +326,8 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
final ComponentName supervisorComponent = ComponentName.unflattenFromString( final ComponentName supervisorComponent = ComponentName.unflattenFromString(
supervisor); supervisor);
if (supervisorComponent == null || who.compareTo(supervisorComponent) != 0) { if (!who.equals(supervisorComponent)
&& !who.getPackageName().equals(supervisionRolePackage)) {
Log.w(TAG, "Unable to set non-default profile owner post-setup " + who); Log.w(TAG, "Unable to set non-default profile owner post-setup " + who);
finish(); finish();
return; return;