am 1af5fe23: Merge "Require that verified intent filters only have http/https <data> decls" into mnc-dev

* commit '1af5fe230835881fee04ce706ddc71181e014db6':
  Require that verified intent filters only have http/https <data> decls
This commit is contained in:
Christopher Tate
2015-06-24 20:41:07 +00:00
committed by Android Git Automerger
2 changed files with 27 additions and 11 deletions

View File

@@ -16,7 +16,6 @@
package android.content; package android.content;
import android.content.pm.PackageParser;
import android.net.Uri; import android.net.Uri;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
@@ -534,13 +533,15 @@ public class IntentFilter implements Parcelable {
*/ */
public final boolean handleAllWebDataURI() { public final boolean handleAllWebDataURI() {
return hasCategory(Intent.CATEGORY_APP_BROWSER) || return hasCategory(Intent.CATEGORY_APP_BROWSER) ||
(hasWebDataURI() && countDataAuthorities() == 0); (hasOnlyWebDataURI() && countDataAuthorities() == 0);
} }
/** /**
* Return if this filter has any HTTP or HTTPS data URI or not. * Return if this filter handles only HTTP or HTTPS data URIs.
* *
* @return True if the filter has any HTTP or HTTPS data URI. False otherwise. * @return True if the filter handles ACTION_VIEW/CATEGORY_BROWSABLE,
* has at least one HTTP or HTTPS data URI pattern defined, and does not
* define any non-http/https data URI patterns.
* *
* This will check if if the Intent action is {@link android.content.Intent#ACTION_VIEW} and * This will check if if the Intent action is {@link android.content.Intent#ACTION_VIEW} and
* the Intent category is {@link android.content.Intent#CATEGORY_BROWSABLE} and the Intent * the Intent category is {@link android.content.Intent#CATEGORY_BROWSABLE} and the Intent
@@ -548,10 +549,26 @@ public class IntentFilter implements Parcelable {
* *
* @hide * @hide
*/ */
public final boolean hasWebDataURI() { public final boolean hasOnlyWebDataURI() {
return hasAction(Intent.ACTION_VIEW) && // Require ACTION_VIEW, CATEGORY_BROWSEABLE, and at least one scheme
hasCategory(Intent.CATEGORY_BROWSABLE) && if (!hasAction(Intent.ACTION_VIEW)
(hasDataScheme(SCHEME_HTTP) || hasDataScheme(SCHEME_HTTPS)); || !hasCategory(Intent.CATEGORY_BROWSABLE)
|| mDataSchemes == null
|| mDataSchemes.size() == 0) {
return false;
}
// Now allow only the schemes "http" and "https"
final int N = mDataSchemes.size();
for (int i = 0; i < N; i++) {
final String scheme = mDataSchemes.get(i);
if (!SCHEME_HTTP.equals(scheme) && !SCHEME_HTTPS.equals(scheme)) {
return false;
}
}
// Everything passed, so it's an only-web-URIs filter
return true;
} }
/** /**
@@ -568,7 +585,7 @@ public class IntentFilter implements Parcelable {
* @hide * @hide
*/ */
public final boolean needsVerification() { public final boolean needsVerification() {
return hasWebDataURI() && getAutoVerify(); return getAutoVerify() && hasOnlyWebDataURI();
} }
/** /**

View File

@@ -12020,8 +12020,7 @@ public class PackageManagerService extends IPackageManager.Stub {
final int verificationId = mIntentFilterVerificationToken++; final int verificationId = mIntentFilterVerificationToken++;
for (PackageParser.Activity a : pkg.activities) { for (PackageParser.Activity a : pkg.activities) {
for (ActivityIntentInfo filter : a.intents) { for (ActivityIntentInfo filter : a.intents) {
boolean needsFilterVerification = filter.hasWebDataURI(); if (filter.hasOnlyWebDataURI() && needsNetworkVerificationLPr(filter)) {
if (needsFilterVerification && needsNetworkVerificationLPr(filter)) {
if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG,
"Verification needed for IntentFilter:" + filter.toString()); "Verification needed for IntentFilter:" + filter.toString());
mIntentFilterVerifier.addOneIntentFilterVerification( mIntentFilterVerifier.addOneIntentFilterVerification(