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
This commit is contained in:
@@ -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<String> allowedPackagesSet = getSetFromString(allowedPackagesString);
|
||||
Set<String> disallowedPackagesSet = getSetFromString(disallowedPackagesString);
|
||||
HashSet<String> allowedPackagesSet = getSetFromString(allowedPackagesString);
|
||||
HashSet<String> disallowedPackagesSet = getSetFromString(disallowedPackagesString);
|
||||
|
||||
if (enabled) {
|
||||
allowedPackagesSet.add(crossProfilePackage);
|
||||
@@ -592,9 +592,9 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
|
||||
String.join(",", disallowedPackagesSet));
|
||||
}
|
||||
|
||||
private Set<String> getSetFromString(String packages) {
|
||||
private HashSet<String> 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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user