Export proguard flags from static android libraries and aar prebuilts

Test: m Contacts, classes-proguard.jar has same contents
Test: rm -rf out; tapas Contacts; m
Change-Id: Id7a92fb2c44913bccbfcbeae127355b4de588e4d
diff --git a/core/java.mk b/core/java.mk
index 717e02d..9e4262a 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -648,6 +648,12 @@
 common_proguard_flags += -dontshrink # don't shrink tests by default
 endif # shrinktests
 endif # test package
+ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
+  ifdef LOCAL_USE_AAPT2
+    common_proguard_flag_files += $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\
+        $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags)
+  endif
+endif
 ifneq ($(common_proguard_flag_files),)
 common_proguard_flags += $(addprefix -include , $(common_proguard_flag_files))
 # This is included from $(BUILD_SYSTEM)/proguard.flags