Snap for 6916203 from ee1f30a6f35669728df6396c3395a2acdd668187 to mainline-release

Change-Id: I474ef1b1b9146f25bae1df428b520a555eaed5ed
diff --git a/core/definitions.mk b/core/definitions.mk
index 89c2e27..7dc3e99 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -111,6 +111,9 @@
 # All compatibility suites mentioned in LOCAL_COMPATIBILITY_SUITES
 ALL_COMPATIBILITY_SUITES :=
 
+# All compatibility suite files to dist.
+ALL_COMPATIBILITY_DIST_FILES :=
+
 # All LINK_TYPE entries
 ALL_LINK_TYPES :=
 
@@ -2903,6 +2906,7 @@
 # 2. Add all the files to each suite's dependent files list.
 # 3. Do the dependency addition to my_all_targets.
 # 4. Save the module name to COMPATIBILITY.$(suite).MODULES for each suite.
+# 5. Collect files to dist to ALL_COMPATIBILITY_DIST_FILES.
 # Requires for each suite: use my_compat_dist_config_$(suite) to define the test config.
 #    and use my_compat_dist_$(suite) to define the others.
 define create-suite-dependencies
@@ -2913,10 +2917,13 @@
     $(eval COMPATIBILITY.$(suite).MODULES :=)) \
   $(eval COMPATIBILITY.$(suite).FILES += \
     $$(foreach f,$$(my_compat_dist_$(suite)),$$(call word-colon,2,$$(f))) \
-    $$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call word-colon,2,$$(f)))) \
+    $$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call word-colon,2,$$(f))) \
+    $$(my_compat_dist_test_data_$(suite))) \
+  $(eval ALL_COMPATIBILITY_DIST_FILES += $$(my_compat_dist_$(suite))) \
   $(eval COMPATIBILITY.$(suite).MODULES += $$(my_register_name))) \
-$(eval $(my_all_targets) : $(call copy-many-files, \
-  $(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE),$(my_compat_dist_$(suite))))) \
+$(eval $(my_all_targets) : \
+  $(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE), \
+    $(foreach f,$(my_compat_dist_$(suite)), $(call word-colon,2,$(f))))) \
   $(call copy-many-xml-files-checked, \
     $(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE),$(my_compat_dist_config_$(suite))))))
 endef
diff --git a/core/main.mk b/core/main.mk
index b6bc7c8..257ae29 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1276,6 +1276,10 @@
 test_files :=
 endif
 
+# Dedpulicate compatibility suite dist files across modules and packages before
+# copying them to their requested locations. Assign the eval result to an unused
+# var to prevent Make from trying to make a sense of it.
+_unused := $(call copy-many-files, $(sort $(ALL_COMPATIBILITY_DIST_FILES)))
 
 # Don't include any GNU General Public License shared objects or static
 # libraries in SDK images.  GPL executables (not static/dynamic libraries)
diff --git a/core/rbe.mk b/core/rbe.mk
index 9ec8481..cfad09c 100644
--- a/core/rbe.mk
+++ b/core/rbe.mk
@@ -19,7 +19,7 @@
   ifdef RBE_DIR
     rbe_dir := $(RBE_DIR)
   else
-    rbe_dir := $(HOME)/rbe
+    rbe_dir := prebuilts/remoteexecution-client/live/
   endif
 
   ifdef RBE_CXX_EXEC_STRATEGY
@@ -37,19 +37,19 @@
   ifdef RBE_JAVAC_EXEC_STRATEGY
     javac_exec_strategy := $(RBE_JAVAC_EXEC_STRATEGY)
   else
-    javac_exec_strategy := "local"
+    javac_exec_strategy := remote_local_fallback
   endif
 
   ifdef RBE_R8_EXEC_STRATEGY
     r8_exec_strategy := $(RBE_R8_EXEC_STRATEGY)
   else
-    r8_exec_strategy := "local"
+    r8_exec_strategy := remote_local_fallback
   endif
 
   ifdef RBE_D8_EXEC_STRATEGY
     d8_exec_strategy := $(RBE_D8_EXEC_STRATEGY)
   else
-    d8_exec_strategy := "local"
+    d8_exec_strategy := remote_local_fallback
   endif
 
   platform := "container-image=docker://gcr.io/androidbuild-re-dockerimage/android-build-remoteexec-image@sha256:582efb38f0c229ea39952fff9e132ccbe183e14869b39888010dacf56b360d62"
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index fc6a18f..d3ad4f4 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -240,7 +240,7 @@
     #  It must be of the form "YYYY-MM-DD" on production devices.
     #  It must match one of the Android Security Patch Level strings of the Public Security Bulletins.
     #  If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
-      PLATFORM_SECURITY_PATCH := 2020-10-05
+      PLATFORM_SECURITY_PATCH := 2020-11-05
 endif
 .KATI_READONLY := PLATFORM_SECURITY_PATCH
 
diff --git a/rbesetup.sh b/rbesetup.sh
index 7e9b2ea..25a1703 100644
--- a/rbesetup.sh
+++ b/rbesetup.sh
@@ -23,3 +23,25 @@
   RBE_re_proxy="${RBE_BINARIES_DIR}/reproxy" \
   $@
 }
+
+# This function detects if the uploader is available and sets the path of it to
+# ANDROID_ENABLE_METRICS_UPLOAD.
+function _export_metrics_uploader() {
+  local uploader_path="$(gettop)/vendor/google/misc/metrics_uploader_prebuilt/metrics_uploader.sh"
+  if [ -x "${uploader_path}" ]; then
+    export ANDROID_ENABLE_METRICS_UPLOAD="${uploader_path}"
+  fi
+}
+
+# This function sets RBE specific environment variables needed for the build to
+# executed by RBE. This file should be sourced once per checkout of Android code.
+function _set_rbe_vars() {
+  export USE_RBE="true"
+  export RBE_CXX_EXEC_STRATEGY="remote_local_fallback"
+  export RBE_JAVAC=1
+  export RBE_R8=1
+  export RBE_D8=1
+}
+
+_export_metrics_uploader
+_set_rbe_vars