Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a6b8d43 authored by Patrick Baumann's avatar Patrick Baumann Committed by Android (Google) Code Review
Browse files

Merge "Add support for pathSuffix"

parents 68c395f4 8cbf2e5a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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 {
+15 −2
Original line number Diff line number Diff line
@@ -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);
+26 −0
Original line number Diff line number Diff line
@@ -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();
+29 −9
Original line number Diff line number Diff line
@@ -211,9 +211,14 @@ 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_pathAdvancedPattern, 0);
            if (str != null) {
                pa = new PatternMatcher(str, PatternMatcher.PATTERN_ADVANCED_GLOB);
            } else {
                str = sa.getNonConfigurationString(
                        R.styleable.AndroidManifestGrantUriPermission_pathPattern, 0);
                if (str != null) {
                    pa = new PatternMatcher(str, PatternMatcher.PATTERN_SIMPLE_GLOB);
@@ -222,6 +227,11 @@ public class ParsedProviderUtils {
                            R.styleable.AndroidManifestGrantUriPermission_pathPrefix, 0);
                    if (str != null) {
                        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);
@@ -230,6 +240,8 @@ public class ParsedProviderUtils {
                            }
                        }
                    }
                }
            }

            if (pa != null) {
                if (provider.uriPermissionPatterns == null) {
@@ -318,7 +330,14 @@ 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_SUFFIX,
                                    readPermission, writePermission);
                        } else {
                            path = sa.getNonConfigurationString(
                                    R.styleable.AndroidManifestPathPermission_path, 0);
                            if (path != null) {
                                pa = new PathPermission(path, PatternMatcher.PATTERN_LITERAL,
                                        readPermission, writePermission);
@@ -326,6 +345,7 @@ public class ParsedProviderUtils {
                        }
                    }
                }
            }

            if (pa != null) {
                if (provider.pathPermissions == null) {
+11 −0
Original line number Diff line number Diff line
@@ -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;
    }
Loading