Support code coverage with Jack

Building an app with Jack and with the environment variable
EMMA_INSTRUMENT_STATIC set to true will apply code coverage
onto the app targeting Jacoco.

Bug: 20115492
Change-Id: Ief3640fa3faa466f7f6aaa9739e06d3db24110a0
diff --git a/core/package_internal.mk b/core/package_internal.mk
index f5a00e5..097d801 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -186,12 +186,22 @@
 
 ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
 ifeq (true,$(EMMA_INSTRUMENT_STATIC))
+ifdef LOCAL_JACK_ENABLED
+# Jack supports coverage with Jacoco
+LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
+else
 LOCAL_STATIC_JAVA_LIBRARIES += emma
+endif # LOCAL_JACK_ENABLED
 else
 ifdef LOCAL_SDK_VERSION
 ifdef TARGET_BUILD_APPS
 # In unbundled build merge the emma library into the apk.
+ifdef LOCAL_JACK_ENABLED
+# Jack supports coverage with Jacoco
+LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
+else
 LOCAL_STATIC_JAVA_LIBRARIES += emma
+endif # LOCAL_JACK_ENABLED
 else
 # If build against the SDK in full build, core.jar is not used,
 # we have to use prebiult emma.jar to make Proguard happy;