Allow users to add profile owner after setup if the supervision role is

set.

Bug: 185905077
Test: manual
Change-Id: Ia267c9d4fa6d438fa9449c6f44031a3831e86fa1
This commit is contained in:
Roman Kalukiewicz
2022-02-09 13:09:55 -08:00
parent 0ee078d37a
commit f6a7b65a98

View File

@@ -309,11 +309,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();
@@ -322,7 +324,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;