Use Proguard -systemjars instead of -libraryjars

Proguard -systemjars will correctly use the system libraries version
of a duplicate class rather than the program's version.

If USE_R8=true then use -libraryjars as R8's proguard emulation layer
does not support -systemjars and it is unnecessary because R8 does not
fail like proguard does when it comes across duplicate classes.

Bug: 30188076
Bug: 69156675
Test: make checkbuild
Change-Id: I99f0cb7a816ce34e5fa209803b7c538fd931d8a7
diff --git a/core/java.mk b/core/java.mk
index a8ba870..6c2eee5 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -619,7 +619,12 @@
 endif
 endif
 
-legacy_proguard_flags := $(addprefix -libraryjars ,$(my_proguard_sdk_raise) \
+ifeq ($(USE_R8),true)
+proguard_jars_prefix := -libraryjars
+else
+proguard_jars_prefix := -systemjars
+endif
+legacy_proguard_flags := $(addprefix $(proguard_jars_prefix) ,$(my_proguard_sdk_raise) \
   $(filter-out $(my_proguard_sdk_raise), \
     $(full_java_bootclasspath_libs) \
     $(full_shared_java_header_libs)))