diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2015-04-29 00:42:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-29 00:42:43 +0000 |
commit | 46fc110104f3017f23abb397ca817db2be39f1a2 (patch) | |
tree | 0a827e6f4fec5a524c00d1733da0c7de24f62097 | |
parent | d6db7eacc983e22eb88fc7b465f290670127569a (diff) | |
parent | 9f7e39fc9d278642a29df48daf44dceff11acd17 (diff) | |
download | frameworks_base-46fc110104f3017f23abb397ca817db2be39f1a2.zip frameworks_base-46fc110104f3017f23abb397ca817db2be39f1a2.tar.gz frameworks_base-46fc110104f3017f23abb397ca817db2be39f1a2.tar.bz2 |
Merge "Use Default Browser App for IntentResolution when needed" into mnc-dev
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | api/system-current.txt | 1 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 13 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 60 |
4 files changed, 63 insertions, 12 deletions
diff --git a/api/current.txt b/api/current.txt index 73829e6..43cae61 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9409,6 +9409,7 @@ package android.content.pm { field public static final int GET_SIGNATURES = 64; // 0x40 field public static final int GET_UNINSTALLED_PACKAGES = 8192; // 0x2000 field public static final int GET_URI_PERMISSION_PATTERNS = 2048; // 0x800 + field public static final int MATCH_ALL = 131072; // 0x20000 field public static final int MATCH_DEFAULT_ONLY = 65536; // 0x10000 field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80L field public static final int PERMISSION_DENIED = -1; // 0xffffffff diff --git a/api/system-current.txt b/api/system-current.txt index d74bf6e..ead078a 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9702,6 +9702,7 @@ package android.content.pm { field public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; // 0xffffff99 field public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; // 0xffffff9a field public static final int INSTALL_SUCCEEDED = 1; // 0x1 + field public static final int MATCH_ALL = 131072; // 0x20000 field public static final int MATCH_DEFAULT_ONLY = 65536; // 0x10000 field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80L field public static final int PERMISSION_DENIED = -1; // 0xffffffff diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index e1c271d..f01ca09 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -209,7 +209,14 @@ public abstract class PackageManager { * matching. This is a synonym for including the CATEGORY_DEFAULT in your * supplied Intent. */ - public static final int MATCH_DEFAULT_ONLY = 0x00010000; + public static final int MATCH_DEFAULT_ONLY = 0x00010000; + + /** + * Querying flag: if set and if the platform is doing any filtering of the results, then + * the filtering will not happen. This is a synonym for saying that all results should + * be returned. + */ + public static final int MATCH_ALL = 0x00020000; /** * Flag for {@link addCrossProfileIntentFilter}: if this flag is set: @@ -2637,6 +2644,8 @@ public abstract class PackageManager { * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. * + * You can also set {@link #MATCH_ALL} for preventing the filtering of the results. + * * @return A List<ResolveInfo> containing one entry for each matching * Activity. These are ordered from best to worst match -- that * is, the first item in the list is what is returned by @@ -2658,6 +2667,8 @@ public abstract class PackageManager { * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. * + * You can also set {@link #MATCH_ALL} for preventing the filtering of the results. + * * @return A List<ResolveInfo> containing one entry for each matching * Activity. These are ordered from best to worst match -- that * is, the first item in the list is what is returned by diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index f087c33..6c18e25 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -49,6 +49,7 @@ import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATIO import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED; +import static android.content.pm.PackageManager.MATCH_ALL; import static android.content.pm.PackageManager.MOVE_FAILED_DOESNT_EXIST; import static android.content.pm.PackageManager.MOVE_FAILED_INTERNAL_ERROR; import static android.content.pm.PackageManager.MOVE_FAILED_OPERATION_PENDING; @@ -2274,6 +2275,13 @@ public class PackageManagerService extends IPackageManager.Stub { } continue; } + if (!pkg.isSystemApp()) { + if (logging) { + Slog.d(TAG, "No priming domain verifications for a non system package : " + + packageName); + } + continue; + } for (PackageParser.Activity a : pkg.activities) { for (ActivityIntentInfo filter : a.intents) { if (hasValidDomains(filter, false)) { @@ -2281,7 +2289,7 @@ public class PackageManagerService extends IPackageManager.Stub { } } } - if (allHosts.size() > 0) { + if (allHosts.size() == 0) { allHosts.add("*"); } IntentFilterVerificationInfo ivi = @@ -3939,7 +3947,7 @@ public class PackageManagerService extends IPackageManager.Stub { } result = filterIfNotPrimaryUser(result, userId); if (result.size() > 1 && hasWebURI(intent)) { - return filterCandidatesWithDomainPreferedActivitiesLPr(result); + return filterCandidatesWithDomainPreferedActivitiesLPr(flags, result); } return result; } @@ -3984,7 +3992,7 @@ public class PackageManagerService extends IPackageManager.Stub { } private List<ResolveInfo> filterCandidatesWithDomainPreferedActivitiesLPr( - List<ResolveInfo> candidates) { + int flags, List<ResolveInfo> candidates) { if (DEBUG_PREFERRED) { Slog.v("TAG", "Filtering results with prefered activities. Candidates count: " + candidates.size()); @@ -4004,6 +4012,11 @@ public class PackageManagerService extends IPackageManager.Stub { String packageName = info.activityInfo.packageName; PackageSetting ps = mSettings.mPackages.get(packageName); if (ps != null) { + // Add to the special match all list (Browser use case) + if (info.handleAllWebDataURI) { + matchAllList.add(info); + continue; + } // Try to get the status from User settings first int status = getDomainVerificationStatusLPr(ps, userId); if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) { @@ -4013,10 +4026,6 @@ public class PackageManagerService extends IPackageManager.Stub { } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED) { undefinedList.add(info); } - // Add to the special match all list (Browser use case) - if (info.handleAllWebDataURI) { - matchAllList.add(info); - } } } // If there is nothing selected, add all candidates and remove the ones that the User @@ -4031,7 +4040,30 @@ public class PackageManagerService extends IPackageManager.Stub { result.removeAll(matchAllList); if (result.size() == 0) { result.addAll(undefinedList); - result.addAll(matchAllList); + if ((flags & MATCH_ALL) != 0) { + result.addAll(matchAllList); + } else { + // Try to add the Default Browser if we can + final String defaultBrowserPackageName = getDefaultBrowserPackageName( + UserHandle.myUserId()); + if (!TextUtils.isEmpty(defaultBrowserPackageName)) { + boolean defaultBrowserFound = false; + final int browserCount = matchAllList.size(); + for (int n=0; n<browserCount; n++) { + ResolveInfo browser = matchAllList.get(n); + if (browser.activityInfo.packageName.equals(defaultBrowserPackageName)) { + result.add(browser); + defaultBrowserFound = true; + break; + } + } + if (!defaultBrowserFound) { + result.addAll(matchAllList); + } + } else { + result.addAll(matchAllList); + } + } } } if (DEBUG_PREFERRED) { @@ -11331,10 +11363,16 @@ public class PackageManagerService extends IPackageManager.Stub { verifierUid, userId, verificationId, filter, packageName); count++; } else if (!needsFilterVerification) { - Slog.d(TAG, "No verification needed for IntentFilter:" - + filter.toString()); + Slog.d(TAG, "No verification needed for IntentFilter:" + filter.toString()); if (hasValidDomains(filter)) { - allHosts.addAll(filter.getHostsList()); + ArrayList<String> hosts = filter.getHostsList(); + if (hosts.size() > 0) { + allHosts.addAll(hosts); + } else { + if (allHosts.isEmpty()) { + allHosts.add("*"); + } + } } } else { Slog.d(TAG, "Verification already done for IntentFilter:" |