StringFilterpublic abstract class StringFilter extends Object implements Filter
Fields Summary |
---|
private static final String | ATTR_EQUALS | private static final String | ATTR_STARTS_WITH | private static final String | ATTR_CONTAINS | private static final String | ATTR_PATTERN | private static final String | ATTR_REGEX | private static final String | ATTR_IS_NULL | private final ValueProvider | mValueProvider | public static final ValueProvider | COMPONENT | public static final ValueProvider | COMPONENT_NAME | public static final ValueProvider | COMPONENT_PACKAGE | public static final FilterFactory | ACTION | public static final ValueProvider | DATA | public static final ValueProvider | MIME_TYPE | public static final ValueProvider | SCHEME | public static final ValueProvider | SSP | public static final ValueProvider | HOST | public static final ValueProvider | PATH |
Constructors Summary |
---|
private StringFilter(ValueProvider valueProvider)
this.mValueProvider = valueProvider;
|
Methods Summary |
---|
private static com.android.server.firewall.StringFilter | getFilter(com.android.server.firewall.StringFilter$ValueProvider valueProvider, org.xmlpull.v1.XmlPullParser parser, int attributeIndex)
String attributeName = parser.getAttributeName(attributeIndex);
switch (attributeName.charAt(0)) {
case 'e":
if (!attributeName.equals(ATTR_EQUALS)) {
return null;
}
return new EqualsFilter(valueProvider, parser.getAttributeValue(attributeIndex));
case 'i":
if (!attributeName.equals(ATTR_IS_NULL)) {
return null;
}
return new IsNullFilter(valueProvider, parser.getAttributeValue(attributeIndex));
case 's":
if (!attributeName.equals(ATTR_STARTS_WITH)) {
return null;
}
return new StartsWithFilter(valueProvider,
parser.getAttributeValue(attributeIndex));
case 'c":
if (!attributeName.equals(ATTR_CONTAINS)) {
return null;
}
return new ContainsFilter(valueProvider, parser.getAttributeValue(attributeIndex));
case 'p":
if (!attributeName.equals(ATTR_PATTERN)) {
return null;
}
return new PatternStringFilter(valueProvider,
parser.getAttributeValue(attributeIndex));
case 'r":
if (!attributeName.equals(ATTR_REGEX)) {
return null;
}
return new RegexFilter(valueProvider, parser.getAttributeValue(attributeIndex));
}
return null;
| public boolean | matches(IntentFirewall ifw, android.content.ComponentName resolvedComponent, android.content.Intent intent, int callerUid, int callerPid, java.lang.String resolvedType, int receivingUid)
String value = mValueProvider.getValue(resolvedComponent, intent, resolvedType);
return matchesValue(value);
| protected abstract boolean | matchesValue(java.lang.String value)
| public static com.android.server.firewall.StringFilter | readFromXml(com.android.server.firewall.StringFilter$ValueProvider valueProvider, org.xmlpull.v1.XmlPullParser parser)Constructs a new StringFilter based on the string filter attribute on the current
element, and the given StringValueMatcher.
The current node should contain exactly 1 string filter attribute. E.g. equals,
contains, etc. Otherwise, an XmlPullParserException will be thrown.
StringFilter filter = null;
for (int i=0; i<parser.getAttributeCount(); i++) {
StringFilter newFilter = getFilter(valueProvider, parser, i);
if (newFilter != null) {
if (filter != null) {
throw new XmlPullParserException("Multiple string filter attributes found");
}
filter = newFilter;
}
}
if (filter == null) {
// if there are no string filter attributes, we default to isNull="false" so that an
// empty filter is equivalent to an existence check
filter = new IsNullFilter(valueProvider, false);
}
return filter;
|
|