Allow aapt2 rules to take zipped resource files

Allow aapt2 rules to take zipped resource files similar to the
way the javac rules take srcjars.  For now, unzip the files using
extract_srcjars.sh, and then use aapt2 compile --dir.  Eventually
it could be done with aapt2 compile --zip.

Bug: 73885582
Bug: 74574557
Test: m checkbuild
Change-Id: I97ea3ff305e7a9ef2a908b4cf0bca903af62c6b1
Merged-In: I97ea3ff305e7a9ef2a908b4cf0bca903af62c6b1
(cherry picked from commit bc0c494d3af1bce637289e4aceaba90cbdadacba)
diff --git a/core/definitions.mk b/core/definitions.mk
index 23f7ae1..20c32b8 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2079,6 +2079,15 @@
   $(PRIVATE_AAPT2_CFLAGS) --legacy
 endef
 
+# TODO(b/74574557): use aapt2 compile --zip if it gets implemented
+define aapt2-compile-resource-zips
+@mkdir -p $(dir $@)
+rm -rf $@.contents
+mkdir -p $@.contents
+$(EXTRACT_SRCJARS) $@.contents $@.list $(PRIVATE_SOURCE_RES_ZIPS)
+$(hide) $(AAPT2) compile -o $@ --dir $@.tmp $(PRIVATE_AAPT2_CFLAGS) --legacy
+endef
+
 # Set up rule to compile one resource file with aapt2.
 # Must be called with $(eval).
 # $(1): the source file