enable PDK to use platform JAVA API

- make platform-java will add necessary Java stuffs from out/target/common/
  to platform.zip
- make platform works as before: no Java libraries
- normal fusion build will pick up the file, and define TARGET_BUILD_PDK_JAVA
  besides TARGET_BUILD_PDK if Java stuffs are included
- For TARGET_BUILD_PDK_JAVA, java.mk does not touch LOCAL_SDK_VERSION, which will lead into
  pulling non-SDK Java APIs

Bug: 6482799

Change-Id: I90b1a0b06dc774150711680a6612f2b97b9eab3f
diff --git a/core/Makefile b/core/Makefile
index 5525b2e..bff5e80 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -815,19 +815,31 @@
 .PHONY: stnod
 stnod: systemtarball-nodeps
 
+# For platform-java goal, add platform as well
+ifneq (,$(filter platform-java, $(MAKECMDGOALS)))
+PLATFORM_ZIP_ADD_JAVA := true
+endif
+
 #######
 ## platform.zip: system, plus other files to be used in PDK fusion build,
 ## in a zip file
-INSTALLED_PLATFROM_ZIP := $(PRODUCT_OUT)/platform.zip
-$(INSTALLED_PLATFROM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
-	$(call pretty,"Platform zip package: $(INSTALLED_PLATFROM_ZIP)")
+INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
+$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
+	$(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
 	$(hide) rm -f $@
 	$(hide) cd $(dir $@) && zip -qry $(notdir $@) \
 		$(TARGET_COPY_OUT_SYSTEM) \
 		$(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES))
+ifeq (true,$(PLATFORM_ZIP_ADD_JAVA))
+	$(hide) cd $(OUT_DIR) && zip -qry ../$(INSTALLED_PLATFORM_ZIP) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
+endif
+
 
 .PHONY: platform
-platform: $(INSTALLED_PLATFROM_ZIP)
+platform: $(INSTALLED_PLATFORM_ZIP)
+
+.PHONY: platform-java
+platform-java: platform
 
 # Dist the platform.zip
 ifneq (,$(filter platform, $(MAKECMDGOALS)))