Add libicuuc, libicui18n, libandroidicu, libpac to APEX

libandroidicu: Provides the stable C interface for other Android
components, except Apps. It's a stub of a subset of libicuuc and
libicui18n

libpac: It uses ICU4C C++ API, but has a stable C interface for
  libjni_pacprocessor. Thus, it should be moved into APEX.

Bug: 120659668
Bug: 121269980
Test: m droid
Test: art/build/apex/runtests.sh
Change-Id: I902c39b104a1678a046262e42efef07a60ee6558
diff --git a/CleanSpec.mk b/CleanSpec.mk
index e28ce2b..cd4e50a 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -53,6 +53,10 @@
 # Old Android Runtime APEX package, before the introduction of "release" and "debug" packages.
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/apex/com.android.runtime.apex)
 
+# Clean up ICU libraries moved to runtime apex
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib*/libandroidicu.so)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib*/libpac.so)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index 735755f..64542da 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -105,11 +105,20 @@
 
 // Native libraries that support the core Java libraries.
 libcore_native_shared_libs = [
+    "libandroidicu",
+    "libexpat",
+    "libicui18n",
+    "libicuuc",
     "libjavacore",
     "libopenjdk",
-    "libexpat",
     "libz",
-    "libziparchive"
+    "libziparchive",
+]
+
+libcore_native_device_only_shared_libs = libcore_native_shared_libs + [
+    // TODO(b/122876336): Remove libpac.so once it's migrated to Webview.
+    // libpac is used by frameworks, not by ART host.
+    "libpac",
 ]
 
 // Temporary library includes for b/123591866 as all libraries are moved into the main art-apex.
@@ -146,7 +155,7 @@
     java_libs: libcore_java_libs,
     native_shared_libs: art_runtime_base_native_shared_libs
         + bionic_native_shared_libs
-        + libcore_native_shared_libs,
+        + libcore_native_device_only_shared_libs,
     multilib: {
         both: {
             // TODO: Add logic to create a `dalvikvm` symlink to `dalvikvm32` or `dalvikvm64`
@@ -177,7 +186,7 @@
     native_shared_libs: art_runtime_base_native_shared_libs
         + art_runtime_debug_native_shared_libs
         + bionic_native_shared_libs
-        + libcore_native_shared_libs
+        + libcore_native_device_only_shared_libs
         + libcore_debug_native_shared_libs,
     multilib: {
         both: {
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 84013f6..46d1e4e 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -396,7 +396,11 @@
 
   def run(self):
     # Check that the mounted image contains Android Core libraries.
+    self._checker.check_library('libandroidicu.so')
     self._checker.check_library('libexpat.so')
+    self._checker.check_library('libicui18n.so')
+    self._checker.check_library('libicuuc.so')
+    self._checker.check_library('libpac.so')
     self._checker.check_library('libz.so')
 
 class ReleaseHostChecker:
@@ -407,7 +411,10 @@
 
   def run(self):
     # Check that the mounted image contains Android Core libraries.
+    self._checker.check_library('libandroidicu-host.so')
     self._checker.check_library('libexpat-host.so')
+    self._checker.check_library('libicui18n-host.so')
+    self._checker.check_library('libicuuc-host.so')
     self._checker.check_library('libz-host.so')
 
 class DebugChecker:
diff --git a/build/apex/ld.config.txt b/build/apex/ld.config.txt
index 3cfda65..f624bd1 100644
--- a/build/apex/ld.config.txt
+++ b/build/apex/ld.config.txt
@@ -34,6 +34,11 @@
 namespace.platform.link.default.shared_libs += libnativebridge.so
 namespace.platform.link.default.shared_libs += libnativehelper.so
 namespace.platform.link.default.shared_libs += libnativeloader.so
+namespace.platform.link.default.shared_libs += libandroidicu.so
+
+# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
+namespace.platform.link.default.shared_libs += libpac.so
+
 # /system/lib/libc.so, etc are symlinks to /bionic/lib/libc.so, etc.
 # Add /bionic/lib to the permitted paths because linker uses realpath(3)
 # to check the accessibility of the lib. We could add this to search.paths