Merge "Remove Bazel metrics/finalize-bazel-metrics." into main
diff --git a/apex/apex_test.go b/apex/apex_test.go
index e70d3af..2bed554 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -3882,13 +3882,24 @@
 func vndkLibrariesTxtFiles(vers ...string) (result string) {
 	for _, v := range vers {
 		if v == "current" {
-			for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
+			for _, txt := range []string{"vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
 				result += `
 					` + txt + `_libraries_txt {
 						name: "` + txt + `.libraries.txt",
+						insert_vndk_version: true,
 					}
 				`
 			}
+			result += `
+				llndk_libraries_txt {
+					name: "llndk.libraries.txt",
+				}
+				llndk_libraries_txt_for_apex {
+					name: "llndk.libraries.txt.apex",
+					stem: "llndk.libraries.txt",
+					insert_vndk_version: true,
+				}
+			`
 		} else {
 			for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
 				result += `
diff --git a/cc/config/global.go b/cc/config/global.go
index 67ea4fd..892a86c 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -259,6 +259,7 @@
 		"-Werror=fortify-source",
 
 		"-Werror=address-of-temporary",
+		"-Werror=incompatible-function-pointer-types",
 		"-Werror=null-dereference",
 		"-Werror=return-type",
 
@@ -335,10 +336,6 @@
 		"-fcommon",
 		// http://b/191699019
 		"-Wno-format-insufficient-args",
-		// http://b/296321145
-		// Indicates potential memory or stack corruption, so should be changed
-		// to a hard error. Currently triggered by some vendor code.
-		"-Wno-incompatible-function-pointer-types",
 		// http://b/296321508
 		// Introduced in response to a critical security vulnerability and
 		// should be a hard error - it requires only whitespace changes to fix.
@@ -356,7 +353,7 @@
 
 	llvmNextExtraCommonGlobalCflags = []string{
 		// Do not report warnings when testing with the top of trunk LLVM.
-		"-Wno-error",
+		"-Wno-everything",
 	}
 
 	// Flags that must not appear in any command line.
@@ -472,6 +469,7 @@
 		flags := noOverrideGlobalCflags
 		if ctx.Config().IsEnvTrue("LLVM_NEXT") {
 			flags = append(noOverrideGlobalCflags, llvmNextExtraCommonGlobalCflags...)
+			IllegalFlags = []string{} // Don't fail build while testing a new compiler.
 		}
 		return strings.Join(flags, " ")
 	})
diff --git a/cc/library.go b/cc/library.go
index b7688f7..1807bbf 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2195,7 +2195,7 @@
 
 			// do not install vndk libs
 			// vndk libs are packaged into VNDK APEX
-			if ctx.isVndk() && !ctx.IsVndkExt() && !ctx.Config().IsVndkDeprecated() {
+			if ctx.isVndk() && !ctx.IsVndkExt() && !ctx.Config().IsVndkDeprecated() && !ctx.inProduct() {
 				return
 			}
 		} else if library.hasStubsVariants() && !ctx.Host() && ctx.directlyInAnyApex() {
diff --git a/cc/vndk.go b/cc/vndk.go
index 5ac5032..a849455 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -28,10 +28,12 @@
 	"android/soong/snapshot"
 
 	"github.com/google/blueprint"
+	"github.com/google/blueprint/proptools"
 )
 
 const (
 	llndkLibrariesTxt                = "llndk.libraries.txt"
+	llndkLibrariesTxtForApex         = "llndk.libraries.txt.apex"
 	vndkCoreLibrariesTxt             = "vndkcore.libraries.txt"
 	vndkSpLibrariesTxt               = "vndksp.libraries.txt"
 	vndkPrivateLibrariesTxt          = "vndkprivate.libraries.txt"
@@ -40,6 +42,7 @@
 )
 
 func VndkLibrariesTxtModules(vndkVersion string, ctx android.BaseModuleContext) []string {
+	// Return the list of vndk txt files for the vndk apex of the vndkVersion.
 	if vndkVersion == "current" {
 		// We can assume all txt files are snapshotted if we find one of them.
 		currentVndkSnapshotted := ctx.OtherModuleExists(insertVndkVersion(llndkLibrariesTxt, ctx.DeviceConfig().PlatformVndkVersion()))
@@ -51,20 +54,13 @@
 			vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
 		} else {
 			// Use the txt files generated from the source
-			result := []string{
+			return []string{
+				llndkLibrariesTxtForApex,
 				vndkCoreLibrariesTxt,
 				vndkSpLibrariesTxt,
 				vndkPrivateLibrariesTxt,
 				vndkProductLibrariesTxt,
 			}
-
-			// TODO(b/290159430) This part will not be required once deprecation
-			// of VNDK is handled with 'ro.vndk.version' property
-			if !ctx.Config().IsVndkDeprecated() {
-				result = append(result, llndkLibrariesTxt)
-			}
-
-			return result
 		}
 	}
 
@@ -451,6 +447,7 @@
 
 func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) {
 	ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory)
+	ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt_for_apex", llndkLibrariesTxtApexOnlyFactory)
 	ctx.RegisterParallelSingletonModuleType("vndksp_libraries_txt", vndkSPLibrariesTxtFactory)
 	ctx.RegisterParallelSingletonModuleType("vndkcore_libraries_txt", vndkCoreLibrariesTxtFactory)
 	ctx.RegisterParallelSingletonModuleType("vndkprivate_libraries_txt", vndkPrivateLibrariesTxtFactory)
@@ -474,22 +471,31 @@
 
 type VndkLibrariesTxtProperties struct {
 	Insert_vndk_version *bool
+	Stem                *string
 }
 
 var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
 var _ android.OutputFileProducer = &vndkLibrariesTxt{}
 
 // llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries
-// generated by Soong but can be referenced by other modules.
-// For example, apex_vndk can depend on these files as prebuilt.
+// generated by Soong.
 // Make uses LLNDK_LIBRARIES to determine which libraries to install.
-// HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN.
+// HWASAN is only part of the LLNDK in builds in which libc depends on HWASAN.
 // Therefore, by removing the library here, we cause it to only be installed if libc
 // depends on it.
 func llndkLibrariesTxtFactory() android.SingletonModule {
 	return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "LLNDK_LIBRARIES", "libclang_rt.hwasan")
 }
 
+// llndk_libraries_txt_for_apex is a singleton module that provide the same LLNDK libraries list
+// with the llndk_libraries_txt, but skips setting make variable LLNDK_LIBRARIES. So, it must not
+// be used without installing llndk_libraries_txt singleton.
+// We include llndk_libraries_txt by default to install the llndk.libraries.txt file to system/etc.
+// This singleton module is to install the llndk.libraries.<ver>.txt file to vndk apex.
+func llndkLibrariesTxtApexOnlyFactory() android.SingletonModule {
+	return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "", "libclang_rt.hwasan")
+}
+
 // vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries
 // generated by Soong but can be referenced by other modules.
 // For example, apex_vndk can depend on these files as prebuilt.
@@ -557,15 +563,10 @@
 }
 
 func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	filename := txt.Name()
+	filename := proptools.StringDefault(txt.properties.Stem, txt.Name())
 
-	shouldInsertVndkVersion := BoolDefault(txt.properties.Insert_vndk_version, true)
-	// llndk.libraries.txt file installed in the system image should not contain version info.
-	if ctx.Config().IsVndkDeprecated() && txt.Name() == llndkLibrariesTxt {
-		shouldInsertVndkVersion = false
-	}
-	if shouldInsertVndkVersion {
-		filename = insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
+	if Bool(txt.properties.Insert_vndk_version) {
+		filename = insertVndkVersion(filename, ctx.DeviceConfig().PlatformVndkVersion())
 	}
 
 	txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
@@ -592,6 +593,10 @@
 }
 
 func (txt *vndkLibrariesTxt) MakeVars(ctx android.MakeVarsContext) {
+	if txt.makeVarName == "" {
+		return
+	}
+
 	filter := func(modules []string, prefix string) []string {
 		if prefix == "" {
 			return modules
diff --git a/genrule/allowlists.go b/genrule/allowlists.go
index a713fbb..ea6be90 100644
--- a/genrule/allowlists.go
+++ b/genrule/allowlists.go
@@ -104,36 +104,12 @@
 		"camera-its",
 		"checkIn-service-stub-lite",
 		"chre_atoms_log.h",
-		"com.android.apex.apkrollback.test.pem",
-		"com.android.apex.apkrollback.test.pubkey",
-		"com.android.apex.cts.shim.debug.pem",
-		"com.android.apex.cts.shim.debug.pubkey",
-		"com.android.apex.cts.shim.pem",
-		"com.android.apex.cts.shim.pubkey",
-		"com.android.apex.cts.shim.v2_no_pb",
-		"com.android.apex.cts.shim.v2_signed_bob",
-		"com.android.apex.cts.shim.v2_signed_bob_rot",
-		"com.android.apex.cts.shim.v2_signed_bob_rot_rollback",
-		"com.android.apex.cts.shim.v2_unsigned_apk_container",
-		"com.android.apex.cts.shim.v3_signed_bob",
-		"com.android.apex.cts.shim.v3_signed_bob_rot",
-		"com.android.apex.cts.shim_not_pre_installed.pem",
-		"com.android.apex.cts.shim_not_pre_installed.pubkey",
-		"com.android.apex.rotation.key.bob.pem",
-		"com.android.apex.rotation.key.bob.pk8",
-		"com.android.apex.rotation.key.bob.rot",
-		"com.android.apex.rotation.key.bob.rot.rollback",
-		"com.android.apex.rotation.key.bob.x509.pem",
 		"com.android.apex.test.bar_stripped",
 		"com.android.apex.test.baz_stripped",
 		"com.android.apex.test.foo_stripped",
 		"com.android.apex.test.pony_stripped",
 		"com.android.apex.test.sharedlibs_generated",
 		"com.android.apex.test.sharedlibs_secondary_generated",
-		"com.android.overlaytest.overlaid.pem",
-		"com.android.overlaytest.overlaid.pubkey",
-		"com.android.overlaytest.overlay.pem",
-		"com.android.overlaytest.overlay.pubkey",
 		"common-profile-text-protos",
 		"core-tests-smali-dex",
 		"cronet_aml_base_android_runtime_jni_headers",
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 4ad3907..7807889 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1751,11 +1751,9 @@
 		"BroadcastBehavior",
 		"DeprecationMismatch",
 		"HiddenSuperclass",
-		"HiddenTypeParameter",
 		"MissingPermission",
 		"SdkConstant",
 		"Todo",
-		"UnavailableSymbol",
 	}
 	droidstubsArgs = append(droidstubsArgs, android.JoinWithPrefix(disabledWarnings, "--hide "))