Move jacocoagent installation to base_system

jacocoagent and its dependencies emits artifacts to system/,
hence it belongs to base_system.mk. It was rather incorrect
to add jacocoagent to EVERY product makefile because those
product makefiles may be enforcing artifact path requirements
(e.g. generic_ramdisk.mk).

Test: EMMA_INSTRUMENT=true m nothing
Bug: 175605139
Bug: 173742069
Change-Id: If9cb93ab8fd69d11e764ab830dc791bbe6106cf5
diff --git a/core/product_config.mk b/core/product_config.mk
index b9de8ca..81a582f 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -184,18 +184,6 @@
 all_product_makefiles :=
 all_product_configs :=
 
-# Jacoco agent JARS to be built and installed, if any.
-ifeq ($(EMMA_INSTRUMENT),true)
-  ifneq ($(EMMA_INSTRUMENT_STATIC),true)
-    # For instrumented build, if Jacoco is not being included statically
-    # in instrumented packages then include Jacoco classes into the
-    # bootclasspath.
-    $(foreach product,$(PRODUCTS),\
-      $(eval PRODUCTS.$(product).PRODUCT_PACKAGES += jacocoagent)\
-      $(eval PRODUCTS.$(product).PRODUCT_BOOT_JARS += jacocoagent))
-  endif # EMMA_INSTRUMENT_STATIC
-endif # EMMA_INSTRUMENT
-
 ############################################################################
 # Strip and assign the PRODUCT_ variables.
 $(call strip-product-vars)
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 1b4c8d9..ef25bde 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -287,6 +287,17 @@
    libclang_rt.hwasan-aarch64-android.bootstrap
 endif
 
+# Jacoco agent JARS to be built and installed, if any.
+ifeq ($(EMMA_INSTRUMENT),true)
+  ifneq ($(EMMA_INSTRUMENT_STATIC),true)
+    # For instrumented build, if Jacoco is not being included statically
+    # in instrumented packages then include Jacoco classes into the
+    # bootclasspath.
+    PRODUCT_PACKAGES += jacocoagent
+    PRODUCT_BOOT_JARS += jacocoagent
+  endif # EMMA_INSTRUMENT_STATIC
+endif # EMMA_INSTRUMENT
+
 # Host tools to install
 PRODUCT_HOST_PACKAGES += \
     BugReport \