More flexibility to keep/remove R.class in static Java library

- Usually you don't need to set LOCAL_JAR_EXCLUDE_FILES in your
  Android.mk, if your static library is directly used by an app.
- If your library will be included by another library that need
  reference the R/Manifest class, you can set
  LOCAL_JAR_EXCLUDE_FILES := none
  to keep the generated classes.
- If your library includes another static library that has Android
  resource and you want to remove the generated classes carried by
  the static library, set:
  LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES)

With the LOCAL_JAR_EXCLUDE_FILES value "none", deprecate the old
long variable LOCAL_KEEP_R_CLASS_IN_STATIC_JAVA_LIBRARY.

Change-Id: I3b9ad5d66f0262f784feb09bc1537c5b01256258
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
index 367ea5f..eaa74aa 100644
--- a/core/static_java_library.mk
+++ b/core/static_java_library.mk
@@ -36,14 +36,18 @@
     ))
 
 ifneq (,$(all_resources))
-# Those files will be excluded from the built jar.
-# The R/Manifest classes should be re-generated in the app Module instead.
-# Use '' and $ escape because they will be passed to bash.
-ifneq (true,$(LOCAL_KEEP_R_CLASS_IN_STATIC_JAVA_LIBRARY))
-LOCAL_JAR_EXCLUDE_FILES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class'
+# By default we should remove the R/Manifest classes from a static Java library,
+# because they will be regenerated in the app that uses it.
+# But if the static Java library will be used by a library, then we may need to
+# keep the generated classes with "LOCAL_JAR_EXCLUDE_FILES := none".
+ifndef LOCAL_JAR_EXCLUDE_FILES
+LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES)
 endif
+ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES))
+LOCAL_JAR_EXCLUDE_FILES :=
 endif
-endif
+endif  # all_resources
+endif  # LOCAL_RESOURCE_DIR
 
 include $(BUILD_SYSTEM)/java_library.mk
 
@@ -107,4 +111,3 @@
 endif  # $(all_resources) not empty
 
 LOCAL_IS_STATIC_JAVA_LIBRARY :=
-LOCAL_JAR_EXCLUDE_FILES :=