Use resource overlay

Instead of using $(shell) to make a dir and then copying over the
resource files.

Change-Id: I0b60749ed487b5a2b507be89abc4425ddadeaee7
diff --git a/tests/SignatureTest/Android.mk b/tests/SignatureTest/Android.mk
index e1753e5..b7a4417 100644
--- a/tests/SignatureTest/Android.mk
+++ b/tests/SignatureTest/Android.mk
@@ -45,75 +45,50 @@
 # hack.
 intermediates.COMMON := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),,COMMON)
 signature_res_dir := $(intermediates.COMMON)/genres
-LOCAL_RESOURCE_DIR := $(signature_res_dir)
-
-# These shell commands allow us to get around the package.mk check for
-# empty/non-existent resouce dirs (which ours would be).  If it finds
-# an empty/non-existent resource dir, R_file_stamp doesn't contain a
-# target and our stuff never gets copied.
-# TODO: fix package.mk so we can avoid this hack
-fake_resource_check := $(signature_res_dir)/raw/fake_resource_check
-
-$(shell \
- if [ ! -f $(fake_resource_check) ]; then \
-   mkdir -p $(dir $(fake_resource_check)); \
-   touch $(fake_resource_check); \
- fi \
- )
+LOCAL_RESOURCE_DIR := $(signature_res_dir) $(LOCAL_PATH)/res
 
 include $(BUILD_PACKAGE)
 
-copied_res_stamp := $(intermediates.COMMON)/copyres.stamp
 generated_res_stamp := $(intermediates.COMMON)/genres.stamp
-api_ver_path := $(intermediates.COMMON)
-api_ver_file := $(api_ver_path)/api_ver_is_$(CTS_API_VERSION)
+api_ver_file := $(intermediates.COMMON)/api_ver_is_$(CTS_API_VERSION)
 
 # The api_ver_file keeps track of which api version was last built.
 # By only ever having one of these magic files in existance and making
 # sure the generated resources rule depend on it, we can ensure that
 # the proper version of the api resource gets generated.
 $(api_ver_file):
-	$(hide) rm -f $(api_ver_path)/api_ver_is_*
+	$(hide) rm -f $(dir $@)/api_ver_is_*
 	$(hide) touch $@
 
 android_api_xml_description := $(intermediates.COMMON)/api.xml
-$(android_api_xml_description): PRIVATE_INPUT_FILE := $(android_api_description)
-$(android_api_xml_description): $(android_api_description) $(APICHECK)
-	$(hide) echo "Convert api file to xml: $@"
-	$(hide) $(APICHECK_COMMAND) -convert2xml $(PRIVATE_INPUT_FILE) $@
-
-static_res_deps := $(call find-subdir-assets,$(LOCAL_PATH)/res)
-$(copied_res_stamp): PRIVATE_PATH := $(LOCAL_PATH)
-$(copied_res_stamp): PRIVATE_MODULE := $(LOCAL_MODULE)
-$(copied_res_stamp): PRIVATE_RES_DIR := $(signature_res_dir)
-$(copied_res_stamp): FAKE_RESOURCE_DIR := $(dir $(fake_resource_check))
-$(copied_res_stamp): FAKE_RESOURCE_CHECK := $(fake_resource_check)
-$(copied_res_stamp): $(foreach res,$(static_res_deps),$(LOCAL_PATH)/res/${res}) | $(ACP)
-	$(hide) echo "Copy resources: $(PRIVATE_MODULE)"
-	$(hide) rm -f $@
-	$(hide) rm -rf $(PRIVATE_RES_DIR)
-	$(hide) mkdir -p $(PRIVATE_RES_DIR)
-	$(hide) if [ ! -f $(FAKE_RESOURCE_CHECK) ]; \
-	  then mkdir -p $(FAKE_RESOURCE_DIR); \
-	  touch $(FAKE_RESOURCE_CHECK); \
-	fi
-	$(hide) $(ACP) -rd $(PRIVATE_PATH)/res/* $(PRIVATE_RES_DIR)/
-	$(hide) touch $@
+$(android_api_xml_description): $(android_api_description) | $(APICHECK)
+	@ echo "Convert api file to xml: $@"
+	@ mkdir -p $(dir $@)
+	$(hide) $(APICHECK_COMMAND) -convert2xml $< $@
 
 # Split up config/api/1.xml by "package" and save the files as the
 # resource files of SignatureTest.
 $(generated_res_stamp): PRIVATE_PATH := $(LOCAL_PATH)
 $(generated_res_stamp): PRIVATE_MODULE := $(LOCAL_MODULE)
 $(generated_res_stamp): PRIVATE_RES_DIR := $(signature_res_dir)
+$(generated_res_stamp): PRIVATE_API_XML_DESC := $(android_api_xml_description)
 $(generated_res_stamp): $(api_ver_file)
-$(generated_res_stamp): $(copied_res_stamp) $(android_api_xml_description)
-	$(hide) echo "Copy generated resources: $(PRIVATE_MODULE)"
-	$(hide) rm -f $@
+$(generated_res_stamp): $(android_api_xml_description)
+	@ echo "Copy generated resources: $(PRIVATE_MODULE)"
 	$(hide) python cts/tools/utils/android_api_description_splitter.py \
-		$(android_api_xml_description) $(PRIVATE_RES_DIR) package
+		$(PRIVATE_API_XML_DESC) $(PRIVATE_RES_DIR) package
 	$(hide) touch $@
 
-$(R_file_stamp): $(generated_res_stamp) $(copied_res_stamp)
+$(R_file_stamp): $(generated_res_stamp)
+
+# clean up temp vars
+android_api_xml_description :=
+api_ver_file :=
+generated_res_stamp :=
+signature_res_dir :=
+android_api_description :=
+CTS_API_VERSION :=
+
 
 # Use the folloing include to make our test apk.
 include $(call all-makefiles-under,$(LOCAL_PATH))