Merge "Adjust partition size checks for recovery resources"
diff --git a/core/Makefile b/core/Makefile
index 7dcc613..048a0f9 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -263,7 +263,7 @@
 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_OUT)/etc/prop.default
 INSTALLED_DEFAULT_PROP_OLD_TARGET := $(TARGET_ROOT_OUT)/default.prop
 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
-$(INSTALLED_DEFAULT_PROP_OLD_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
+$(INSTALLED_DEFAULT_PROP_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
 else
 # legacy path
 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
@@ -1358,10 +1358,10 @@
 # original notice files instead of making rules to copy them somwehere.
 # Then we could traverse that without quite as much bash drama.
 define combine-notice-files
-$(2) $(3): PRIVATE_MESSAGE := $(4)
-$(2) $(3): PRIVATE_DIR := $(5)
-$(2) : $(3)
-$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
+$(2): PRIVATE_MESSAGE := $(4)
+$(2): PRIVATE_DIR := $(5)
+$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
+$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
 	build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
 	    $(if $(filter $(1),xml_excluded_vendor_product_odm),-e vendor -e product -e system_ext -e odm --xml-output, \
 	      $(if $(filter $(1),xml_excluded_system_product_odm),-e system -e product -e system_ext -e odm --xml-output, \
diff --git a/core/base_rules.mk b/core/base_rules.mk
index b161384..9576a80 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -895,7 +895,7 @@
 ##########################################################
 # Track module-level dependencies.
 # Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness.
-ifneq (,$(filter deps-license,$(MAKECMDGOALS)))
+ifdef RECORD_ALL_DEPS
 ALL_DEPS.MODULES := $(ALL_DEPS.MODULES) $(LOCAL_MODULE)
 ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \
   $(ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS) \
diff --git a/core/check_elf_file.mk b/core/check_elf_file.mk
index da4168d..d54a5b7 100644
--- a/core/check_elf_file.mk
+++ b/core/check_elf_file.mk
@@ -38,6 +38,8 @@
 	    $<
 	$(hide) touch $@
 
+CHECK_ELF_FILES.$(check_elf_files_stamp) := 1
+
 ifneq ($(strip $(LOCAL_CHECK_ELF_FILES)),false)
 ifneq ($(strip $(BUILD_BROKEN_PREBUILT_ELF_FILES)),true)
 $(LOCAL_BUILT_MODULE): $(check_elf_files_stamp)
diff --git a/core/config.mk b/core/config.mk
index 160614d..69e2b5c 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -1218,4 +1218,7 @@
 DEFAULT_DATA_OUT_MODULES := ltp $(ltp_packages) $(kselftest_modules)
 .KATI_READONLY := DEFAULT_DATA_OUT_MODULES
 
+# Make RECORD_ALL_DEPS readonly and also set it if deps-license is a goal.
+RECORD_ALL_DEPS :=$= $(filter true,$(RECORD_ALL_DEPS))$(filter deps-license,$(MAKECMDGOALS))
+
 include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/java_common.mk b/core/java_common.mk
index f6e01d2..b218c0d 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -382,7 +382,9 @@
   endif # USE_CORE_LIB_BOOTCLASSPATH
 endif # !LOCAL_IS_HOST_MODULE
 
+ifdef RECORD_ALL_DEPS
 ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS) $(full_java_bootclasspath_libs)
+endif
 
 # Export the SDK libs. The sdk library names listed in LOCAL_SDK_LIBRARIES are first exported.
 # Then sdk library names exported from dependencies are all re-exported.
diff --git a/core/local_systemsdk.mk b/core/local_systemsdk.mk
index 2b73f93..460073d 100644
--- a/core/local_systemsdk.mk
+++ b/core/local_systemsdk.mk
@@ -15,7 +15,7 @@
 #
 
 ifdef BOARD_SYSTEMSDK_VERSIONS
-  # Apps and jars in vendor or odm partition are forced to build against System SDK.
+  # Apps and jars in vendor, product or odm partition are forced to build against System SDK.
   _cannot_use_platform_apis :=
   ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_PROPRIETARY_MODULE)))
     # Note: no need to check LOCAL_MODULE_PATH* since LOCAL_[VENDOR|ODM|OEM]_MODULE is already
@@ -29,9 +29,9 @@
   ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
     ifndef LOCAL_SDK_VERSION
       ifeq ($(_cannot_use_platform_apis),true)
-        ifeq (,$(findstring __auto_generated_rro_,$(LOCAL_MODULE)))
+        ifeq (,$(LOCAL_IS_RUNTIME_RESOURCE_OVERLAY))
           # Runtime resource overlays are exempted from building against System SDK.
-          # TODO(b/35859726): remove this exception
+          # TODO(b/155027019): remove this, after no product/vendor apps rely on this behavior.
           LOCAL_SDK_VERSION := system_current
         endif
       endif
diff --git a/core/main.mk b/core/main.mk
index 465a396..68303cf 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -795,9 +795,10 @@
     $($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))TARGET_OUT_INTERMEDIATES)/SHARED_LIBRARIES/%,\
     $(call module-built-files,$(mod)))))\
   \
-  $(if $(r),\
+  $(if $(and $(r),$(deps)),\
     $(eval stamp := $(dir $(r))check_elf_files.timestamp)\
-    $(eval $(call add-elf-file-check-shared-lib,$(stamp),$(deps)))\
+    $(if $(CHECK_ELF_FILES.$(stamp)),\
+      $(eval $(call add-elf-file-check-shared-lib,$(stamp),$(deps))))\
   ))
 endef
 
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 59e0701..62dac99 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -377,9 +377,11 @@
 # they want to use this module's R.java file.
 $(LOCAL_BUILT_MODULE): $(R_file_stamp)
 
+ifneq ($(full_classes_jar),)
 # The R.java file must exist by the time the java source
 # list is generated
 $(java_source_list_file): $(R_file_stamp)
+endif
 
 endif # need_compile_res
 
diff --git a/target/product/aosp_arm64.mk b/target/product/aosp_arm64.mk
index d026a19..e14effc 100644
--- a/target/product/aosp_arm64.mk
+++ b/target/product/aosp_arm64.mk
@@ -48,11 +48,8 @@
 #
 $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_product.mk)
 
-#
-# All components inherited here go to vendor or vendor_boot image
-#
-$(call inherit-product-if-exists, device/generic/goldfish/arm64-vendor.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/product/emulator_vendor.mk)
+PRODUCT_FULL_TREBLE_OVERRIDE := true
+
 $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_arm64/device.mk)
 
 #
diff --git a/tools/releasetools/OWNERS b/tools/releasetools/OWNERS
index a8295d4..d7fc540 100644
--- a/tools/releasetools/OWNERS
+++ b/tools/releasetools/OWNERS
@@ -1,3 +1,4 @@
+elsk@google.com
 nhdo@google.com
 xunchang@google.com
 zhaojiac@google.com
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 54bb857..f30f787 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -57,7 +57,7 @@
   Returns:
     The number of bytes based on a 1K block_size.
   """
-  cmd = ["du", "-k", "-s", path]
+  cmd = ["du", "-b", "-k", "-s", path]
   output = common.RunAndCheckOutput(cmd, verbose=False)
   return int(output.split()[0]) * 1024