Check purely for the presence of a managed profile

including the parent user, as here we care only about the existence of
the managed profile.

This maintains the behaviour prior to private space changes.

Bug: 313128792
Test: manual
Test: atest ProfileSelectFragmentTest
Change-Id: I1d253f95ca534b48acfdb4c1c8b84368d731dded
This commit is contained in:
Manish Singh
2023-11-28 16:06:31 +00:00
parent eaafcbcb28
commit d503f25692
3 changed files with 30 additions and 14 deletions

View File

@@ -322,7 +322,7 @@ public abstract class ProfileSelectFragment extends DashboardFragment {
personalFragment.setArguments(personalOnly);
fragments.add(personalFragment);
if (managedProfileInfoProvider.getManagedProfile(context) != null) {
if (managedProfileInfoProvider.isManagedProfilePresent(context)) {
final Bundle workOnly = bundle != null ? bundle.deepCopy() : new Bundle();
workOnly.putInt(EXTRA_PROFILE, ProfileType.WORK);
final Fragment workFragment =
@@ -361,8 +361,9 @@ public abstract class ProfileSelectFragment extends DashboardFragment {
}
interface ManagedProfileInfoProvider {
default UserHandle getManagedProfile(Context context) {
return Utils.getManagedProfile(context.getSystemService(UserManager.class));
default boolean isManagedProfilePresent(Context context) {
return Utils.doesProfileOfTypeExists(
context.getSystemService(UserManager.class), ProfileType.WORK);
}
}