Consolidate the logic for the sdk prebuilt module names.

I'm making some changes to it, and found the names are scattered
in various places. Make a macro and re-use the logic instead.

Bug: 77525052
Test: make droid
Change-Id: I0f2da80b8b4d427353509b27ec720d024eee7a6e
diff --git a/core/java_common.mk b/core/java_common.mk
index 44ee4b2..a65b6ef 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -261,11 +261,10 @@
     else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),core_current)
       full_java_bootclasspath_libs := $(call java-lib-header-files,core.current.stubs)
     else
-      # core_<ver> is subset of <ver>. Instead of defining a prebuilt lib for core_<ver>,
-      # use the stub for <ver> when building for apps.
-      _version := $(patsubst core_%,%,$(LOCAL_SDK_VERSION))
-      full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(_version))
-      _version :=
+      # TARGET_BUILD_APPS is set. Use the modules defined in prebuilts/sdk/Android.mk.
+      _module_name := $(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION))
+      full_java_bootclasspath_libs := $(call java-lib-header-files,$(_module_name))
+      _module_name :=
     endif # current, system_current, system_${VER}, test_current or core_current
   endif # LOCAL_SDK_VERSION