summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/current.txt5
-rw-r--r--core/java/android/content/IntentFilter.java17
-rw-r--r--core/java/android/content/pm/parsing/component/ParsedIntentInfoUtils.java26
-rw-r--r--core/java/android/content/pm/parsing/component/ParsedProviderUtils.java38
-rw-r--r--core/java/android/os/PatternMatcher.java11
-rw-r--r--core/res/res/values/attrs_manifest.xml48
-rw-r--r--core/res/res/values/public.xml4
7 files changed, 136 insertions, 13 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 69133283aee7..a1a2314163eb 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -1054,9 +1054,11 @@ package android {
field public static final int parentActivityName = 16843687; // 0x10103a7
field @Deprecated public static final int password = 16843100; // 0x101015c
field public static final int path = 16842794; // 0x101002a
+ field public static final int pathAdvancedPattern = 16844318; // 0x101061e
field public static final int pathData = 16843781; // 0x1010405
field public static final int pathPattern = 16842796; // 0x101002c
field public static final int pathPrefix = 16842795; // 0x101002b
+ field public static final int pathSuffix = 16844316; // 0x101061c
field public static final int patternPathData = 16843978; // 0x10104ca
field public static final int permission = 16842758; // 0x1010006
field public static final int permissionFlags = 16843719; // 0x10103c7
@@ -1290,8 +1292,10 @@ package android {
field public static final int spotShadowAlpha = 16843967; // 0x10104bf
field public static final int src = 16843033; // 0x1010119
field public static final int ssp = 16843747; // 0x10103e3
+ field public static final int sspAdvancedPattern = 16844319; // 0x101061f
field public static final int sspPattern = 16843749; // 0x10103e5
field public static final int sspPrefix = 16843748; // 0x10103e4
+ field public static final int sspSuffix = 16844317; // 0x101061d
field public static final int stackFromBottom = 16843005; // 0x10100fd
field public static final int stackViewStyle = 16843838; // 0x101043e
field public static final int starStyle = 16842882; // 0x1010082
@@ -30943,6 +30947,7 @@ package android.os {
field public static final int PATTERN_LITERAL = 0; // 0x0
field public static final int PATTERN_PREFIX = 1; // 0x1
field public static final int PATTERN_SIMPLE_GLOB = 2; // 0x2
+ field public static final int PATTERN_SUFFIX = 4; // 0x4
}
public final class PersistableBundle extends android.os.BaseBundle implements java.lang.Cloneable android.os.Parcelable {
diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java
index f0633591f16c..c5badb9148ea 100644
--- a/core/java/android/content/IntentFilter.java
+++ b/core/java/android/content/IntentFilter.java
@@ -150,6 +150,7 @@ public class IntentFilter implements Parcelable {
private static final String AGLOB_STR = "aglob";
private static final String SGLOB_STR = "sglob";
private static final String PREFIX_STR = "prefix";
+ private static final String SUFFIX_STR = "suffix";
private static final String LITERAL_STR = "literal";
private static final String PATH_STR = "path";
private static final String PORT_STR = "port";
@@ -1226,7 +1227,8 @@ public class IntentFilter implements Parcelable {
* path, or a simple pattern, depending on <var>type</var>.
* @param type Determines how <var>ssp</var> will be compared to
* determine a match: either {@link PatternMatcher#PATTERN_LITERAL},
- * {@link PatternMatcher#PATTERN_PREFIX}, or
+ * {@link PatternMatcher#PATTERN_PREFIX},
+ * {@link PatternMatcher#PATTERN_SUFFIX}, or
* {@link PatternMatcher#PATTERN_SIMPLE_GLOB}.
*
* @see #matchData
@@ -1419,7 +1421,8 @@ public class IntentFilter implements Parcelable {
* path, or a simple pattern, depending on <var>type</var>.
* @param type Determines how <var>path</var> will be compared to
* determine a match: either {@link PatternMatcher#PATTERN_LITERAL},
- * {@link PatternMatcher#PATTERN_PREFIX}, or
+ * {@link PatternMatcher#PATTERN_PREFIX},
+ * {@link PatternMatcher#PATTERN_SUFFIX}, or
* {@link PatternMatcher#PATTERN_SIMPLE_GLOB}.
*
* @see #matchData
@@ -1920,6 +1923,9 @@ public class IntentFilter implements Parcelable {
case PatternMatcher.PATTERN_ADVANCED_GLOB:
serializer.attribute(null, AGLOB_STR, pe.getPath());
break;
+ case PatternMatcher.PATTERN_SUFFIX:
+ serializer.attribute(null, SUFFIX_STR, pe.getPath());
+ break;
}
serializer.endTag(null, SSP_STR);
}
@@ -1950,6 +1956,9 @@ public class IntentFilter implements Parcelable {
case PatternMatcher.PATTERN_ADVANCED_GLOB:
serializer.attribute(null, AGLOB_STR, pe.getPath());
break;
+ case PatternMatcher.PATTERN_SUFFIX:
+ serializer.attribute(null, SUFFIX_STR, pe.getPath());
+ break;
}
serializer.endTag(null, PATH_STR);
}
@@ -2057,6 +2066,8 @@ public class IntentFilter implements Parcelable {
addDataSchemeSpecificPart(ssp, PatternMatcher.PATTERN_SIMPLE_GLOB);
} else if ((ssp=parser.getAttributeValue(null, AGLOB_STR)) != null) {
addDataSchemeSpecificPart(ssp, PatternMatcher.PATTERN_ADVANCED_GLOB);
+ } else if ((ssp=parser.getAttributeValue(null, SUFFIX_STR)) != null) {
+ addDataSchemeSpecificPart(ssp, PatternMatcher.PATTERN_SUFFIX);
}
} else if (tagName.equals(AUTH_STR)) {
String host = parser.getAttributeValue(null, HOST_STR);
@@ -2074,6 +2085,8 @@ public class IntentFilter implements Parcelable {
addDataPath(path, PatternMatcher.PATTERN_SIMPLE_GLOB);
} else if ((path=parser.getAttributeValue(null, AGLOB_STR)) != null) {
addDataPath(path, PatternMatcher.PATTERN_ADVANCED_GLOB);
+ } else if ((path=parser.getAttributeValue(null, SUFFIX_STR)) != null) {
+ addDataPath(path, PatternMatcher.PATTERN_SUFFIX);
}
} else {
Log.w("IntentFilter", "Unknown tag parsing IntentFilter: " + tagName);
diff --git a/core/java/android/content/pm/parsing/component/ParsedIntentInfoUtils.java b/core/java/android/content/pm/parsing/component/ParsedIntentInfoUtils.java
index c0536bb7eb10..a7a5c245914c 100644
--- a/core/java/android/content/pm/parsing/component/ParsedIntentInfoUtils.java
+++ b/core/java/android/content/pm/parsing/component/ParsedIntentInfoUtils.java
@@ -209,6 +209,25 @@ public class ParsedIntentInfoUtils {
PatternMatcher.PATTERN_SIMPLE_GLOB);
}
+ str = sa.getNonConfigurationString(
+ R.styleable.AndroidManifestData_sspAdvancedPattern, 0);
+ if (str != null) {
+ if (!allowGlobs) {
+ return input.error(
+ "sspAdvancedPattern not allowed here; ssp must be literal");
+ }
+ intentInfo.addDataSchemeSpecificPart(str,
+ PatternMatcher.PATTERN_ADVANCED_GLOB);
+ }
+
+ str = sa.getNonConfigurationString(
+ R.styleable.AndroidManifestData_sspSuffix, 0);
+ if (str != null) {
+ intentInfo.addDataSchemeSpecificPart(str,
+ PatternMatcher.PATTERN_SUFFIX);
+ }
+
+
String host = sa.getNonConfigurationString(
R.styleable.AndroidManifestData_host, 0);
String port = sa.getNonConfigurationString(
@@ -249,6 +268,13 @@ public class ParsedIntentInfoUtils {
intentInfo.addDataPath(str, PatternMatcher.PATTERN_ADVANCED_GLOB);
}
+ str = sa.getNonConfigurationString(
+ R.styleable.AndroidManifestData_pathSuffix, 0);
+ if (str != null) {
+ intentInfo.addDataPath(str, PatternMatcher.PATTERN_SUFFIX);
+ }
+
+
return input.success(null);
} finally {
sa.recycle();
diff --git a/core/java/android/content/pm/parsing/component/ParsedProviderUtils.java b/core/java/android/content/pm/parsing/component/ParsedProviderUtils.java
index 90691f1686aa..4deab56c3210 100644
--- a/core/java/android/content/pm/parsing/component/ParsedProviderUtils.java
+++ b/core/java/android/content/pm/parsing/component/ParsedProviderUtils.java
@@ -211,22 +211,34 @@ public class ParsedProviderUtils {
R.styleable.AndroidManifestGrantUriPermission);
try {
String name = parser.getName();
- // Pattern has priority over prefix over literal path
+ // Pattern has priority over pre/suffix over literal path
PatternMatcher pa = null;
String str = sa.getNonConfigurationString(
- R.styleable.AndroidManifestGrantUriPermission_pathPattern, 0);
+ R.styleable.AndroidManifestGrantUriPermission_pathAdvancedPattern, 0);
if (str != null) {
- pa = new PatternMatcher(str, PatternMatcher.PATTERN_SIMPLE_GLOB);
+ pa = new PatternMatcher(str, PatternMatcher.PATTERN_ADVANCED_GLOB);
} else {
str = sa.getNonConfigurationString(
- R.styleable.AndroidManifestGrantUriPermission_pathPrefix, 0);
+ R.styleable.AndroidManifestGrantUriPermission_pathPattern, 0);
if (str != null) {
- pa = new PatternMatcher(str, PatternMatcher.PATTERN_PREFIX);
+ pa = new PatternMatcher(str, PatternMatcher.PATTERN_SIMPLE_GLOB);
} else {
str = sa.getNonConfigurationString(
- R.styleable.AndroidManifestGrantUriPermission_path, 0);
+ R.styleable.AndroidManifestGrantUriPermission_pathPrefix, 0);
if (str != null) {
- pa = new PatternMatcher(str, PatternMatcher.PATTERN_LITERAL);
+ pa = new PatternMatcher(str, PatternMatcher.PATTERN_PREFIX);
+ } else {
+ str = sa.getNonConfigurationString(
+ R.styleable.AndroidManifestGrantUriPermission_pathSuffix, 0);
+ if (str != null) {
+ pa = new PatternMatcher(str, PatternMatcher.PATTERN_SUFFIX);
+ } else {
+ str = sa.getNonConfigurationString(
+ R.styleable.AndroidManifestGrantUriPermission_path, 0);
+ if (str != null) {
+ pa = new PatternMatcher(str, PatternMatcher.PATTERN_LITERAL);
+ }
+ }
}
}
}
@@ -318,10 +330,18 @@ public class ParsedProviderUtils {
pa = new PathPermission(path, PatternMatcher.PATTERN_PREFIX, readPermission,
writePermission);
} else {
- path = sa.getNonConfigurationString(R.styleable.AndroidManifestPathPermission_path, 0);
+ path = sa.getNonConfigurationString(
+ R.styleable.AndroidManifestPathPermission_pathSuffix, 0);
if (path != null) {
- pa = new PathPermission(path, PatternMatcher.PATTERN_LITERAL,
+ pa = new PathPermission(path, PatternMatcher.PATTERN_SUFFIX,
readPermission, writePermission);
+ } else {
+ path = sa.getNonConfigurationString(
+ R.styleable.AndroidManifestPathPermission_path, 0);
+ if (path != null) {
+ pa = new PathPermission(path, PatternMatcher.PATTERN_LITERAL,
+ readPermission, writePermission);
+ }
}
}
}
diff --git a/core/java/android/os/PatternMatcher.java b/core/java/android/os/PatternMatcher.java
index 428405b74004..631c98af07bf 100644
--- a/core/java/android/os/PatternMatcher.java
+++ b/core/java/android/os/PatternMatcher.java
@@ -61,6 +61,12 @@ public class PatternMatcher implements Parcelable {
*/
public static final int PATTERN_ADVANCED_GLOB = 3;
+ /**
+ * Pattern type: the given pattern must match the
+ * end of the string it is tested against.
+ */
+ public static final int PATTERN_SUFFIX = 4;
+
// token types for advanced matching
private static final int TOKEN_TYPE_LITERAL = 0;
private static final int TOKEN_TYPE_ANY = 1;
@@ -128,6 +134,9 @@ public class PatternMatcher implements Parcelable {
case PATTERN_ADVANCED_GLOB:
type = "ADVANCED: ";
break;
+ case PATTERN_SUFFIX:
+ type = "SUFFIX: ";
+ break;
}
return "PatternMatcher{" + type + mPattern + "}";
}
@@ -179,6 +188,8 @@ public class PatternMatcher implements Parcelable {
return matchGlobPattern(pattern, match);
} else if (type == PATTERN_ADVANCED_GLOB) {
return matchAdvancedPattern(parsedPattern, match);
+ } else if (type == PATTERN_SUFFIX) {
+ return match.endsWith(pattern);
}
return false;
}
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 060c8b1144e5..0185714dc342 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -2494,7 +2494,11 @@
<code>grant-uri-permission</code> tag, a child of the
{@link #AndroidManifestProvider provider} tag, describing a specific
URI path that can be granted as a permission. This tag can be
- specified multiple time to supply multiple paths. -->
+ specified multiple time to supply multiple paths. If multiple
+ path matching attributes are supplied, they will be evaluated in the
+ following order with the first attribute being the only one honored:
+ <code>pathAdvancedPattern</code>, <code>pathPattern</code>,
+ <code>pathPrefix</code>, <code>pathSuffix</code>, <code>path</code>. -->
<declare-styleable name="AndroidManifestGrantUriPermission" parent="AndroidManifestProvider">
<!-- Specify a URI path that must exactly match, as per
{@link android.os.PatternMatcher} with
@@ -2514,18 +2518,37 @@
"\\\\". This is basically the same as what you would need to
write if constructing the string in Java code. -->
<attr name="pathPattern" format="string" />
+ <!-- Specify a URI path that matches an advanced pattern, as per
+ {@link android.os.PatternMatcher} with
+ {@link android.os.PatternMatcher#PATTERN_ADVANCED_GLOB}.
+ Note that because '\' is used as an escape character when
+ reading the string from XML (before it is parsed as a pattern),
+ you will need to double-escape: for example a literal "*" would
+ be written as "\\*" and a literal "\" would be written as
+ "\\\\". This is basically the same as what you would need to
+ write if constructing the string in Java code. -->
+ <attr name="pathAdvancedPattern" format="string"/>
+ <!-- Specify a URI path that must be a suffix to match, as per
+ {@link android.os.PatternMatcher} with
+ {@link android.os.PatternMatcher#PATTERN_SUFFIX}. -->
+ <attr name="pathSuffix" format="string" />
</declare-styleable>
<!-- Attributes that can be supplied in an AndroidManifest.xml
<code>path-permission</code> tag, a child of the
{@link #AndroidManifestProvider provider} tag, describing a permission
that allows access to a specific path in the provider. This tag can be
- specified multiple time to supply multiple paths. -->
+ specified multiple time to supply multiple paths. If multiple
+ path matching attributes are supplied, they will be evaluated in the
+ following order with the first attribute being the only one honored:
+ <code>pathAdvancedPattern</code>, <code>pathPattern</code>,
+ <code>pathPrefix</code>, <code>pathSuffix</code>, <code>path</code>.-->
<declare-styleable name="AndroidManifestPathPermission" parent="AndroidManifestProvider">
<attr name="path" />
<attr name="pathPrefix" />
<attr name="pathPattern" />
<attr name="pathAdvancedPattern" format="string"/>
+ <attr name="pathSuffix" />
<attr name="permission" />
<attr name="readPermission" />
<attr name="writePermission" />
@@ -2977,6 +3000,22 @@
"\\\\". This is basically the same as what you would need to
write if constructing the string in Java code. -->
<attr name="sspPattern" format="string" />
+ <!-- Specify a URI scheme specific part that matches an advanced pattern, as per
+ {@link android.content.IntentFilter#addDataSchemeSpecificPart
+ IntentFilter.addDataSchemeSpecificPart()} with
+ {@link android.os.PatternMatcher#PATTERN_ADVANCED_GLOB}.
+ Note that because '\' is used as an escape character when
+ reading the string from XML (before it is parsed as a pattern),
+ you will need to double-escape: for example a literal "*" would
+ be written as "\\*" and a literal "\" would be written as
+ "\\\\". This is basically the same as what you would need to
+ write if constructing the string in Java code. -->
+ <attr name="sspAdvancedPattern" format="string" />
+ <!-- Specify a URI scheme specific part that must be a suffix to match, as per
+ {@link android.content.IntentFilter#addDataSchemeSpecificPart
+ IntentFilter.addDataSchemeSpecificPart()} with
+ {@link android.os.PatternMatcher#PATTERN_SUFFIX}. -->
+ <attr name="sspSuffix" format="string" />
<!-- Specify a URI authority host that is handled, as per
{@link android.content.IntentFilter#addDataAuthority
IntentFilter.addDataAuthority()}.
@@ -3021,6 +3060,11 @@
"\\\\". This is basically the same as what you would need to
write if constructing the string in Java code. -->
<attr name="pathAdvancedPattern" />
+ <!-- Specify a URI path that must be a suffix to match, as per
+ {@link android.content.IntentFilter#addDataPath
+ IntentFilter.addDataPath()} with
+ {@link android.os.PatternMatcher#PATTERN_SUFFIX}. -->
+ <attr name="pathSuffix" />
</declare-styleable>
<!-- Attributes that can be supplied in an AndroidManifest.xml
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 095843467f9b..b3b241f3f062 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -3050,6 +3050,10 @@
<!-- @hide -->
<public name="windowBackgroundBlurRadius"/>
<public name="requireDeviceScreenOn" />
+ <public name="pathSuffix" />
+ <public name="sspSuffix" />
+ <public name="pathAdvancedPattern" />
+ <public name="sspAdvancedPattern" />
</public-group>
<public-group type="drawable" first-id="0x010800b5">