Merge "Fix UnsupportedOperationException from immutable set" into main
This commit is contained in:
@@ -72,9 +72,9 @@ import com.android.settingslib.RestrictedLockUtils;
|
|||||||
import com.android.settingslib.RestrictedSwitchPreference;
|
import com.android.settingslib.RestrictedSwitchPreference;
|
||||||
import com.android.settingslib.widget.LayoutPreference;
|
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.Optional;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class InteractAcrossProfilesDetails extends AppInfoBase
|
public class InteractAcrossProfilesDetails extends AppInfoBase
|
||||||
implements Preference.OnPreferenceClickListener {
|
implements Preference.OnPreferenceClickListener {
|
||||||
@@ -571,8 +571,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
|
|||||||
String disallowedPackagesString = Settings.Global.getString(getContentResolver(),
|
String disallowedPackagesString = Settings.Global.getString(getContentResolver(),
|
||||||
CONNECTED_APPS_DISALLOWED_PACKAGES);
|
CONNECTED_APPS_DISALLOWED_PACKAGES);
|
||||||
|
|
||||||
Set<String> allowedPackagesSet = getSetFromString(allowedPackagesString);
|
HashSet<String> allowedPackagesSet = getSetFromString(allowedPackagesString);
|
||||||
Set<String> disallowedPackagesSet = getSetFromString(disallowedPackagesString);
|
HashSet<String> disallowedPackagesSet = getSetFromString(disallowedPackagesString);
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
allowedPackagesSet.add(crossProfilePackage);
|
allowedPackagesSet.add(crossProfilePackage);
|
||||||
@@ -592,9 +592,9 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
|
|||||||
String.join(",", disallowedPackagesSet));
|
String.join(",", disallowedPackagesSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> getSetFromString(String packages) {
|
private HashSet<String> getSetFromString(String packages) {
|
||||||
return Optional.ofNullable(packages)
|
return Optional.ofNullable(packages)
|
||||||
.map(pkg -> Set.of(pkg.split(",")))
|
.map(pkg -> new HashSet<>(Arrays.asList(pkg.split(","))))
|
||||||
.orElse(Collections.emptySet());
|
.orElseGet(HashSet::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user