Merge "Add components to enable CFI for." into pi-dev
diff --git a/core/binary.mk b/core/binary.mk
index 97429c3..954df1f 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1330,6 +1330,15 @@
   endif
 endif
 
+# Platform can use vendor public libraries. If a required shared lib is one of
+# the vendor public libraries, the lib is switched to the stub version of the lib.
+ifeq ($(LOCAL_USE_VNDK),)
+  ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+    my_shared_libraries := $(foreach l,$(my_shared_libraries),\
+      $(if $(filter $(l),$(VENDOR_PUBLIC_LIBRARIES)),$(l).vendorpublic,$(l)))
+  endif
+endif
+
 ##########################################################
 ## Set up installed module dependency
 ## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
diff --git a/core/config.mk b/core/config.mk
index 800a7fc..d9f14fa 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -888,11 +888,13 @@
 ifneq ($(sepolicy_major_vers), $(PLATFORM_SDK_VERSION))
 $(error sepolicy_major_version does not match PLATFORM_SDK_VERSION, please update.)
 endif
+
+TOT_SEPOLICY_VERSION := 10000.0
 ifneq (REL,$(PLATFORM_VERSION_CODENAME))
-    sepolicy_major_vers := 10000
-    sepolicy_minor_vers := 0
+    PLATFORM_SEPOLICY_VERSION := $(TOT_SEPOLICY_VERSION)
+else
+    PLATFORM_SEPOLICY_VERSION := $(join $(addsuffix .,$(sepolicy_major_vers)), $(sepolicy_minor_vers))
 endif
-PLATFORM_SEPOLICY_VERSION := $(join $(addsuffix .,$(sepolicy_major_vers)), $(sepolicy_minor_vers))
 sepolicy_major_vers :=
 sepolicy_minor_vers :=
 
@@ -901,6 +903,11 @@
     26.0 \
     27.0
 
+.KATI_READONLY := \
+    PLATFORM_SEPOLICY_COMPAT_VERSIONS \
+    PLATFORM_SEPOLICY_VERSION \
+    TOT_SEPOLICY_VERSION \
+
 # ###############################################################
 # Set up final options.
 # ###############################################################
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 32295ab..750254f 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -102,16 +102,10 @@
 	$(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \
             -stripDir META-INF -zipToNotStrip $< $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES))
 
-#######################################
-LOCAL_JETIFIER_INPUT_FILE := $(full_classes_combined_jar)
-
-include $(BUILD_SYSTEM)/jetifier.mk
-#######################################
-
 # Run jarjar if necessary, otherwise just copy the file.
 ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
 $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
-$(full_classes_jarjar_jar): $(LOCAL_JETIFIER_OUTPUT_FILE) $(LOCAL_JARJAR_RULES) | $(JARJAR)
+$(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
 	@echo JarJar: $@
 	$(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
 else
diff --git a/core/java.mk b/core/java.mk
index 3eb9086..9147849 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -358,13 +358,7 @@
 full_classes_jarjar_jar := $(full_classes_processed_jar)
 endif
 
-#######################################
-LOCAL_JETIFIER_INPUT_FILE := $(full_classes_jarjar_jar)
-
-include $(BUILD_SYSTEM)/jetifier.mk
-#######################################
-
-$(eval $(call copy-one-file,$(LOCAL_JETIFIER_OUTPUT_FILE),$(full_classes_jar)))
+$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
 
 #######################################
 LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar)
diff --git a/core/jetifier.mk b/core/jetifier.mk
index 305c9dd..33a4624 100644
--- a/core/jetifier.mk
+++ b/core/jetifier.mk
@@ -20,7 +20,7 @@
 ifeq ($(strip $(LOCAL_JETIFIER_ENABLED)),true)
   my_jetifier_input_path := $(LOCAL_JETIFIER_INPUT_FILE)
   my_files := $(intermediates.COMMON)/jetifier
-  my_jetifier_output_path := $(my_files)/classes-jetifier.jar
+  my_jetifier_output_path := $(my_files)/jetified-$(notdir $(my_jetifier_input_path))
 
 $(my_jetifier_output_path) : $(my_jetifier_input_path) $(JETIFIER)
 	rm -rf $@
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 96e2613..0efda57 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -571,6 +571,12 @@
 my_src_aar := $(filter %.aar, $(my_prebuilt_src_file))
 ifneq ($(my_src_aar),)
 # This is .aar file, archive of classes.jar and Android resources.
+
+# run Jetifier if needed
+LOCAL_JETIFIER_INPUT_FILE := $(my_src_aar)
+include $(BUILD_SYSTEM)/jetifier.mk
+my_src_aar := $(LOCAL_JETIFIER_OUTPUT_FILE)
+
 my_src_jar := $(intermediates.COMMON)/aar/classes.jar
 my_src_proguard_options := $(intermediates.COMMON)/aar/proguard.txt
 
@@ -582,6 +588,12 @@
 	$(hide) touch $@
 	# Make sure the proguard file exists and has a new timestamp.
 	$(hide) touch $(dir $@)/proguard.txt
+else
+
+# run Jetifier if needed
+LOCAL_JETIFIER_INPUT_FILE := $(my_src_jar)
+include $(BUILD_SYSTEM)/jetifier.mk
+my_src_jar := $(LOCAL_JETIFIER_OUTPUT_FILE)
 
 endif
 
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index 8f277f2..6d7ac4a 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -84,11 +84,8 @@
         pm.dexopt.boot=verify
 endif
 
-# The install filter is speed-profile in order to enable the use of
-# profiles from the dex metadata files. Note that if a profile is not provided
-# or if it is empty speed-profile is equivalent to quicken.
 PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
-    pm.dexopt.install=speed-profile \
+    pm.dexopt.install=quicken \
     pm.dexopt.bg-dexopt=speed-profile \
     pm.dexopt.ab-ota=speed-profile \
     pm.dexopt.inactive=verify \