Merge "Fix gen_notice init to support arch and dist." into tm-mainline-prod
diff --git a/android/apex.go b/android/apex.go
index 20c78ee..98b122e 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -454,7 +454,8 @@
}
return InList(what, apex_available) ||
(what != AvailableToPlatform && InList(AvailableToAnyApex, apex_available)) ||
- (what == "com.android.btservices" && InList("com.android.bluetooth", apex_available)) ||
+ (what == "com.android.btservices" && InList("com.android.bluetooth", apex_available)) || // TODO b/243054261
+ (what == "com.android.bluetooth" && InList("com.android.btservices", apex_available)) || // TODO b/243054261
(strings.HasPrefix(what, "com.android.gki.") && InList(AvailableToGkiApex, apex_available))
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index dbe9180..c425e9c 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -8845,6 +8845,16 @@
android.FixtureMergeEnv(map[string]string{
"EMMA_INSTRUMENT": "true",
}),
+ // need to mock jacocoagent here to satisfy dependency added for
+ // instrumented libraries at build time
+ android.FixtureAddFile("jacocoagent/Android.bp", []byte(`
+ java_library {
+ name: "jacocoagent",
+ srcs: ["Test.java"],
+ system_modules: "none",
+ sdk_version: "none",
+ }
+ `)),
).RunTest(t)
// Make sure jacoco ran on both mylib and mybootclasspathlib
diff --git a/java/base.go b/java/base.go
index ddabbc0..58c1649 100644
--- a/java/base.go
+++ b/java/base.go
@@ -169,6 +169,8 @@
Output_params []string
}
+ // If true, then jacocoagent is automatically added as a libs dependency so that
+ // r8 will not strip instrumentation classes out of dexed libraries.
Instrument bool `blueprint:"mutated"`
// If true, then the module supports statically including the jacocoagent
// into the library.
@@ -781,6 +783,9 @@
} else if j.shouldInstrumentStatic(ctx) {
ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent")
}
+ if j.shouldInstrument(ctx) {
+ ctx.AddVariationDependencies(nil, libTag, "jacocoagent")
+ }
if j.useCompose() {
ctx.AddVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), kotlinPluginTag,
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index f95c83f..2bfb255 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -96,10 +96,22 @@
}
func TestBootclasspathFragment_Coverage(t *testing.T) {
- prepareForTestWithFrameworkCoverage := android.FixtureMergeEnv(map[string]string{
- "EMMA_INSTRUMENT": "true",
- "EMMA_INSTRUMENT_FRAMEWORK": "true",
- })
+ prepareForTestWithFrameworkCoverage := android.GroupFixturePreparers(
+ android.FixtureMergeEnv(map[string]string{
+ "EMMA_INSTRUMENT": "true",
+ "EMMA_INSTRUMENT_FRAMEWORK": "true",
+ }),
+ // need to mock jacocoagent here to satisfy dependency added for
+ // instrumented libraries at build time
+ android.FixtureAddFile("jacocoagent/Android.bp", []byte(`
+ java_library {
+ name: "jacocoagent",
+ srcs: ["Test.java"],
+ system_modules: "none",
+ sdk_version: "none",
+ }
+ `)),
+ )
prepareWithBp := android.FixtureWithRootAndroidBp(`
bootclasspath_fragment {