From 2a8b7039b0b0560dda1b62461f284425556a24c0 Mon Sep 17 00:00:00 2001 From: Oli Thompson Date: Tue, 30 Jul 2024 09:46:53 +0000 Subject: [PATCH] Fix UnsupportedOperationException from immutable set change immutable set to HashSet Flag: android.app.admin.flags.backup_connected_apps_settings Bug: 355817689 Test: manually tested Change-Id: I983d9b3f979e5659669a4a318f03e720623a47b4 --- .../InteractAcrossProfilesDetails.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java index d40a075b058..5df591443f3 100644 --- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java +++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java @@ -72,9 +72,9 @@ import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedSwitchPreference; import com.android.settingslib.widget.LayoutPreference; -import java.util.Collections; +import java.util.Arrays; +import java.util.HashSet; import java.util.Optional; -import java.util.Set; public class InteractAcrossProfilesDetails extends AppInfoBase implements Preference.OnPreferenceClickListener { @@ -571,8 +571,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase String disallowedPackagesString = Settings.Global.getString(getContentResolver(), CONNECTED_APPS_DISALLOWED_PACKAGES); - Set allowedPackagesSet = getSetFromString(allowedPackagesString); - Set disallowedPackagesSet = getSetFromString(disallowedPackagesString); + HashSet allowedPackagesSet = getSetFromString(allowedPackagesString); + HashSet disallowedPackagesSet = getSetFromString(disallowedPackagesString); if (enabled) { allowedPackagesSet.add(crossProfilePackage); @@ -592,9 +592,9 @@ public class InteractAcrossProfilesDetails extends AppInfoBase String.join(",", disallowedPackagesSet)); } - private Set getSetFromString(String packages) { + private HashSet getSetFromString(String packages) { return Optional.ofNullable(packages) - .map(pkg -> Set.of(pkg.split(","))) - .orElse(Collections.emptySet()); + .map(pkg -> new HashSet<>(Arrays.asList(pkg.split(",")))) + .orElseGet(HashSet::new); } }