Hide VPNs from users that are hidden
Bug: 342562186
Test: manual
Change-Id: I288ac0a0eef48d4a94191de2292d02a0f93310aa
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 0ee21b9..093d2be 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -61,6 +61,7 @@
import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnProfile;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.GearPreference;
@@ -592,6 +593,9 @@
// Mark connected third-party services
Set<AppVpnInfo> connections = new ArraySet<>();
for (UserHandle profile : mUserManager.getUserProfiles()) {
+ if (Utils.shouldHideUser(profile, mUserManager)) {
+ continue;
+ }
VpnConfig config = mVpnManager.getVpnConfig(profile.getIdentifier());
if (config != null && !config.legacy) {
connections.add(new AppVpnInfo(profile.getIdentifier(), config.user));
@@ -604,6 +608,9 @@
private Set<AppVpnInfo> getAlwaysOnAppVpnInfos() {
Set<AppVpnInfo> result = new ArraySet<>();
for (UserHandle profile : mUserManager.getUserProfiles()) {
+ if (Utils.shouldHideUser(profile, mUserManager)) {
+ continue;
+ }
final int profileId = profile.getIdentifier();
final String packageName = mVpnManager.getAlwaysOnVpnPackageForUser(profileId);
if (packageName != null) {
@@ -627,7 +634,11 @@
final Set<Integer> profileIds;
if (includeProfiles) {
profileIds = new ArraySet<>();
- for (UserHandle profile : UserManager.get(context).getUserProfiles()) {
+ UserManager userManager = UserManager.get(context);
+ for (UserHandle profile : userManager.getUserProfiles()) {
+ if (Utils.shouldHideUser(profile, userManager)) {
+ continue;
+ }
profileIds.add(profile.getIdentifier());
}
} else {