From 9e0437bc5b619ec40c3759710ec1b32863e2260e Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Wed, 15 Nov 2023 11:50:47 +0000 Subject: [PATCH] Don't add private profile accounts to Personal tab If there are no tabs to show then the single Passwords & accounts page shows all the profiles under the corresponding headings. No tabs are shown only when the PS is locked and there's no work profile. And if PS is locked then we don't want to show any PS setting. On the other hand if PS is not locked then we'll have tabs. Bug: 309423484 Test: manual Change-Id: Iebc62fbc4caf21988af6aa1af4fbd570f4c80ada --- .../accounts/AccountPreferenceController.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java index 33b38884258..eb0f6f3eaaa 100644 --- a/src/com/android/settings/accounts/AccountPreferenceController.java +++ b/src/com/android/settings/accounts/AccountPreferenceController.java @@ -45,6 +45,7 @@ import android.content.pm.UserInfo; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Flags; import android.os.UserHandle; import android.os.UserManager; import android.text.BidiFormatter; @@ -297,13 +298,22 @@ public class AccountPreferenceController extends AbstractPreferenceController } else { List profiles = mUm.getProfiles(UserHandle.myUserId()); for (UserInfo profile : profiles) { - if ((profile.isManagedProfile() - && (mType & ProfileSelectFragment.ProfileType.WORK) != 0) - || (profile.isPrivateProfile() + // Check if this controller can handle this profile - e.g. if this controller's + // mType has the WORK flag set and this profile is a managed profile. + // If there are no tabs then this controller will support all profile types - + // - ProfileType.ALL. + // At the same time we should check the user property to make sure if this profile + // should be shown or not. + if (((profile.isManagedProfile() + && (mType & ProfileSelectFragment.ProfileType.WORK) != 0) + || (Flags.allowPrivateProfile() + && profile.isPrivateProfile() && (mType & ProfileSelectFragment.ProfileType.PRIVATE) != 0) || (!profile.isManagedProfile() - && !profile.isPrivateProfile() - && (mType & ProfileSelectFragment.ProfileType.PERSONAL) != 0)) { + && !(Flags.allowPrivateProfile() && profile.isPrivateProfile()) + && (mType & ProfileSelectFragment.ProfileType.PERSONAL) != 0)) + && !(mUm.getUserProperties(profile.getUserHandle()) + .getHideInSettingsInQuietMode() && profile.isQuietModeEnabled())) { updateProfileUi(profile); } }