Merge 902d54ac019a9085244b645df717bdd77ecb4101 on remote branch

Change-Id: I4a84b600c4f243860f720b0f46fa9d034a75f10d
diff --git a/Android.bp b/Android.bp
index c665c49..a26de2e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -71,12 +71,20 @@
             enabled: true,
         },
     },
-}
 
-cc_library_static {
-    name: "libz_current",
-    defaults: ["libz_defaults"],
-    sdk_version: "current",
+// TODO(b/155456180): make libz a stub-providing library by uncommenting below
+//    stubs: {
+//        versions: ["29", "30"],
+//        symbol_file: "libz.map.txt",
+//    },
+
+    apex_available: [
+        "//apex_available:platform",
+        "com.android.art.debug", // from libdexfile
+        "com.android.art.release",
+        "com.android.bluetooth.updatable",
+        "com.android.runtime",
+    ],
 }
 
 cc_binary_host {
@@ -115,6 +123,21 @@
 //     license: "NOTICE",
 // }
 
+// TODO(b/155351357) remove this library and let libtextclassifier to use libz
+// instead.
+// libz_current allows modules building against the NDK to have access to zlib
+// API that's not available from the NDK libz.
+cc_library_static {
+    name: "libz_current",
+    defaults: ["libz_defaults"],
+    sdk_version: "current",
+
+    apex_available: [
+        "//apex_available:platform", // indirectly from GoogleExtServices that gets installed to /system
+        "com.android.extservices", // indirectly via libtextclassifier
+    ],
+}
+
 ndk_library {
     name: "libz",
     symbol_file: "libz.map.txt",