Reduce duplication in visibility property management
Adds a couple of new methods to manage visibility property instances to
reduce duplication and encapsulate the implementation slightly better.
The AddVisibilityProperty method is exported as it will be needed by
other packages in follow up commits.
Bug: 155295806
Test: m nothing
Merged-In: Ic1a9bb1e151fc6ae65761344fd210b4e4ba74fbc
Change-Id: Ic1a9bb1e151fc6ae65761344fd210b4e4ba74fbc
(cherry picked from commit 5ec73ecc08342f0d16f2fb6f128df04d6553b83d)
diff --git a/android/visibility.go b/android/visibility.go
index 3f04123..ab16444 100644
--- a/android/visibility.go
+++ b/android/visibility.go
@@ -480,3 +480,28 @@
return rule.Strings()
}
+
+// Clear the default visibility properties so they can be replaced.
+func clearVisibilityProperties(module Module) {
+ module.base().visibilityPropertyInfo = nil
+}
+
+// Add a property that contains visibility rules so that they are checked for
+// correctness.
+func AddVisibilityProperty(module Module, name string, stringsProperty *[]string) {
+ addVisibilityProperty(module, name, stringsProperty)
+}
+
+func addVisibilityProperty(module Module, name string, stringsProperty *[]string) visibilityProperty {
+ base := module.base()
+ property := newVisibilityProperty(name, stringsProperty)
+ base.visibilityPropertyInfo = append(base.visibilityPropertyInfo, property)
+ return property
+}
+
+// Set the primary visibility property.
+//
+// Also adds the property to the list of properties to be validated.
+func setPrimaryVisibilityProperty(module Module, name string, stringsProperty *[]string) {
+ module.base().primaryVisibilityProperty = addVisibilityProperty(module, name, stringsProperty)
+}