Install symbols for JNI libraries

When building an app in Soong with JNI libraries copy the unstripped
libraries to the symbols directory in directory that matches the
installed path of the APK.

Bug: 159726429
Test: forrest
Change-Id: If8e423c7cdf3afd518761b5ab6bc857321acda46
Merged-In: If8e423c7cdf3afd518761b5ab6bc857321acda46
(cherry picked from commit e926cab37252cdfe7ea202f1476bfd25acf47b81)
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index b9f439f..f50a701 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -341,6 +341,7 @@
 LOCAL_REQUIRED_MODULES_$(TARGET_ARCH):=
 LOCAL_SHARED_LIBRARIES_$(TARGET_ARCH):=
 LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH):=
+LOCAL_SOONG_JNI_LIBS_SYMBOLS:=
 LOCAL_SRC_FILES_EXCLUDE_$(TARGET_ARCH):=
 LOCAL_SRC_FILES_$(TARGET_ARCH):=
 LOCAL_STATIC_LIBRARIES_$(TARGET_ARCH):=
diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk
index 01e9800..e94b87e 100644
--- a/core/soong_app_prebuilt.mk
+++ b/core/soong_app_prebuilt.mk
@@ -11,6 +11,7 @@
 # LOCAL_SOONG_RRO_DIRS
 # LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH)
 # LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH)
+# LOCAL_SOONG_JNI_LIBS_SYMBOLS
 
 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
   $(call pretty-error,soong_app_prebuilt.mk may only be used from Soong)
@@ -118,6 +119,11 @@
 $(call create-suite-dependencies)
 endif
 
+# install symbol files of JNI libraries
+my_jni_lib_symbols_copy_files := $(foreach f,$(LOCAL_SOONG_JNI_LIBS_SYMBOLS),\
+  $(call word-colon,1,$(f)):$(patsubst $(PRODUCT_OUT)/%,$(TARGET_OUT_UNSTRIPPED)/%,$(call word-colon,2,$(f))))
+$(LOCAL_BUILT_MODULE): $(call copy-many-files, $(my_jni_lib_symbols_copy_files))
+
 # embedded JNI will already have been handled by soong
 my_embed_jni :=
 my_prebuilt_jni_libs :=