diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 8ee4ebac502..e57a32d6734 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -41,6 +41,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; +import android.content.pm.UserProperties; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; @@ -1163,7 +1164,7 @@ public final class Utils extends com.android.settingslib.Utils { final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE) == ProfileSelectFragment.ProfileType.WORK : false; try { - if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1 + if (isNewTabNeeded(activity) && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null && !isWork && !isPersonal) { f = Fragment.instantiate(activity, @@ -1177,6 +1178,24 @@ public final class Utils extends com.android.settingslib.Utils { return f; } + /** + * Checks if a new tab is needed or not for any user profile associated with the context user. + * + *
Checks if any user has the property {@link UserProperties#SHOW_IN_SETTINGS_SEPARATE} set.
+ */
+ public static boolean isNewTabNeeded(Activity activity) {
+ UserManager userManager = activity.getSystemService(UserManager.class);
+ List