Loading src/com/android/settings/Utils.java +20 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading @@ -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. * * <p> 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<UserHandle> profiles = userManager.getUserProfiles(); for (UserHandle userHandle : profiles) { UserProperties userProperties = userManager.getUserProperties(userHandle); if (userProperties.getShowInSettings() == UserProperties.SHOW_IN_SETTINGS_SEPARATE) { return true; } } return false; } /** * Returns true if current binder uid is Settings Intelligence. */ Loading src/com/android/settings/applications/manageapplications/ManageApplications.java +3 −2 Original line number Diff line number Diff line Loading @@ -521,8 +521,9 @@ public class ManageApplications extends InstrumentedFragment mFilterAdapter.enableFilter(filterType); if (mListType == LIST_TYPE_MAIN) { if (UserManager.get(getActivity()).getUserProfiles().size() > 1 && !mIsWorkOnly && !mIsPersonalOnly) { // Apply the personal and work filter only if new tab should be added // for a given user profile. Else let it use the default all apps filter. if (Utils.isNewTabNeeded(getActivity()) && !mIsWorkOnly && !mIsPersonalOnly) { mFilterAdapter.enableFilter(FILTER_APPS_PERSONAL); mFilterAdapter.enableFilter(FILTER_APPS_WORK); } Loading Loading
src/com/android/settings/Utils.java +20 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading @@ -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. * * <p> 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<UserHandle> profiles = userManager.getUserProfiles(); for (UserHandle userHandle : profiles) { UserProperties userProperties = userManager.getUserProperties(userHandle); if (userProperties.getShowInSettings() == UserProperties.SHOW_IN_SETTINGS_SEPARATE) { return true; } } return false; } /** * Returns true if current binder uid is Settings Intelligence. */ Loading
src/com/android/settings/applications/manageapplications/ManageApplications.java +3 −2 Original line number Diff line number Diff line Loading @@ -521,8 +521,9 @@ public class ManageApplications extends InstrumentedFragment mFilterAdapter.enableFilter(filterType); if (mListType == LIST_TYPE_MAIN) { if (UserManager.get(getActivity()).getUserProfiles().size() > 1 && !mIsWorkOnly && !mIsPersonalOnly) { // Apply the personal and work filter only if new tab should be added // for a given user profile. Else let it use the default all apps filter. if (Utils.isNewTabNeeded(getActivity()) && !mIsWorkOnly && !mIsPersonalOnly) { mFilterAdapter.enableFilter(FILTER_APPS_PERSONAL); mFilterAdapter.enableFilter(FILTER_APPS_WORK); } Loading