From 33b6654eeace28ceeb8f8328c01722abc4cdc6c6 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 12 Feb 2020 10:39:32 +0900 Subject: [PATCH] Turn on the instrumentation by default for the java code in APEXes Bug: 149353192 Test: DIST_DIR=dist_dir TARGET_BUILD_VARIANT=userdebug EMMA_INSTRUMENT=true NATIVE_COVERAGE=true TARGET_BUILD_APPS="com.android.media" vendor/google/build/build_unbundled_coverage_mainline_module.sh and check that jacoco-report-classes.jar is created. Change-Id: I28e3dc82b7913f60b2278126fca255306e48a424 --- java/java.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/java.go b/java/java.go index dd44d06aa..182dbc360 100644 --- a/java/java.go +++ b/java/java.go @@ -1459,6 +1459,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.headerJarFile = j.implementationJarFile } + // Force enable the instrumentation for java code that is built for APEXes + if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !j.IsForPlatform() { + j.properties.Instrument = true + } + if j.shouldInstrument(ctx) { outputFile = j.instrument(ctx, flags, outputFile, jarName) }