Merge "Remove inputflinger from the builds."
diff --git a/CleanSpec.mk b/CleanSpec.mk
index e0c826c..acd5273 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -405,6 +405,11 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib*)
 
+# Revert that move
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib*)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/Makefile b/core/Makefile
index aaf8227..acc1a65 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1421,7 +1421,7 @@
 	  $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
 	  $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
 	  $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
-	  $(hide) echo "PDK.DEXPREOPT.$(m).PROPRIETARY_MODULE:=$(DEXPREOPT.$(m).PROPRIETARY_MODULE)" >> $@$(newline)\
+	  $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
 	  $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
 	  $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
 	  )
@@ -2234,7 +2234,7 @@
 	@# Zip everything up, preserving symlinks and placing META/ files first to
 	@# help early validation of the .zip file while uploading it.
 	$(hide) find $(zip_root)/META | sort >$@.list
-	$(hide) find $(zip_root) | grep -v "^$(zip_root)/META/" | sort >>$@.list
+	$(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
 	$(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
 
 .PHONY: target-files-package
@@ -2273,6 +2273,7 @@
 	$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
 	   ./build/tools/releasetools/ota_from_target_files -v \
 	   --block \
+	   --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
 	   -p $(HOST_OUT) \
 	   -k $(KEY_CERT_PAIR) \
 	   $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
diff --git a/core/aapt2.mk b/core/aapt2.mk
index 34f32e3..a10af67 100644
--- a/core/aapt2.mk
+++ b/core/aapt2.mk
@@ -5,6 +5,8 @@
 # - my_res_resources
 # - my_overlay_resources
 # - my_compiled_res_base_dir
+# - my_asset_dirs
+# - my_full_asset_paths
 # - my_res_package
 # - R_file_stamp
 # - proguard_options_file
@@ -66,8 +68,10 @@
 $(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_static_library_resources) $(my_generated_resources_flata) $(my_overlay_resources_flat)
 $(my_res_package): PRIVATE_SHARED_ANDROID_LIBRARIES := $(my_shared_library_resources)
 $(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
-$(my_res_package) : $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources)
-$(my_res_package) : $(my_res_resources_flat) $(my_overlay_resources_flat) \
+$(my_res_package): PRIVATE_ASSET_DIRS := $(my_asset_dirs)
+$(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources)
+$(my_res_package): $(my_full_asset_paths)
+$(my_res_package): $(my_res_resources_flat) $(my_overlay_resources_flat) \
   $(my_generated_resources_flata) $(my_static_library_resources) \
   $(AAPT2)
 	@echo "AAPT2 link $@"
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 1763a06..92e69bb 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -65,6 +65,16 @@
   my_host_cross :=
 endif
 
+ifndef LOCAL_PROPRIETARY_MODULE
+  LOCAL_PROPRIETARY_MODULE := $(LOCAL_VENDOR_MODULE)
+endif
+ifndef LOCAL_VENDOR_MODULE
+  LOCAL_VENDOR_MODULE := $(LOCAL_PROPRIETARY_MODULE)
+endif
+ifneq ($(filter-out $(LOCAL_PROPRIETARY_MODULE),$(LOCAL_VENDOR_MODULE))$(filter-out $(LOCAL_VENDOR_MODULE),$(LOCAL_PROPRIETARY_MODULE)),)
+$(call pretty-error,Only one of LOCAL_PROPRIETARY_MODULE[$(LOCAL_PROPRIETARY_MODULE)] and LOCAL_VENDOR_MODULE[$(LOCAL_VENDOR_MODULE)] may be set, or they must be equal)
+endif
+
 include $(BUILD_SYSTEM)/local_vndk.mk
 
 my_module_tags := $(LOCAL_MODULE_TAGS)
@@ -78,8 +88,6 @@
 endif
 endif
 
-my_module_is_soong := $(if $(filter $(OUT_DIR)/soong/%,$(LOCAL_MODULE_MAKEFILE)),true,false)
-
 # Ninja has an implicit dependency on the command being run, and kati will
 # regenerate the ninja manifest if any read makefile changes, so there is no
 # need to have dependencies on makefiles.
@@ -165,18 +173,10 @@
 endif
 my_module_path := $(patsubst %/,%,$(my_module_path))
 my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
-
-# my_module_default_path is the path that is automatically chosen according to the attributes of
-# a module. It is used when the module does not explicitly specify install path using LOCAL_MODULE_PATH.
-# If LOCAL_MODULE_PATH is specified, it is always respected and my_module_default_path is
-# ignored. However, for shared libraries, such conflict generates warning so that module owner
-# can place the library in the correct location (, stop using LOCAL_MODULE_PATH, or migrate to Soong to
-# be better).
-my_module_default_path :=
 ifdef LOCAL_IS_HOST_MODULE
   partition_tag :=
 else
-ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
+ifeq (true,$(LOCAL_VENDOR_MODULE))
   partition_tag := _VENDOR
 else ifeq (true,$(LOCAL_OEM_MODULE))
   partition_tag := _OEM
@@ -190,137 +190,20 @@
   partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
 endif
 endif
-install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
-ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
-  install_path_var := $(install_path_var)_PRIVILEGED
-endif
-
-my_module_default_path := $($(install_path_var))
-ifeq ($(strip $(my_module_path)$(my_module_default_path)),)
-  $(call pretty-error,internal error in base_rules.mk; $(install_path_var) is not defined.)
-endif
-
-# Determine lib_type and do some sanity checks.
-ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
-  ifneq ($(filter $(LOCAL_MODULE),$(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES))),)
-    ifneq ($(partition_tag),)
-      $(call pretty-error,"NDK library must be installed at system partition, where other libraries will look for it. It cannot be moved.")
-    endif
-    lib_type := ndk
-  else ifneq ($(filter $(LOCAL_MODULE),$(VNDK_LIBRARIES) $(VNDK_INDIRECT_LIBRARIES)),)
-    ifneq ($(partition_tag),)
-      $(call pretty-error,"VNDK library must be installed at system partition. DO NOT modify VNDK_LIBRARIES or VNDK_LIBRARIES. \
-If your library needs to be shared between system.img and vendor.img then define it as a VNDK-ext library. Use vndk_ext_library {...} \
-in Android.bp to do so.")
-    endif
-    lib_type := vndk
-  else ifneq ($(filter $(LOCAL_MODULE),$(BOARD_SAME_PROCESS_HAL_DEPS)),)
-    # List of libraries implementing same-process HALs (and their internal sub-libraries) is
-    # defined by vendors.
-    ifeq ($(partition_tag),)
-      $(call pretty-error,Sameprocess HAL must not be installed at system partition)
-    endif
-    lib_type := sameprocess_hal
-  else ifeq ($(LOCAL_IS_HOST_MODULE)$(partition_tag),)
-    lib_type := framework
-  else ifneq ($(partition_tag),_DATA)
-    # Here, vendor means vendor/oem/odm
-    lib_type := vendor_provided
-  else
-    # Test, samples lib falls into this. No lib_type required for them.
-    ifeq ($(filter tests samples,$(LOCAL_MODULE_TAGS)),)
-      $(call pretty-warning,Cannot determine the type of this library)
-    endif
-    lib_type :=
-  endif
-else
-  lib_type :=
-endif
-
-# This is the default path until N. From O, the default path is changed.
-# Let's save the old default path in case we need a symlink to it later.
-my_module_pre_o_default_path := $(my_module_default_path)
-
-# Special case for pre_o_default_path of Soong defined modules.
-# For those modules, we guess their pre_o_default_path by removing /ndk, /vndk, etc.
-# from their LOCAL_MODULE_PATH. This is because relative_install_path is already
-# embedded to my_module_path.
-ifeq ($(my_module_is_soong),true)
-ifndef LOCAL_IS_HOST_MODULE
-ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
-  my_module_pre_o_default_path := $(my_module_path)
-  my_module_pre_o_default_path := $(subst /vndk-ext,,$(my_module_pre_o_default_path))
-  my_module_pre_o_default_path := $(subst /vndk,,$(my_module_pre_o_default_path))
-  my_module_pre_o_default_path := $(subst /ndk,,$(my_module_pre_o_default_path))
-  my_module_pre_o_default_path := $(subst /sameprocess,,$(my_module_pre_o_default_path))
-endif
-endif
-endif
-
-# Amend the default_path once again depending on lib_type. This is new from O.
-ifeq ($(lib_type),vndk)
-  my_module_default_path := $(my_module_default_path)/vndk
-  # TODO(b/35020246): before P, we should support installing two snapshots of VNDK
-  # libraries. One for framework libs and execs and the other for vendor libs and execs.
-else ifeq ($(lib_type),ndk)
-  my_module_default_path := $(my_module_default_path)/ndk
-else ifeq ($(lib_type),sameprocess_hal)
-  my_module_default_path := $(my_module_default_path)/sameprocess
-endif
-
-# Relative path is appended to path resolved so far
-ifneq ($(my_module_relative_path),)
-  my_module_default_path := $(my_module_default_path)/$(my_module_relative_path)
-  my_module_pre_o_default_path := $(my_module_pre_o_default_path)/$(my_module_relative_path)
-  ifneq ($(my_module_path),)
-    my_module_path := $(my_module_path)/$(my_module_relative_path)
-  endif
-endif
-
-_lib_moved :=
 ifeq ($(my_module_path),)
-  # If LOCAL_MODULE_PATH is not specified, use the automatically determined path.
-  my_module_path := $(my_module_default_path)
+  install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
+  ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
+    install_path_var := $(install_path_var)_PRIVILEGED
+  endif
 
-  # Mark if the lib is installed to a different path than before. With this hint,
-  # a symlink is created if BOARD_SYMLINK_FOR_LIBS is true.
-  ifneq ($(my_module_path),$(my_module_pre_o_default_path))
-    _lib_moved := true
-  endif
-else
-  # If LOCAL_MODULE_PATH is specified, we respect it.
-  ifndef LOCAL_IS_HOST_MODULE
-  ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
-  ifeq ($(filter $(TARGET_OUT_DATA)%,$(my_module_path)),)
-    # However, we are kind enough to warn if it seems to be wrong.
-    # Warn only for Android.mk defined shared libraries that will be installed
-    # to system or vendor partition. For other types of files - especially
-    # Soong-defined libs -, we don't warn because Soong always gives us correct
-    # paths.
-    ifeq ($(my_module_is_soong),false)
-      ifneq ($(my_module_path),$(my_module_default_path))
-        ifeq ($(SHOW_MODULE_PATH_WARNINGS),true)
-        # TODO(b/35020635): s/warning/error/
-        $(call pretty-warning,$(lib_type) library must be installed to \
-$(subst $(PRODUCT_OUT)/,,$(my_module_default_path)) but requested to be installed at \
-$(subst $(PRODUCT_OUT)/,,$(my_module_path)). Please fix.)
-        endif
-      endif
-    else
-      # For Soong-defined module, symlink is provided if the path has been amended
-      # ...except for vndk-ext libraries because there already is a symlink for the
-      # vndk (unmodified) version of the vndk-ext library.
-      ifneq ($(my_module_path),$(my_module_pre_o_default_path))
-        ifeq ($(filter vndk-ext,$(subst /,$(space),$(my_module_path))),)
-          _lib_moved := true
-        endif
-      endif
-    endif
-  endif
-  endif
+  my_module_path := $($(install_path_var))
+  ifeq ($(strip $(my_module_path)),)
+    $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
   endif
 endif
-
+ifneq ($(my_module_relative_path),)
+  my_module_path := $(my_module_path)/$(my_module_relative_path)
+endif
 endif # not LOCAL_UNINSTALLABLE_MODULE
 
 ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
@@ -511,30 +394,8 @@
 
 # Rule to install the module's companion symlinks
 my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix)))
-
-# If this lib is installed to the different directory than before,
-# make a symlink from the old path to the new path.
-# This symlink is required because there are so many plances that expect the old
-# path (e.g. systemproperty rild.libpath). Until that places are all fixed,
-# we keep this symlink.
-# TODO(b/34917183): remove symlinks after everything migrations to the new paths;
-# this should be done before O launch unless it will be a security hole that
-# we can't restrict access to a certain set of libraries by using the directory
-# path.
-ifneq ($(BOARD_SYMLINK_FOR_LIBS),false)
-ifeq ($(_lib_moved),true)
-  my_installed_symlinks += $(my_module_pre_o_default_path)/$(my_installed_module_stem)
-endif
-else
-# Symlinks for ndk libs are permanent.
-ifeq ($(lib_type)$(_lib_moved),ndktrue)
-  my_installed_symlinks += $(my_module_pre_o_default_path)/$(my_installed_module_stem)
-endif
-endif
-
-# Make a symlink $(symlink) -> $(LOCAL_INSTALLED_MODULE)
 $(foreach symlink,$(my_installed_symlinks),\
-    $(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(LOCAL_INSTALLED_MODULE),$(symlink),true))
+    $(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink)))
 
 $(my_all_targets) : | $(my_installed_symlinks)
 
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 65fc7c8..2e305f7 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -227,6 +227,7 @@
 LOCAL_UNSTRIPPED_PATH:=
 LOCAL_USE_AAPT2:=$(USE_AAPT2)
 LOCAL_USE_VNDK:=
+LOCAL_VENDOR_MODULE:=
 LOCAL_VTSC_FLAGS:=
 LOCAL_VTS_INCLUDES:=
 LOCAL_VTS_MODE:=
diff --git a/core/definitions.mk b/core/definitions.mk
index 4362a8d..159073e 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2110,6 +2110,7 @@
   $(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
   $(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
   $(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
+  $(addprefix -A ,$(PRIVATE_ASSET_DIR)) \
   $(addprefix --java ,$(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
   $(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \
   $(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
@@ -2520,6 +2521,13 @@
 $(filter-out -classpath -bootclasspath "",$(subst :,$(space),$(1)))
 endef
 
+# Takes an sdk version that might be PLATFORM_VERSION_CODENAME (for example P),
+# returns a number greater than the highest existing sdk version if it is, or
+# the input if it is not.
+define codename-or-sdk-to-sdk
+$(if $(filter $(1),$(PLATFORM_VERSION_CODENAME)),10000,$(1))
+endef
+
 define desugar-classes-jar
 @echo Desugar: $@
 @mkdir -p $(dir $@)
@@ -2527,7 +2535,7 @@
 $(hide) java -jar $(DESUGAR) \
     $(addprefix --bootclasspath_entry ,$(call desugar-bootclasspath,$(PRIVATE_BOOTCLASSPATH))) \
     $(addprefix --classpath_entry ,$(PRIVATE_ALL_JAVA_LIBRARIES)) \
-    --min_sdk_version $(PRIVATE_SDK_VERSION) \
+    --min_sdk_version $(call codename-or-sdk-to-sdk,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
     --allow_empty_bootclasspath \
     $(if $(filter --core-library,$(PRIVATE_DX_FLAGS)),--core_library) \
     -i $< -o $@.tmp
@@ -2544,7 +2552,7 @@
 $(hide) $(DX) \
     -JXms16M -JXmx2048M \
     --dex --output=$(dir $@) \
-    --min-sdk-version=$(PRIVATE_SDK_VERSION) \
+    --min-sdk-version=$(call codename-or-sdk-to-sdk,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
     $(if $(NO_OPTIMIZE_DX), \
         --no-optimize) \
     $(if $(GENERATE_DEX_DEBUG), \
@@ -2852,10 +2860,8 @@
 
 # Define a rule to create a symlink to a file.
 # $(1): full path to source
-# $(2): target of the link
-# $(3): full path of the symlink
-# $(4): (optional) when set to true, $(2) is recognized as a path from the build root and
-#       thus -r option is used to link $(3) to $(2). Off by default.
+# $(2): source (may be relative)
+# $(3): full path to destination
 define symlink-file
 $(eval $(_symlink-file))
 endef
@@ -2867,9 +2873,7 @@
 	@echo "Symlink: $$@ -> $(2)"
 	@mkdir -p $(dir $$@)
 	@rm -rf $$@
-	$(if $(filter true,$(4)),\
-            $(hide) python -c "import os.path; import os; os.symlink(os.path.relpath('$(2)','$(dir $(3))'), '$$@')",\
-            $(hide) ln -sf $(2) $$@)
+	$(hide) ln -sf $(2) $$@
 endef
 
 ###########################################################
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index 4ffd6f1..68c46f5 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -128,17 +128,17 @@
 my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
 $(built_odex): $(my_built_profile)
 $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile)
-$(my_built_profile): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
+$(my_built_profile): PRIVATE_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
 $(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location)
 $(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
 $(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
 $(my_built_profile): $(PROFMAN)
-$(my_built_profile): $(LOCAL_INSTALLED_MODULE)
+$(my_built_profile): $(LOCAL_BUILT_MODULE)
 $(my_built_profile):
 	$(hide) mkdir -p $(dir $@)
 	ANDROID_LOG_TAGS="*:e" $(PROFMAN) \
 		--create-profile-from=$(PRIVATE_SOURCE_CLASSES) \
-		--apk=$(PRIVATE_INSTALLED_MODULE) \
+		--apk=$(PRIVATE_BUILT_MODULE) \
 		--dex-location=$(PRIVATE_DEX_LOCATION) \
 		--reference-profile-file=$@
 else
@@ -169,7 +169,7 @@
 DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
 DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
-DEXPREOPT.$(LOCAL_MODULE).PROPRIETARY_MODULE := $(LOCAL_PROPRIETARY_MODULE)
+DEXPREOPT.$(LOCAL_MODULE).VENDOR_MODULE := $(LOCAL_VENDOR_MODULE)
 DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
 DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex)
 DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
diff --git a/core/java.mk b/core/java.mk
index 2864e56..175311c 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -466,12 +466,14 @@
 my_desugaring :=
 ifndef LOCAL_JACK_ENABLED
 ifeq ($(LOCAL_JAVA_LANGUAGE_VERSION),1.8)
+ifndef LOCAL_IS_STATIC_JAVA_LIBRARY
 my_desugaring := true
 $(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
 $(full_classes_desugar_jar): $(full_classes_compiled_jar) $(DESUGAR)
 	$(desugar-classes-jar)
 endif
 endif
+endif
 
 ifndef my_desugaring
 full_classes_desugar_jar := $(full_classes_compiled_jar)
diff --git a/core/local_vndk.mk b/core/local_vndk.mk
index f7970f0..5ac5f26 100644
--- a/core/local_vndk.mk
+++ b/core/local_vndk.mk
@@ -3,7 +3,7 @@
 #If LOCAL_SDK_VERSION is set, thats a more restrictive set, so they dont need LOCAL_USE_VNDK
 ifndef LOCAL_IS_HOST_MODULE
 ifndef LOCAL_SDK_VERSION
-  ifneq (,$(filter true,$(LOCAL_PROPRIETARY_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_OEM_MODULE)))
+  ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_OEM_MODULE)))
     LOCAL_USE_VNDK:=true
   else
     ifneq (,$(filter $(TARGET_OUT_VENDOR)%,$(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64)))
diff --git a/core/main.mk b/core/main.mk
index 0e4af4f..4fbfc73 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -10,9 +10,6 @@
 endif
 
 ifndef KATI
-USE_SOONG_UI ?= true
-endif
-ifeq ($(USE_SOONG_UI),true)
 
 host_prebuilts := linux-x86
 ifeq ($(shell uname),Darwin)
@@ -27,7 +24,7 @@
 $(sort $(MAKECMDGOALS)) : run_soong_ui
 	@#empty
 
-else # USE_SOONG_UI
+else # KATI
 
 # Absolute path of the present working direcotry.
 # This overrides the shell variable $PWD, which does not necessarily points to
@@ -47,23 +44,10 @@
 .PHONY: droid_targets
 droid_targets:
 
-# Targets that provide quick help on the build system.
-include $(BUILD_SYSTEM)/help.mk
-
 # Set up various standard variables based on configuration
 # and host information.
 include $(BUILD_SYSTEM)/config.mk
 
-ifndef KATI
-ifdef USE_NINJA
-$(warning USE_NINJA is ignored. Ninja is always used.)
-endif
-
-# Mark this is a ninja build.
-$(shell mkdir -p $(OUT_DIR) && touch $(OUT_DIR)/ninja_build)
-include build/core/ninja.mk
-else # KATI
-
 ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
 dont_bother := true
 endif
@@ -276,7 +260,7 @@
   ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
 endif
 
-ifneq ($(ENABLE_TREBLE), true)
+ifneq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
   ADDITIONAL_BUILD_PROPERTIES += $(PRODUCT_PROPERTY_OVERRIDES)
 else
   ifndef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
@@ -1166,4 +1150,3 @@
 all_link_types:
 
 endif # KATI
-endif # USE_SOONG_UI
diff --git a/core/ninja.mk b/core/ninja.mk
deleted file mode 100644
index af2ede0..0000000
--- a/core/ninja.mk
+++ /dev/null
@@ -1,103 +0,0 @@
-include $(BUILD_SYSTEM)/soong.mk
-
-# Modifier goals we don't need to pass to Ninja.
-.PHONY : $(NINJA_EXCLUDE_GOALS)
-
-define replace_space_and_slash
-$(subst /,_,$(subst $(space),_,$(sort $1)))
-endef
-
-KATI_NINJA_SUFFIX := -$(TARGET_PRODUCT)
-ifneq ($(KATI_GOALS),)
-KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-$(call replace_space_and_slash,$(KATI_GOALS))
-endif
-ifneq ($(ONE_SHOT_MAKEFILE),)
-KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmm-$(call replace_space_and_slash,$(ONE_SHOT_MAKEFILE))
-endif
-
-my_checksum_suffix :=
-my_ninja_suffix_too_long := $(filter 1, $(shell v='$(KATI_NINJA_SUFFIX)' && echo $$(($${$(pound)v} > 64))))
-ifneq ($(my_ninja_suffix_too_long),)
-# Replace the suffix with a checksum if it gets too long.
-my_checksum_suffix := $(KATI_NINJA_SUFFIX)
-KATI_NINJA_SUFFIX := -$(word 1, $(shell echo $(my_checksum_suffix) | $(MD5SUM)))
-endif
-
-KATI_BUILD_NINJA := $(OUT_DIR)/build$(KATI_NINJA_SUFFIX).ninja
-KATI_ENV_SH := $(OUT_DIR)/env$(KATI_NINJA_SUFFIX).sh
-
-# Write out a file mapping checksum to the real suffix.
-ifneq ($(my_checksum_suffix),)
-my_ninja_suffix_file := $(basename $(KATI_BUILD_NINJA)).suf
-$(shell mkdir -p $(dir $(my_ninja_suffix_file)) && \
-    echo $(my_checksum_suffix) > $(my_ninja_suffix_file))
-endif
-
-ifeq (,$(NINJA_STATUS))
-NINJA_STATUS := [%p %f/%t]$(space)
-endif
-
-NINJA_EXTRA_ARGS :=
-
-ifneq (,$(filter showcommands,$(ORIGINAL_MAKECMDGOALS)))
-NINJA_EXTRA_ARGS += "-v"
-endif
-
-# Make multiple rules to generate the same target an error instead of
-# proceeding with undefined behavior.
-NINJA_EXTRA_ARGS += -w dupbuild=err
-
-ifneq ($(filter-out false,$(USE_GOMA)),)
-KATI_MAKEPARALLEL := $(MAKEPARALLEL)
-# Ninja runs remote jobs (i.e., commands which contain gomacc) with
-# this parallelism. Note the parallelism of all other jobs is still
-# limited by the -j flag passed to GNU make.
-NINJA_REMOTE_NUM_JOBS ?= 500
-NINJA_EXTRA_ARGS += -j$(NINJA_REMOTE_NUM_JOBS)
-else
-NINJA_MAKEPARALLEL := $(MAKEPARALLEL) --ninja
-
-# We never want Kati to see MAKEFLAGS, as forcefully overriding variables is
-# terrible. The variables in MAKEFLAGS are still available in the environment,
-# so if part of the build wants input from the user, it should be explicitly
-# checking for an environment variable or using ?=
-#
-# makeparallel already clears MAKEFLAGS, so it's not necessary in the GOMA case
-KATI_MAKEPARALLEL := MAKEFLAGS=
-endif
-
-NINJA_ARGS += $(NINJA_EXTRA_ARGS)
-
-COMBINED_BUILD_NINJA := $(OUT_DIR)/combined$(KATI_NINJA_SUFFIX).ninja
-
-$(COMBINED_BUILD_NINJA): $(KATI_BUILD_NINJA) FORCE
-	$(hide) echo "builddir = $(OUT_DIR)" > $(COMBINED_BUILD_NINJA)
-	$(hide) echo "include $(KATI_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
-	$(hide) echo "include $(SOONG_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
-	$(hide) echo "build $(COMBINED_BUILD_NINJA): phony $(SOONG_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
-
-$(sort $(DEFAULT_GOAL) $(ANDROID_GOALS)) : ninja_wrapper
-	@#empty
-
-.PHONY: ninja_wrapper
-ninja_wrapper: $(COMBINED_BUILD_NINJA) $(MAKEPARALLEL)
-	@echo Starting build with ninja
-	+$(hide) export NINJA_STATUS="$(NINJA_STATUS)" && source $(KATI_ENV_SH) && exec $(NINJA_MAKEPARALLEL) $(NINJA) -d keepdepfile $(NINJA_GOALS) -C $(TOP) -f $(COMBINED_BUILD_NINJA) $(NINJA_ARGS)
-
-# Dummy Android.mk and CleanSpec.mk files so that kati won't recurse into the
-# out directory
-DUMMY_OUT_MKS := $(OUT_DIR)/Android.mk $(OUT_DIR)/CleanSpec.mk
-$(DUMMY_OUT_MKS):
-	@mkdir -p $(dir $@)
-	$(hide) echo '# This file prevents findleaves.py from traversing this directory further' >$@
-
-KATI_FIND_EMULATOR := --use_find_emulator
-ifeq ($(KATI_EMULATE_FIND),false)
-  KATI_FIND_EMULATOR :=
-endif
-$(KATI_BUILD_NINJA): $(CKATI) $(MAKEPARALLEL) $(DUMMY_OUT_MKS) run_soong FORCE
-	@echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
-	+$(hide) $(KATI_MAKEPARALLEL) $(CKATI) --ninja --ninja_dir=$(OUT_DIR) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo $(KATI_FIND_EMULATOR) -f build/core/main.mk $(KATI_GOALS) --gen_all_targets BUILDING_WITH_NINJA=true SOONG_ANDROID_MK=$(SOONG_ANDROID_MK) SOONG_MAKEVARS_MK=$(SOONG_MAKEVARS_MK)
-
-.PHONY: FORCE
-FORCE:
diff --git a/core/package_internal.mk b/core/package_internal.mk
index e26b3c7..8a31552 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -380,6 +380,8 @@
 my_compiled_res_base_dir := $(intermediates)/flat-res
 my_generated_res_dirs := $(rs_generated_res_dir)
 my_generated_res_dirs_deps := $(RenderScript_file_stamp)
+my_asset_dirs := $(LOCAL_ASSET_DIR)
+my_full_asset_paths := $(all_assets)
 # Add AAPT2 link specific flags.
 $(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --no-static-lib-packages
 include $(BUILD_SYSTEM)/aapt2.mk
diff --git a/core/pdk_fusion_modules.mk b/core/pdk_fusion_modules.mk
index 49b30dc..0c03f37 100644
--- a/core/pdk_fusion_modules.mk
+++ b/core/pdk_fusion_modules.mk
@@ -23,7 +23,7 @@
 LOCAL_BUILT_MODULE_STEM:=$(7)
 LOCAL_MODULE_SUFFIX:=$(suffix $(7))
 LOCAL_PRIVILEGED_MODULE:=$(8)
-LOCAL_PROPRIETARY_MODULE:=$(9)
+LOCAL_VENDOR_MODULE:=$(9)
 LOCAL_MODULE_TARGET_ARCH:=$(10)
 LOCAL_REPLACE_PREBUILT_APK_INSTALLED:=$(11)
 LOCAL_CERTIFICATE:=PRESIGNED
@@ -72,7 +72,7 @@
     $(PDK.DEXPREOPT.$(a).DEX_PREOPT_FLAGS),\
     package.apk,\
     $(PDK.DEXPREOPT.$(a).PRIVILEGED_MODULE),\
-    $(PDK.DEXPREOPT.$(a).PROPRIETARY_MODULE),\
+    $(PDK.DEXPREOPT.$(a).VENDOR_MODULE),\
     $(PDK.DEXPREOPT.$(a).TARGET_ARCH),\
     $(_pdk_fusion_intermediates)/$(PDK.DEXPREOPT.$(a).STRIPPED_SRC),\
     )))
diff --git a/core/soong.mk b/core/soong.mk
deleted file mode 100644
index 4a74f2e..0000000
--- a/core/soong.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-# We need to rebootstrap soong if SOONG_OUT_DIR or the reverse path from
-# SOONG_OUT_DIR to TOP changes
-SOONG_NEEDS_REBOOTSTRAP :=
-ifneq ($(wildcard $(SOONG_BOOTSTRAP)),)
-  ifneq ($(SOONG_OUT_DIR),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$BUILDDIR)))
-    SOONG_NEEDS_REBOOTSTRAP := FORCE
-    $(warning soong_out_dir changed)
-  endif
-  ifneq ($(strip $(shell build/soong/scripts/reverse_path.py $(SOONG_OUT_DIR))),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$SRCDIR_FROM_BUILDDIR)))
-    SOONG_NEEDS_REBOOTSTRAP := FORCE
-    $(warning reverse path changed)
-  endif
-endif
-
-# Bootstrap soong.
-$(SOONG_BOOTSTRAP): bootstrap.bash $(SOONG_NEEDS_REBOOTSTRAP)
-	$(hide) mkdir -p $(dir $@)
-	$(hide) BUILDDIR=$(SOONG_OUT_DIR) ./bootstrap.bash
-
-# Tell soong that it is embedded in make
-$(SOONG_IN_MAKE):
-	$(hide) mkdir -p $(dir $@)
-	$(hide) touch $@
-
-# Run Soong, this implicitly create an Android.mk listing all soong outputs as
-# prebuilts.
-.PHONY: run_soong
-run_soong: $(SOONG_BOOTSTRAP) $(SOONG_VARIABLES) $(SOONG_IN_MAKE) FORCE
-	$(hide) SKIP_NINJA=true $(SOONG)
diff --git a/core/soong_config.mk b/core/soong_config.mk
index ff8a51d..576c8ab 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -69,9 +69,7 @@
 	echo ''; \
 	echo '    "ArtUseReadBarrier": $(if $(filter false,$(PRODUCT_ART_USE_READ_BARRIER)),false,true),'; \
 	echo ''; \
-	echo '    "BtConfigIncludeDir": "$(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)",'; \
-	echo ''; \
-	echo '    "SameProcessHalDeps": [$(if $(BOARD_SAME_PROCESS_HAL_DEPS),"$(subst $(space),"$(comma)",$(BOARD_SAME_PROCESS_HAL_DEPS))")]'; \
+	echo '    "BtConfigIncludeDir": "$(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)"'; \
 	echo '}') > $(SOONG_VARIABLES_TMP); \
 	if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
 	  mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \
diff --git a/core/tasks/device-tests.mk b/core/tasks/device-tests.mk
index a0662ca..731937f 100644
--- a/core/tasks/device-tests.mk
+++ b/core/tasks/device-tests.mk
@@ -14,4 +14,14 @@
 
 
 .PHONY: device-tests
-device-tests: $(COMPATIBILITY.device-tests.FILES)
+
+device-tests-zip := $(PRODUCT_OUT)/device-tests.zip
+$(device-tests-zip): $(COMPATIBILITY.device-tests.FILES) $(SOONG_ZIP)
+	echo $(COMPATIBILITY.device-tests.FILES) > $@.list
+	sed -i -e 's/\s\+/\n/g' $@.list
+	grep $(HOST_OUT_TESTCASES) $@.list > $@-host.list || true
+	grep $(TARGET_OUT_TESTCASES) $@.list > $@-target.list || true
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(HOST_OUT) -l $@-host.list -C $(PRODUCT_OUT) -l $@-target.list
+
+device-tests: $(device-tests-zip)
+$(call dist-for-goals, device-tests, $(device-tests-zip))
diff --git a/core/tasks/general-tests.mk b/core/tasks/general-tests.mk
index ddaede4..e02faa7 100644
--- a/core/tasks/general-tests.mk
+++ b/core/tasks/general-tests.mk
@@ -13,4 +13,14 @@
 # limitations under the License.
 
 .PHONY: general-tests
-device-tests: $(COMPATIBILITY.general-tests.FILES)
+
+general-tests-zip := $(PRODUCT_OUT)/general-tests.zip
+$(general-tests-zip): $(COMPATIBILITY.general-tests.FILES) $(SOONG_ZIP)
+	echo $(COMPATIBILITY.general-tests.FILES) > $@.list
+	sed -i -e 's/\s\+/\n/g' $@.list
+	grep $(HOST_OUT_TESTCASES) $@.list > $@-host.list || true
+	grep $(TARGET_OUT_TESTCASES) $@.list > $@-target.list || true
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(HOST_OUT) -l $@-host.list -C $(PRODUCT_OUT) -l $@-target.list
+
+general-tests: $(general-tests-zip)
+$(call dist-for-goals, general-tests, $(general-tests-zip))
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 6b19ad2..03629b2 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -52,17 +52,22 @@
 #$(warning $(call find_and_earlier,A B C,D))
 
 define version-list
-$(1) $(1)DR1 $(1)DR2 $(1)MR1 $(1)MR2
+$(1)PR1 $(1)PD1 $(1)PD2 $(1)PM1 $(1)PM2
 endef
 
 ALL_VERSIONS := O P
 ALL_VERSIONS := $(foreach v,$(ALL_VERSIONS),$(call version-list,$(v)))
 
+# HACK: forward P to PPR1 until the build server config is updated
+ifeq (P,$(TARGET_PLATFORM_VERSION))
+  TARGET_PLATFORM_VERSION := PPR1
+endif
+
 ifeq (,$(TARGET_PLATFORM_VERSION))
   # Default targeted platform version
   # TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional
   # on this
-  TARGET_PLATFORM_VERSION := O
+  TARGET_PLATFORM_VERSION := OPR1
 endif
 
 ifeq (,$(filter $(ALL_VERSIONS), $(TARGET_PLATFORM_VERSION)))
@@ -91,11 +96,13 @@
 # When you change PLATFORM_VERSION for a given PLATFORM_SDK_VERSION
 # please add that PLATFORM_VERSION to the following text file:
 # cts/tests/tests/os/assets/platform_versions.txt
-PLATFORM_VERSION.O := O
+PLATFORM_VERSION.OPR1 := O
+PLATFORM_VERSION.PPR1 := P
 
 # This is the current development code-name, if the build is not a final
 # release build.  If this is a final release build, it is simply "REL".
-PLATFORM_VERSION_CODENAME.O := O
+PLATFORM_VERSION_CODENAME.OPR1 := O
+PLATFORM_VERSION_CODENAME.PPR1 := P
 
 ifndef PLATFORM_VERSION
   PLATFORM_VERSION := $(PLATFORM_VERSION.$(TARGET_PLATFORM_VERSION))
diff --git a/target/board/generic/sepolicy/logpersist.te b/target/board/generic/sepolicy/logpersist.te
index 0c52986..3fc0250 100644
--- a/target/board/generic/sepolicy/logpersist.te
+++ b/target/board/generic/sepolicy/logpersist.te
@@ -10,3 +10,4 @@
 
 # Write to /dev/ttyS2 and /dev/ttyGF2.
 allow logpersist serial_device:chr_file { write open };
+get_prop(logpersist, qemu_cmdline)
diff --git a/target/board/generic/sepolicy/property.te b/target/board/generic/sepolicy/property.te
index 22d580a..a486702 100644
--- a/target/board/generic/sepolicy/property.te
+++ b/target/board/generic/sepolicy/property.te
@@ -1,3 +1,4 @@
 type qemu_prop, property_type;
+type qemu_cmdline, property_type;
 type radio_noril_prop, property_type;
 type opengles_prop, property_type;
diff --git a/target/board/generic/sepolicy/property_contexts b/target/board/generic/sepolicy/property_contexts
index 142b062..c66a85f 100644
--- a/target/board/generic/sepolicy/property_contexts
+++ b/target/board/generic/sepolicy/property_contexts
@@ -1,4 +1,5 @@
 qemu.                   u:object_r:qemu_prop:s0
+qemu.cmdline            u:object_r:qemu_cmdline:s0
 ro.emu.                 u:object_r:qemu_prop:s0
 ro.emulator.            u:object_r:qemu_prop:s0
 ro.radio.noril          u:object_r:radio_noril_prop:s0
diff --git a/target/board/generic/sepolicy/qemu_props.te b/target/board/generic/sepolicy/qemu_props.te
index 6768ce7..95174d6 100644
--- a/target/board/generic/sepolicy/qemu_props.te
+++ b/target/board/generic/sepolicy/qemu_props.te
@@ -9,3 +9,4 @@
 set_prop(qemu_props, dalvik_prop)
 set_prop(qemu_props, config_prop)
 set_prop(qemu_props, opengles_prop)
+set_prop(qemu_props, qemu_cmdline)
diff --git a/target/board/generic_arm64_ab/BoardConfig.mk b/target/board/generic_arm64_ab/BoardConfig.mk
index 6da54dc..8c38ac7 100644
--- a/target/board/generic_arm64_ab/BoardConfig.mk
+++ b/target/board/generic_arm64_ab/BoardConfig.mk
@@ -88,3 +88,5 @@
 # Must be moved after early-mount is supported.
 ###############################################################################
 BOARD_SEPOLICY_DIRS += device/google/marlin/sepolicy
+
+BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
diff --git a/target/product/aosp_arm64_ab.mk b/target/product/aosp_arm64_ab.mk
index 87cb709..6a7023e 100644
--- a/target/product/aosp_arm64_ab.mk
+++ b/target/product/aosp_arm64_ab.mk
@@ -98,6 +98,7 @@
     android.hidl.memory@1.0 \
 
 PRODUCT_PACKAGES += \
+    libdynamic_sensor_ext \
     libxml2 \
     libtinyalsa \
     libtinycompress \
diff --git a/target/product/base.mk b/target/product/base.mk
index 6848acf..f449c39 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -59,6 +59,7 @@
     libcamera2ndk \
     libdl \
     libdrmclearkeyplugin \
+    libclearkeycasplugin \
     libeffectproxy \
     libeffects \
     libinput \
@@ -109,7 +110,6 @@
     mediadrmserver \
     mediaserver \
     mediametrics \
-    mediacodec \
     mediaextractor \
     monkey \
     mtpd \
@@ -137,6 +137,10 @@
     vold \
     wm
 
+# Essential HAL modules
+PRODUCT_PACKAGES += \
+    android.hardware.media.omx@1.0-service
+
 # Packages included only for eng or userdebug builds, previously debug tagged
 PRODUCT_PACKAGES_DEBUG := \
     perfprofd
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index f55d9a9..5ee297a 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -20,7 +20,6 @@
 PRODUCT_PACKAGES += \
     adb \
     adbd \
-    android.hardware.configstore@1.0-impl \
     android.hardware.configstore@1.0-service \
     android.hidl.allocator@1.0-service \
     android.hidl.memory@1.0-impl \
diff --git a/target/product/emulator.mk b/target/product/emulator.mk
index b6e83ec..6226677 100644
--- a/target/product/emulator.mk
+++ b/target/product/emulator.mk
@@ -53,7 +53,9 @@
     power.goldfish \
     fingerprint.ranchu \
     android.hardware.biometrics.fingerprint@2.1-service \
-    sensors.ranchu
+    sensors.ranchu \
+	hwcomposer.goldfish \
+	hwcomposer.ranchu \
 
 PRODUCT_PACKAGES += \
     android.hardware.audio@2.0-impl \
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 0b8f3a0..2b7aee4 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -404,7 +404,6 @@
     images_dir = None
 
   has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true")
-  system_root_image = (OPTIONS.info_dict.get("system_root_image", None) == "true")
 
   def banner(s):
     print("\n\n++++ " + s + " ++++\n\n")
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index d8fcc41..e385866 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -36,23 +36,21 @@
 
 
 def compute_patch(srcfile, tgtfile, imgdiff=False):
-  patchfile = common.MakeTempFile(prefix="patch-")
+  patchfile = common.MakeTempFile(prefix='patch-')
 
-  if imgdiff:
-    p = subprocess.call(
-        ["imgdiff", "-z", srcfile, tgtfile, patchfile],
-        stdout=open(os.devnull, 'w'),
-        stderr=subprocess.STDOUT)
-  else:
-    p = subprocess.call(
-        ["bsdiff", srcfile, tgtfile, patchfile],
-        stdout=open(os.devnull, 'w'),
-        stderr=subprocess.STDOUT)
+  cmd = ['imgdiff', '-z'] if imgdiff else ['bsdiff']
+  cmd.extend([srcfile, tgtfile, patchfile])
 
-  if p:
-    raise ValueError("diff failed: " + str(p))
+  # Not using common.Run(), which would otherwise dump all the bsdiff/imgdiff
+  # commands when OPTIONS.verbose is True - not useful for the case here, since
+  # they contain temp filenames only.
+  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+  output, _ = p.communicate()
 
-  with open(patchfile, "rb") as f:
+  if p.returncode != 0:
+    raise ValueError(output)
+
+  with open(patchfile, 'rb') as f:
     return f.read()
 
 
@@ -718,6 +716,7 @@
 
       diff_total = len(diff_queue)
       patches = [None] * diff_total
+      error_messages = []
       if sys.stdout.isatty():
         global diff_done
         diff_done = 0
@@ -754,9 +753,13 @@
           try:
             patch = compute_patch(src_file, tgt_file, imgdiff)
           except ValueError as e:
-            raise ValueError(
-                "Failed to generate diff for %s: src=%s, tgt=%s: %s" % (
-                    xf.tgt_name, xf.src_ranges, xf.tgt_ranges, e.message))
+            with lock:
+              error_messages.append(
+                  "Failed to generate %s for %s: tgt=%s, src=%s:\n%s" % (
+                      "imgdiff" if imgdiff else "bsdiff",
+                      xf.tgt_name if xf.tgt_name == xf.src_name else
+                          xf.tgt_name + " (from " + xf.src_name + ")",
+                      xf.tgt_ranges, xf.src_ranges, e.message))
 
           with lock:
             patches[patch_index] = (xf_index, patch)
@@ -777,6 +780,10 @@
 
       if sys.stdout.isatty():
         print('\n')
+
+      if error_messages:
+        print('\n'.join(error_messages))
+        sys.exit(1)
     else:
       patches = []
 
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 8222377..f75bb96 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -180,6 +180,7 @@
 OPTIONS.log_diff = None
 OPTIONS.payload_signer = None
 OPTIONS.payload_signer_args = []
+OPTIONS.extracted_input = None
 
 METADATA_NAME = 'META-INF/com/android/metadata'
 UNZIP_PATTERN = ['IMAGES/*', 'META/*']
@@ -1235,6 +1236,8 @@
       OPTIONS.payload_signer = a
     elif o == "--payload_signer_args":
       OPTIONS.payload_signer_args = shlex.split(a)
+    elif o == "--extracted_input_target_files":
+      OPTIONS.extracted_input = a
     else:
       return False
     return True
@@ -1265,6 +1268,7 @@
                                  "log_diff=",
                                  "payload_signer=",
                                  "payload_signer_args=",
+                                 "extracted_input_target_files=",
                              ], extra_option_handler=option_handler)
 
   if len(args) != 2:
@@ -1287,9 +1291,12 @@
 
   # Load the dict file from the zip directly to have a peek at the OTA type.
   # For packages using A/B update, unzipping is not needed.
-  input_zip = zipfile.ZipFile(args[0], "r")
-  OPTIONS.info_dict = common.LoadInfoDict(input_zip)
-  common.ZipClose(input_zip)
+  if OPTIONS.extracted_input is not None:
+    OPTIONS.info_dict = common.LoadInfoDict(OPTIONS.extracted_input, OPTIONS.extracted_input)
+  else:
+    input_zip = zipfile.ZipFile(args[0], "r")
+    OPTIONS.info_dict = common.LoadInfoDict(input_zip)
+    common.ZipClose(input_zip)
 
   ab_update = OPTIONS.info_dict.get("ab_update") == "true"
 
@@ -1319,12 +1326,18 @@
   if OPTIONS.extra_script is not None:
     OPTIONS.extra_script = open(OPTIONS.extra_script).read()
 
-  print("unzipping target target-files...")
-  OPTIONS.input_tmp, input_zip = common.UnzipTemp(
-      args[0], UNZIP_PATTERN)
+  if OPTIONS.extracted_input is not None:
+    OPTIONS.input_tmp = OPTIONS.extracted_input
+    OPTIONS.target_tmp = OPTIONS.input_tmp
+    OPTIONS.info_dict = common.LoadInfoDict(OPTIONS.input_tmp, OPTIONS.input_tmp)
+    input_zip = zipfile.ZipFile(args[0], "r")
+  else:
+    print("unzipping target target-files...")
+    OPTIONS.input_tmp, input_zip = common.UnzipTemp(
+        args[0], UNZIP_PATTERN)
 
-  OPTIONS.target_tmp = OPTIONS.input_tmp
-  OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp)
+    OPTIONS.target_tmp = OPTIONS.input_tmp
+    OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp)
 
   if OPTIONS.verbose:
     print("--- target info ---")