summaryrefslogtreecommitdiff
path: root/apex/apex.go
diff options
context:
space:
mode:
Diffstat (limited to 'apex/apex.go')
-rw-r--r--apex/apex.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/apex/apex.go b/apex/apex.go
index ac67feea2..56313714d 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -76,6 +76,8 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("apex", apexMutator).Parallel()
ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).Parallel()
ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
+ // Register after apex_info mutator so that it can use ApexVariationName
+ ctx.TopDown("apex_strict_updatability_lint", apexStrictUpdatibilityLintMutator).Parallel()
}
type apexBundleProperties struct {
@@ -1005,6 +1007,52 @@ func apexInfoMutator(mctx android.TopDownMutatorContext) {
}
}
+// apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module
+// This check is enforced for updatable modules
+func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) {
+ if !mctx.Module().Enabled() {
+ return
+ }
+ if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() {
+ mctx.WalkDeps(func(child, parent android.Module) bool {
+ // b/208656169 Do not propagate strict updatability linting to libcore/
+ // These libs are available on the classpath during compilation
+ // These libs are transitive deps of the sdk. See java/sdk.go:decodeSdkDep
+ // Only skip libraries defined in libcore root, not subdirectories
+ if mctx.OtherModuleDir(child) == "libcore" {
+ // Do not traverse transitive deps of libcore/ libs
+ return false
+ }
+ if lintable, ok := child.(java.LintDepSetsIntf); ok {
+ lintable.SetStrictUpdatabilityLinting(true)
+ }
+ // visit transitive deps
+ return true
+ })
+ }
+}
+
+// TODO: b/215736885 Whittle the denylist
+// Transitive deps of certain mainline modules baseline NewApi errors
+// Skip these mainline modules for now
+var (
+ skipStrictUpdatabilityLintAllowlist = []string{
+ "com.android.art",
+ "com.android.art.debug",
+ "com.android.conscrypt",
+ "com.android.media",
+ // test apexes
+ "test_com.android.art",
+ "test_com.android.conscrypt",
+ "test_com.android.media",
+ "test_jitzygote_com.android.art",
+ }
+)
+
+func (a *apexBundle) checkStrictUpdatabilityLinting() bool {
+ return a.Updatable() && !android.InList(a.ApexVariationName(), skipStrictUpdatabilityLintAllowlist)
+}
+
// apexUniqueVariationsMutator checks if any dependencies use unique apex variations. If so, use
// unique apex variations for this module. See android/apex.go for more about unique apex variant.
// TODO(jiyong): move this to android/apex.go?