Fixes wildcard intent filter matching logic am: 28a68105e1 am: 6acd3edcbc am: 0ba0528bbb

Change-Id: Iee934a123671a4159bd99650ac7881fe3103478f
This commit is contained in:
Patrick Baumann
2020-03-19 21:10:26 +00:00
committed by Automerger Merge Worker
2 changed files with 22 additions and 5 deletions

View File

@@ -274,8 +274,13 @@ public class IntentFilter implements Parcelable {
*/
public static final String SCHEME_HTTPS = "https";
/** The value to indicate a wildcard for incoming match arguments. */
private static final String WILDCARD = "*";
/**
* The value to indicate a wildcard for incoming match arguments.
* @hide
*/
public static final String WILDCARD = "*";
/** @hide */
public static final String WILDCARD_PATH = "/" + WILDCARD;
private int mPriority;
@UnsupportedAppUsage
@@ -1439,7 +1444,7 @@ public class IntentFilter implements Parcelable {
if (mDataPaths == null) {
return false;
}
if (wildcardSupported && WILDCARD.equals(data)) {
if (wildcardSupported && WILDCARD_PATH.equals(data)) {
return true;
}
final int numDataPaths = mDataPaths.size();

View File

@@ -40,7 +40,6 @@ import android.content.pm.ConfigurationInfo;
import android.content.pm.FeatureGroupInfo;
import android.content.pm.FeatureInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser.PackageParserException;
@@ -1390,7 +1389,7 @@ public class ParsingPackageUtils {
Uri data = null;
String dataType = null;
String host = "";
String host = IntentFilter.WILDCARD;
final int numActions = intentInfo.countActions();
final int numSchemes = intentInfo.countDataSchemes();
final int numTypes = intentInfo.countDataTypes();
@@ -1421,10 +1420,23 @@ public class ParsingPackageUtils {
data = new Uri.Builder()
.scheme(intentInfo.getDataScheme(0))
.authority(host)
.path(IntentFilter.WILDCARD_PATH)
.build();
}
if (numTypes == 1) {
dataType = intentInfo.getDataType(0);
// The dataType may have had the '/' removed for the dynamic mimeType feature.
// If we detect that case, we add the * back.
if (!dataType.contains("/")) {
dataType = dataType + "/*";
}
if (data == null) {
data = new Uri.Builder()
.scheme("content")
.authority(IntentFilter.WILDCARD)
.path(IntentFilter.WILDCARD_PATH)
.build();
}
}
intent.setDataAndType(data, dataType);
if (numActions == 1) {