apex_available becomes more correct

Previously, Soong didn't follow the static dependencies when checking
apex_available. As a result, a module that is not available to an APEX
(or to the platform) was able to be statically linked from the APEX (or
the platform).

As the Soong bug is fixed, unchecked dependencies have revealed and this
change reflects the finding.

Exempt-From-Owner-Approval: cherry-pick from internal

Bug: 147671264
Test: m
Merged-In: I6d9dbe31a8d46d26a4925462edd1984281bd203a
(cherry picked from commit a24189de28d3dc078ffe3e694816859bce9ce730)
Change-Id: I6d9dbe31a8d46d26a4925462edd1984281bd203a
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index 635a3d3..e3320fe 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -120,6 +120,7 @@
     ],
     apex_available: [
         "com.android.art.release",
+        "com.android.art.debug",
     ],
 }
 
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 6802041..a414bd2 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -176,6 +176,11 @@
     apex_available: [
         "com.android.art.release",
         "com.android.art.debug",
+        // due to the transitive dependency from linker:
+        // linker -> libdebuggerd_handler_fallback -> libdexfile_support_static -> libdexfile
+        // libartbase
+        // TODO(b/142944931): remove this
+        "com.android.runtime",
         // TODO(b/142944931) Clean this up. This is due to the dependency to libdexfile_support_static
         // from /system/core, etc.
         "//apex_available:platform",
diff --git a/libartpalette/Android.bp b/libartpalette/Android.bp
index 2fe4cc6..43539d6 100644
--- a/libartpalette/Android.bp
+++ b/libartpalette/Android.bp
@@ -95,6 +95,8 @@
     apex_available: [
         "com.android.art.release",
         "com.android.art.debug",
+        // TODO(b/142944931): remove this
+        "com.android.runtime", // due to the transitive dependency from linker
         // TODO(b/142944931) Clean this up. This is due to the dependency to libdexfile_support_static
         // from /system/core, etc.
         "//apex_available:platform",
diff --git a/libdexfile/Android.bp b/libdexfile/Android.bp
index e9ae603..626295c 100644
--- a/libdexfile/Android.bp
+++ b/libdexfile/Android.bp
@@ -177,6 +177,8 @@
     apex_available: [
         "com.android.art.release",
         "com.android.art.debug",
+        // TODO(b/142944931): remove this
+        "com.android.runtime", // due to the transitive dependency from linker
         // TODO(b/142944931) Clean this up. This is due to the dependency to libdexfile_support_static
         // from /system/core, etc.
         "//apex_available:platform",
@@ -311,6 +313,8 @@
     apex_available: [
         "com.android.art.release",
         "com.android.art.debug",
+        // TODO(b/142944931): remove this
+        "com.android.runtime", // due to the transitive dependency from linker
         // TODO(b/142944931) Clean this up. This is due to the dependency to libdexfile_support_static
         // from /system/core, etc.
         "//apex_available:platform",
diff --git a/libelffile/Android.bp b/libelffile/Android.bp
index 3e6cbf0..de7fa96 100644
--- a/libelffile/Android.bp
+++ b/libelffile/Android.bp
@@ -41,6 +41,7 @@
     ],
     apex_available: [
         "com.android.art.release",
+        "com.android.art.debug",
     ],
 }
 
diff --git a/tools/cpp-define-generator/Android.bp b/tools/cpp-define-generator/Android.bp
index 20634fe..65310b8 100644
--- a/tools/cpp-define-generator/Android.bp
+++ b/tools/cpp-define-generator/Android.bp
@@ -31,7 +31,10 @@
     // Produce text file rather than binary.
     cflags: ["-S"],
     srcs: ["asm_defines.cc"],
-    apex_available: ["//apex_available:platform"],
+    apex_available: [
+        "com.android.art.debug",
+        "com.android.art.release",
+    ],
 }
 
 // This extracts the compile-time constants from asm_defines.s and creates the header.