Automate NDK API coverage used by Mainline modules build integration

Dist txt files containing NDK APIs used by Mainline modules

Test: TARGET_BUILD_APPS=com.google.android.adbd m dist apps_only

Change-Id: I035f1e0cc7eb43fc09e796dbc6ce77e65b8aa3b4
diff --git a/apex/androidmk.go b/apex/androidmk.go
index da38c2a..61b9dad 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -421,6 +421,15 @@
 				for _, dist := range data.Entries.GetDistForGoals(a) {
 					fmt.Fprintf(w, dist)
 				}
+
+				if a.coverageOutputPath.String() != "" {
+					goal := "apps_only"
+					distFile := a.coverageOutputPath.String()
+					fmt.Fprintf(w, "ifneq (,$(filter $(my_register_name),$(TARGET_BUILD_APPS)))\n"+
+						" $(call dist-for-goals,%s,%s:ndk_apis_usedby_apex/$(notdir %s))\n"+
+						"endif",
+						goal, distFile, distFile)
+				}
 			}
 		}}
 }