Create canonical name -> file name symlink in the symbol directory

We have two runtime APEX files: com.android.runtime.debug.apex and
com.android.runtime.release.apex. For a device, only either of them is
selected and mounted on the canonical path /apex/com.android.runtime.

The symbol files for the two APEX modules are installed to
$(TARGET_OUT_UNSTRIPPED)/apex/com.android.runtime.{release|debug}.
However, since the APEXes are mounted to /apex/com.android.runtime
(without .debug or .release suffix), the stack trace for the files shows
/apex/com.android.runtime path, not the .release or .debug path. As a
result, a tool like 'stack' fails to find the symbols for the libs in
the runtime APEX.

This problem is solved by creating a symlink com.android.runtime in the
symbol directory ($(TARGET_OUT_UNSTRIPPED)) that points either
com.android.runtime.debug or com.android.runtime.release depending on
which variant of the runtime APEX is selected for the device.

Bug: 120846816
Test: m and inspect that symbol files exist under
$(PRODUCT_OUT)/symbols/apex/com.android.runtime/

Change-Id: If3969736ed1c51b8375974dfa320cd798dbd730c
diff --git a/Android.mk b/Android.mk
index 65b904f..76965d2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -361,6 +361,14 @@
 
 LOCAL_MODULE := com.android.runtime
 LOCAL_REQUIRED_MODULES := $(TARGET_RUNTIME_APEX)
+# Create canonical name -> file name symlink in the symbol directory
+# The symbol files for the debug or release variant are installed to
+# $(TARGET_OUT_UNSTRIPPED)/$(TARGET_RUNTIME_APEX) directory. However,
+# since they are available via /apex/com.android.runtime at runtime
+# regardless of which variant is installed, create a symlink so that
+# $(TARGET_OUT_UNSTRIPPED)/apex/com.android.runtime is linked to
+# $(TARGET_OUT_UNSTRIPPED)/apex/$(TARGET_RUNTIME_APEX).
+LOCAL_POST_INSTALL_CMD := ln -sf $(TARGET_RUNTIME_APEX) $(TARGET_OUT_UNSTRIPPED)/apex/com.android.runtime
 ifneq ($(HOST_OS),darwin)
   LOCAL_REQUIRED_MODULES += $(APEX_TEST_MODULE)
 endif