Merge tag 'android-14.0.0_r50' into leaf-3.2

Android 14.0.0 Release 50 (AP2A.240605.024)

* tag 'android-14.0.0_r50': (355 commits)
  release-config: sync from goog/main
  Merge "Add secretkeeper-v1-java to platform APIs" into main am: f28b5697b8 am: 196729ffda
  Create rule to generate the exportable api files when checkapi is disabled
  Revert "Additional cleanup prior to adding the runtime stubs"
  Revert "Generate runtime stubs in droidstubs"
  Support partial module variants with apex_contributions
  Fix non-determinism in prebuilt selection
  Use BaseModuleName for LOCAL_MODULE
  Disable source javalib dexpreopt when using prebuilt apex
  Allow clippy::disallowed_names since it can be used for debugging
  Add the build flags for apex contribution contents
  Add a source_module_name to android_app
  Revert "Fix non-determinism in prebuilt selection"
  Fix non-determinism in prebuilt selection
  Copy imported APKs to output filename
  disablePrebuilt: also clear sanitizer-dependent Srcs
  Define libc++ config macros to nothing
  Remove --multitree-build
  Some tweaks to the aconfig flag collection logic
  Use R.txt files from aar files directly
  ...

Change-Id: I7c536315dd82ae00be6798089e7007e08c594606
diff --git a/android/config.go b/android/config.go
index 396b685..f72fc9c 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1443,6 +1443,10 @@
 	return c.config.productVariables.DeviceKernelHeaders
 }
 
+func (c *deviceConfig) TargetSpecificHeaderPath() string {
+	return String(c.config.productVariables.TargetSpecificHeaderPath)
+}
+
 // JavaCoverageEnabledForPath returns whether Java code coverage is enabled for
 // path. Coverage is enabled by default when the product variable
 // JavaCoveragePaths is empty. If JavaCoveragePaths is not empty, coverage is
diff --git a/android/namespace.go b/android/namespace.go
index ebf85a1..3b9ae3a 100644
--- a/android/namespace.go
+++ b/android/namespace.go
@@ -156,6 +156,9 @@
 			return fmt.Errorf("a namespace must be the first module in the file")
 		}
 	}
+	if (namespace.exportToKati) {
+		r.rootNamespace.visibleNamespaces = append(r.rootNamespace.visibleNamespaces, namespace)
+	}
 	r.sortedNamespaces.add(namespace)
 
 	r.namespacesByDir.Store(namespace.Path, namespace)
diff --git a/android/variable.go b/android/variable.go
index df2f8d4..47c6029 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -146,6 +146,7 @@
 		Eng struct {
 			Cflags   []string
 			Cppflags []string
+			Init_rc  []string
 			Lto      struct {
 				Never *bool
 			}
@@ -353,6 +354,8 @@
 
 	DeviceKernelHeaders []string `json:",omitempty"`
 
+	TargetSpecificHeaderPath *string `json:",omitempty"`
+
 	ExtraVndkVersions []string `json:",omitempty"`
 
 	NamespacesToExport []string `json:",omitempty"`
diff --git a/androidmk/androidmk/android.go b/androidmk/androidmk/android.go
index 9d61e1c..0572ee8 100644
--- a/androidmk/androidmk/android.go
+++ b/androidmk/androidmk/android.go
@@ -762,6 +762,13 @@
 	return includeVariableNow(bpVariable{"cflags", bpparser.ListType}, ctx)
 }
 
+func exportCflags(ctx variableAssignmentContext) error {
+	// The Soong replacement for EXPORT_CFLAGS doesn't need the same extra escaped quotes that were present in Make
+	ctx.mkvalue = ctx.mkvalue.Clone()
+	ctx.mkvalue.ReplaceLiteral(`\"`, `"`)
+	return includeVariableNow(bpVariable{"export_cflags", bpparser.ListType}, ctx)
+}
+
 func protoOutputParams(ctx variableAssignmentContext) error {
 	// The Soong replacement for LOCAL_PROTO_JAVA_OUTPUT_PARAMS doesn't need ","
 	ctx.mkvalue = ctx.mkvalue.Clone()
diff --git a/cc/cc.go b/cc/cc.go
index 2770fb2..a7d087f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2581,6 +2581,22 @@
 	variantNdkLibs := []string{}
 	variantLateNdkLibs := []string{}
 	if ctx.Os() == android.Android {
+		rewriteHeaderLibs := func(list []string) (newHeaderLibs []string) {
+			newHeaderLibs = []string{}
+			for _, entry := range list {
+				// Replace device_kernel_headers with generated_kernel_headers
+				// for inline kernel building
+				if entry == "device_kernel_headers" || entry == "qti_kernel_headers" {
+					newHeaderLibs = append(newHeaderLibs, "generated_kernel_headers")
+					continue
+				}
+				newHeaderLibs = append(newHeaderLibs, entry)
+			}
+			return newHeaderLibs
+		}
+
+		deps.HeaderLibs = rewriteHeaderLibs(deps.HeaderLibs)
+
 		deps.SharedLibs, variantNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.SharedLibs)
 		deps.LateSharedLibs, variantLateNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.LateSharedLibs)
 		deps.ReexportSharedLibHeaders, _ = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.ReexportSharedLibHeaders)
diff --git a/cc/compiler.go b/cc/compiler.go
index de1ae71..40e8974 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -345,6 +345,16 @@
 	tc := ctx.toolchain()
 	modulePath := ctx.ModuleDir()
 
+	additionalIncludeDirs := ctx.DeviceConfig().TargetSpecificHeaderPath()
+	if len(additionalIncludeDirs) > 0 {
+		// devices can have multiple paths in TARGET_SPECIFIC_HEADER_PATH
+		// add -I in front of all of them
+		if (strings.Contains(additionalIncludeDirs, " ")) {
+			additionalIncludeDirs = strings.ReplaceAll(additionalIncludeDirs, " ", " -I")
+		}
+		flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I" + additionalIncludeDirs)
+	}
+
 	compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
 	compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
 
diff --git a/cc/library.go b/cc/library.go
index e2b4d4f..222b380 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -197,6 +197,9 @@
 	// using -isystem for this module and any module that links against this module.
 	Export_system_include_dirs []string `android:"arch_variant,variant_prepend"`
 
+	// list of plain cc flags to be used for any module that links against this module.
+	Export_cflags []string  `android:"arch_variant"`
+
 	Target struct {
 		Vendor, Product struct {
 			// list of exported include directories, like
@@ -302,6 +305,10 @@
 	f.systemDirs = append(f.systemDirs, android.PathsForModuleSrc(ctx, f.Properties.Export_system_include_dirs)...)
 }
 
+func (f *flagExporter) exportExtraFlags(ctx ModuleContext) {
+	f.flags = append(f.flags, f.Properties.Export_cflags...)
+}
+
 // exportIncludesAsSystem registers the include directories and system include directories to be
 // exported transitively both as system include directories to modules depending on this module.
 func (f *flagExporter) exportIncludesAsSystem(ctx ModuleContext) {
@@ -1607,6 +1614,7 @@
 
 	// Export include paths and flags to be propagated up the tree.
 	library.exportIncludes(ctx)
+	library.exportExtraFlags(ctx)
 	library.reexportDirs(deps.ReexportedDirs...)
 	library.reexportSystemDirs(deps.ReexportedSystemDirs...)
 	library.reexportFlags(deps.ReexportedFlags...)
diff --git a/scripts/check_boot_jars/package_allowed_list.txt b/scripts/check_boot_jars/package_allowed_list.txt
index 47eae07..0a24cab 100644
--- a/scripts/check_boot_jars/package_allowed_list.txt
+++ b/scripts/check_boot_jars/package_allowed_list.txt
@@ -258,3 +258,19 @@
 # Packages used for Android in Chrome OS
 org\.chromium\.arc
 org\.chromium\.arc\..*
+
+# QC adds
+com.qualcomm.qti
+com.quicinc.tcmiface
+com.qualcomm.wfd
+com.qualcomm.wfd.service
+org.codeaurora.ims
+org.codeaurora.internal
+qcom.fmradio
+
+###################################################
+# IFAA Manager used for Alipay and/or WeChat payment
+org\.ifaa\.android\.manager.*
+
+# Lineage HALs
+vendor\.lineage\..*
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index e17bd54..2576b09 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -147,6 +147,9 @@
 var BannerVars = []string{
 	"PLATFORM_VERSION_CODENAME",
 	"PLATFORM_VERSION",
+        "LEAF_VERSION",
+        "LEAF_FLAVOR",
+        "LEAF_BUILDTYPE",
 	"PRODUCT_INCLUDE_TAGS",
 	"PRODUCT_SOURCE_ROOT_DIRS",
 	"TARGET_PRODUCT",
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index edb3b66..ce0d174 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -228,6 +228,13 @@
 		sandboxArgs = append(sandboxArgs, "-N")
 	}
 
+	if ccacheExec := os.Getenv("CCACHE_EXEC"); ccacheExec != "" {
+		bytes, err := exec.Command(ccacheExec, "-k", "cache_dir").Output()
+		if err == nil {
+			sandboxArgs = append(sandboxArgs, "-B", strings.TrimSpace(string(bytes)))
+		}
+	}
+
 	// Stop nsjail from parsing arguments
 	sandboxArgs = append(sandboxArgs, "--")