summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorWinson <chiuwinson@google.com>2021-04-12 16:50:12 -0700
committerWinson <chiuwinson@google.com>2021-04-12 16:58:59 -0700
commit64ee7ff095ce2f10531a8f260180df64133029ec (patch)
tree62a3aef66761504da10a02432597474d92c3caa4 /core/java/android
parentc5b6959fb922b430d48015c80f1e322b08f267ce (diff)
Change getOwnersForDomain to SortedSet
Kept the lowest to highest ordering priority, under the assumption that less has to change in the UI/consumer if the highest priority is popped, since it will just take it off the end without shifting any elements. The ordering is documented. Bug: 184891031 Test: atest DomainVerificationManagerApiTest Change-Id: I6ea5908e356ee96aa440650f3d5025319c195266
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/pm/verify/domain/DomainVerificationManager.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/java/android/content/pm/verify/domain/DomainVerificationManager.java b/core/java/android/content/pm/verify/domain/DomainVerificationManager.java
index 33920c676170..adc668f8fa02 100644
--- a/core/java/android/content/pm/verify/domain/DomainVerificationManager.java
+++ b/core/java/android/content/pm/verify/domain/DomainVerificationManager.java
@@ -34,6 +34,8 @@ import com.android.internal.util.CollectionUtils;
import java.util.List;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import java.util.UUID;
/**
@@ -346,17 +348,22 @@ public final class DomainVerificationManager {
* an Intent with that domain. That will be decided by the set of apps which
* are the highest priority level, ignoring all lower priority levels.
*
- * By default the list will be returned ordered from lowest to highest
- * priority.
+ * The set will be ordered from lowest to highest priority.
*
* @hide
*/
@SystemApi
@NonNull
@RequiresPermission(android.Manifest.permission.UPDATE_DOMAIN_VERIFICATION_USER_SELECTION)
- public List<DomainOwner> getOwnersForDomain(@NonNull String domain) {
+ public SortedSet<DomainOwner> getOwnersForDomain(@NonNull String domain) {
try {
- return mDomainVerificationManager.getOwnersForDomain(domain, mContext.getUserId());
+ final List<DomainOwner> orderedList = mDomainVerificationManager.getOwnersForDomain(
+ domain, mContext.getUserId());
+ SortedSet<DomainOwner> set = new TreeSet<>(
+ (first, second) -> Integer.compare(orderedList.indexOf(first),
+ orderedList.indexOf(second)));
+ set.addAll(orderedList);
+ return set;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}