From f2fec45280682b0b2531781d8f9bd34f64fe164d Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Tue, 19 May 2015 14:50:54 -0700 Subject: [PATCH] Add IntentFilter auto verification - part 12 - again tune Intent resolution candidates filtering: first add always list if not empty, other wise add undefined and browsers. If the list is still empty at the end, then add all the initial candidates. See bug #19628271 Change-Id: I21f5313daf7bec1049c1e7c08275c825855d2935 --- .../android/server/pm/PackageManagerService.java | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index eaaee93f7c9b..040ae59c2f3d 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -4124,6 +4124,7 @@ public class PackageManagerService extends IPackageManager.Stub { final int userId = UserHandle.getCallingUserId(); ArrayList result = new ArrayList(); + ArrayList alwaysList = new ArrayList(); ArrayList undefinedList = new ArrayList(); ArrayList neverList = new ArrayList(); ArrayList matchAllList = new ArrayList(); @@ -4146,27 +4147,22 @@ public class PackageManagerService extends IPackageManager.Stub { // Try to get the status from User settings first int status = getDomainVerificationStatusLPr(ps, userId); if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) { - result.add(info); + alwaysList.add(info); } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER) { neverList.add(info); - } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED) { + } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED || + status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK) { undefinedList.add(info); } } } - // Add all undefined Apps as we want them to appear in the Disambiguation dialog. - result.addAll(undefinedList); - // If there is nothing selected, add all candidates and remove the ones that the User - // has explicitely put into the INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER state and - // also remove Browser Apps ones. - // If there is still none after this pass, add all Browser Apps and - // let the User decide with the Disambiguation dialog if there are several ones. - if (result.size() == 0) { - result.addAll(candidates); - } - result.removeAll(neverList); - result.removeAll(matchAllList); - if (result.size() == 0) { + // First try to add the "always" if there is any + if (alwaysList.size() > 0) { + result.addAll(alwaysList); + } else { + // Add all undefined Apps as we want them to appear in the Disambiguation dialog. + result.addAll(undefinedList); + // Also add Browsers (all of them or only the default one) if ((flags & MATCH_ALL) != 0) { result.addAll(matchAllList); } else { @@ -4191,6 +4187,13 @@ public class PackageManagerService extends IPackageManager.Stub { result.addAll(matchAllList); } } + + // If there is nothing selected, add all candidates and remove the ones that the User + // has explicitely put into the INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER state + if (result.size() == 0) { + result.addAll(candidates); + result.removeAll(neverList); + } } } if (DEBUG_PREFERRED) { -- 2.11.0