Revert "Relax apex package restriction for T+ jars"
This reverts commit 1fdd6ca88a192c61abe31d2f7a7f5721cafca1f8.
Reason for revert: b/205289292 tracks the real fix for this
Test: presubmit
Change-Id: I5a2edaf4f930dafa26659f85d9425e9041c72275
Merged-In: I5a2edaf4f930dafa26659f85d9425e9041c72275
diff --git a/android/neverallow.go b/android/neverallow.go
index 6f9ae58..7512da7 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -249,7 +249,7 @@
continue
}
- if !n.appliesToProperties(ctx, properties) {
+ if !n.appliesToProperties(properties) {
continue
}
@@ -269,12 +269,8 @@
}
}
-type ValueMatcherContext interface {
- Config() Config
-}
-
type ValueMatcher interface {
- Test(ValueMatcherContext, string) bool
+ Test(string) bool
String() string
}
@@ -282,7 +278,7 @@
expected string
}
-func (m *equalMatcher) Test(ctx ValueMatcherContext, value string) bool {
+func (m *equalMatcher) Test(value string) bool {
return m.expected == value
}
@@ -293,7 +289,7 @@
type anyMatcher struct {
}
-func (m *anyMatcher) Test(ctx ValueMatcherContext, value string) bool {
+func (m *anyMatcher) Test(value string) bool {
return true
}
@@ -307,7 +303,7 @@
prefix string
}
-func (m *startsWithMatcher) Test(ctx ValueMatcherContext, value string) bool {
+func (m *startsWithMatcher) Test(value string) bool {
return strings.HasPrefix(value, m.prefix)
}
@@ -319,7 +315,7 @@
re *regexp.Regexp
}
-func (m *regexMatcher) Test(ctx ValueMatcherContext, value string) bool {
+func (m *regexMatcher) Test(value string) bool {
return m.re.MatchString(value)
}
@@ -331,7 +327,7 @@
allowed []string
}
-func (m *notInListMatcher) Test(ctx ValueMatcherContext, value string) bool {
+func (m *notInListMatcher) Test(value string) bool {
return !InList(value, m.allowed)
}
@@ -341,7 +337,7 @@
type isSetMatcher struct{}
-func (m *isSetMatcher) Test(ctx ValueMatcherContext, value string) bool {
+func (m *isSetMatcher) Test(value string) bool {
return value != ""
}
@@ -351,19 +347,6 @@
var isSetMatcherInstance = &isSetMatcher{}
-type sdkVersionMatcher struct {
- condition func(ctx ValueMatcherContext, spec SdkSpec) bool
- description string
-}
-
-func (m *sdkVersionMatcher) Test(ctx ValueMatcherContext, value string) bool {
- return m.condition(ctx, SdkSpecFromWithConfig(ctx.Config(), value))
-}
-
-func (m *sdkVersionMatcher) String() string {
- return ".sdk-version(" + m.description + ")"
-}
-
type ruleProperty struct {
fields []string // e.x.: Vndk.Enabled
matcher ValueMatcher
@@ -606,10 +589,9 @@
return (len(r.moduleTypes) == 0 || InList(moduleType, r.moduleTypes)) && !InList(moduleType, r.unlessModuleTypes)
}
-func (r *rule) appliesToProperties(ctx ValueMatcherContext,
- properties []interface{}) bool {
- includeProps := hasAllProperties(ctx, properties, r.props)
- excludeProps := hasAnyProperty(ctx, properties, r.unlessProps)
+func (r *rule) appliesToProperties(properties []interface{}) bool {
+ includeProps := hasAllProperties(properties, r.props)
+ excludeProps := hasAnyProperty(properties, r.unlessProps)
return includeProps && !excludeProps
}
@@ -629,16 +611,6 @@
return ¬InListMatcher{allowed}
}
-func LessThanSdkVersion(sdk string) ValueMatcher {
- return &sdkVersionMatcher{
- condition: func(ctx ValueMatcherContext, spec SdkSpec) bool {
- return spec.ApiLevel.LessThan(
- SdkSpecFromWithConfig(ctx.Config(), sdk).ApiLevel)
- },
- description: "lessThan=" + sdk,
- }
-}
-
// assorted utils
func cleanPaths(paths []string) []string {
@@ -657,28 +629,25 @@
return names
}
-func hasAnyProperty(ctx ValueMatcherContext, properties []interface{},
- props []ruleProperty) bool {
+func hasAnyProperty(properties []interface{}, props []ruleProperty) bool {
for _, v := range props {
- if hasProperty(ctx, properties, v) {
+ if hasProperty(properties, v) {
return true
}
}
return false
}
-func hasAllProperties(ctx ValueMatcherContext, properties []interface{},
- props []ruleProperty) bool {
+func hasAllProperties(properties []interface{}, props []ruleProperty) bool {
for _, v := range props {
- if !hasProperty(ctx, properties, v) {
+ if !hasProperty(properties, v) {
return false
}
}
return true
}
-func hasProperty(ctx ValueMatcherContext, properties []interface{},
- prop ruleProperty) bool {
+func hasProperty(properties []interface{}, prop ruleProperty) bool {
for _, propertyStruct := range properties {
propertiesValue := reflect.ValueOf(propertyStruct).Elem()
for _, v := range prop.fields {
@@ -692,7 +661,7 @@
}
check := func(value string) bool {
- return prop.matcher.Test(ctx, value)
+ return prop.matcher.Test(value)
}
if matchValue(propertiesValue, check) {