Simplify the *-lib-* functions

Simplify the java-lib-* type functions, three layers of abstraction
is a bit much for a single line function, and isn't reducing enough
duplication to be worth the complexity.

Add app-lib-* functions and use them.

Test: m -j checkbuild
Change-Id: Ia47ebc95e4af2073396233416f14fdee7d856844
diff --git a/core/definitions.mk b/core/definitions.mk
index 0f7c765..819a485 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -671,25 +671,12 @@
 ## $(2): Non-empty if IS_HOST_MODULE
 ###########################################################
 
-# $(1): library name
-# $(2): Non-empty if IS_HOST_MODULE
-define _java-lib-dir
-$(call intermediates-dir-for, \
-	JAVA_LIBRARIES,$(1),$(2),COMMON)
-endef
-
-# $(1): library name
-# $(2): Non-empty if IS_HOST_MODULE
-define _java-lib-full-classes.jar
-$(call _java-lib-dir,$(1),$(2))/classes.jar
-endef
-
 # Get the jar files (you can pass to "javac -classpath") of static or shared
 # Java libraries that you want to link against.
 # $(1): library name list
 # $(2): Non-empty if IS_HOST_MODULE
 define java-lib-files
-$(foreach lib,$(1),$(call _java-lib-full-classes.jar,$(lib),$(2)))
+$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes.jar)
 endef
 
 # Get the header jar files (you can pass to "javac -classpath") of static or shared
@@ -697,7 +684,7 @@
 # $(1): library name list
 # $(2): Non-empty if IS_HOST_MODULE
 define java-lib-header-files
-$(foreach lib,$(1),$(call intermediates-dir-for, JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes-header.jar)
+$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes-header.jar)
 endef
 
 # Get the dependency files (you can put on the right side of "|" of a build rule)
@@ -712,6 +699,19 @@
 $(call java-lib-files,$(1),$(2))
 endef
 
+# Get the jar files (you can pass to "javac -classpath") of static or shared
+# APK libraries that you want to link against.
+# $(1): library name list
+define app-lib-files
+$(foreach lib,$(1),$(call intermediates-dir-for,APPS,$(lib),,COMMON)/classes.jar)
+endef
+
+# Get the header jar files (you can pass to "javac -classpath") of static or shared
+# APK libraries that you want to link against.
+# $(1): library name list
+define app-lib-header-files
+$(foreach lib,$(1),$(call intermediates-dir-for,APPS,$(lib),,COMMON)/classes-header.jar)
+endef
 
 ###########################################################
 ## Convert "core ext framework" to "out/.../classes.jack ..."
@@ -719,16 +719,10 @@
 ## $(2): Non-empty if IS_HOST_MODULE
 ###########################################################
 
-# $(1): library name
-# $(2): Non-empty if IS_HOST_MODULE
-define _jack-lib-full-classes
-$(call _java-lib-dir,$(1),$(2))/classes.jack
-endef
-
 # $(1): library name list
 # $(2): Non-empty if IS_HOST_MODULE
 define jack-lib-files
-$(foreach lib,$(1),$(call _jack-lib-full-classes,$(lib),$(2)))
+$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes.jack)
 endef
 
 ###########################################################