Remove PlatformVndkVersion property

Platform VNDK version is no longer available based on VNDK deprecation.
Remove all code using Platform VNDK version.

Bug: 330100430
Test: AOSP CF build succeeded
Change-Id: I7d0f7e23eff5d153346890f242a94b78bad6736b
diff --git a/android/config.go b/android/config.go
index 2ee3b93..651b6ea 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1448,10 +1448,6 @@
 	return StringDefault(c.config.productVariables.DeviceCurrentApiLevelForVendorModules, "current")
 }
 
-func (c *deviceConfig) PlatformVndkVersion() string {
-	return String(c.config.productVariables.Platform_vndk_version)
-}
-
 func (c *deviceConfig) ExtraVndkVersions() []string {
 	return c.config.productVariables.ExtraVndkVersions
 }
diff --git a/android/variable.go b/android/variable.go
index 9b630c0..fc5ae23 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -209,7 +209,6 @@
 	Platform_base_sdk_extension_version       *int     `json:",omitempty"`
 	Platform_version_active_codenames         []string `json:",omitempty"`
 	Platform_version_all_preview_codenames    []string `json:",omitempty"`
-	Platform_vndk_version                     *string  `json:",omitempty"`
 	Platform_systemsdk_versions               []string `json:",omitempty"`
 	Platform_security_patch                   *string  `json:",omitempty"`
 	Platform_preview_sdk_version              *string  `json:",omitempty"`
@@ -597,7 +596,6 @@
 		Platform_sdk_final:                     boolPtr(false),
 		Platform_version_active_codenames:      []string{"S"},
 		Platform_version_all_preview_codenames: []string{"S"},
-		Platform_vndk_version:                  stringPtr("S"),
 
 		HostArch:                    stringPtr("x86_64"),
 		HostSecondaryArch:           stringPtr("x86"),
diff --git a/apex/apex.go b/apex/apex.go
index bc91407..f24590f 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -737,7 +737,7 @@
 // image variation name.
 func (a *apexBundle) getImageVariationPair(deviceConfig android.DeviceConfig) (string, string) {
 	if a.vndkApex {
-		return cc.VendorVariationPrefix, a.vndkVersion(deviceConfig)
+		return cc.VendorVariationPrefix, a.vndkVersion()
 	}
 
 	prefix := android.CoreVariation
@@ -746,9 +746,6 @@
 		if a.SocSpecific() || a.DeviceSpecific() {
 			prefix = cc.VendorVariationPrefix
 			vndkVersion = deviceConfig.VndkVersion()
-		} else if a.ProductSpecific() {
-			prefix = cc.ProductVariationPrefix
-			vndkVersion = deviceConfig.PlatformVndkVersion()
 		}
 	} else {
 		if a.SocSpecific() || a.DeviceSpecific() {
@@ -757,9 +754,6 @@
 			prefix = cc.ProductVariation
 		}
 	}
-	if vndkVersion == "current" {
-		vndkVersion = deviceConfig.PlatformVndkVersion()
-	}
 
 	return prefix, vndkVersion
 }
diff --git a/apex/builder.go b/apex/builder.go
index 50db631..9bd4b61 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -277,7 +277,7 @@
 	// VNDK APEX name is determined at runtime, so update "name" in apex_manifest
 	optCommands := []string{}
 	if a.vndkApex {
-		apexName := vndkApexNamePrefix + a.vndkVersion(ctx.DeviceConfig())
+		apexName := vndkApexNamePrefix + a.vndkVersion()
 		optCommands = append(optCommands, "-v name "+apexName)
 	}
 
@@ -1043,7 +1043,7 @@
 	if a.vndkApex {
 		overrideName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(vndkApexName)
 		if overridden {
-			return overrideName + ".v" + a.vndkVersion(ctx.DeviceConfig())
+			return overrideName + ".v" + a.vndkVersion()
 		}
 		return ""
 	}
diff --git a/apex/vndk.go b/apex/vndk.go
index 377c1c0..781aa3c 100644
--- a/apex/vndk.go
+++ b/apex/vndk.go
@@ -45,16 +45,12 @@
 	return bundle
 }
 
-func (a *apexBundle) vndkVersion(config android.DeviceConfig) string {
-	vndkVersion := proptools.StringDefault(a.vndkProperties.Vndk_version, "current")
-	if vndkVersion == "current" {
-		vndkVersion = config.PlatformVndkVersion()
-	}
-	return vndkVersion
+func (a *apexBundle) vndkVersion() string {
+	return proptools.StringDefault(a.vndkProperties.Vndk_version, "current")
 }
 
 type apexVndkProperties struct {
-	// Indicates VNDK version of which this VNDK APEX bundles VNDK libs. Default is Platform VNDK Version.
+	// Indicates VNDK version of which this VNDK APEX bundles VNDK libs.
 	Vndk_version *string
 }
 
@@ -64,7 +60,7 @@
 			mctx.PropertyErrorf("native_bridge_supported", "%q doesn't support native bridge binary.", mctx.ModuleType())
 		}
 
-		vndkVersion := ab.vndkVersion(mctx.DeviceConfig())
+		vndkVersion := ab.vndkVersion()
 		if vndkVersion != "" {
 			apiLevel, err := android.ApiLevelFromUser(mctx, vndkVersion)
 			if err != nil {
@@ -73,17 +69,9 @@
 			}
 
 			targets := mctx.MultiTargets()
-			if len(targets) > 0 && apiLevel.LessThan(cc.MinApiForArch(mctx, targets[0].Arch.ArchType)) &&
-				vndkVersion != mctx.DeviceConfig().PlatformVndkVersion() {
+			if len(targets) > 0 && apiLevel.LessThan(cc.MinApiForArch(mctx, targets[0].Arch.ArchType)) {
 				// Disable VNDK APEXes for VNDK versions less than the minimum supported API
-				// level for the primary architecture. This validation is skipped if the VNDK
-				// version matches the platform VNDK version, which can occur when the device
-				// config targets the 'current' VNDK (see `vndkVersion`).
-				ab.Disable()
-			}
-			if proptools.String(ab.vndkProperties.Vndk_version) != "" &&
-				mctx.DeviceConfig().PlatformVndkVersion() != "" &&
-				apiLevel.GreaterThanOrEqualTo(android.ApiLevelOrPanic(mctx, mctx.DeviceConfig().PlatformVndkVersion())) {
+				// level for the primary architecture.
 				ab.Disable()
 			}
 		}
@@ -93,20 +81,11 @@
 func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) {
 	if m, ok := mctx.Module().(*cc.Module); ok && cc.IsForVndkApex(mctx, m) {
 		vndkVersion := m.VndkVersion()
-		// For VNDK-Lite device, we gather core-variants of VNDK-Sp libraries, which doesn't have VNDK version defined
-		if vndkVersion == "" {
-			vndkVersion = mctx.DeviceConfig().PlatformVndkVersion()
-		}
 
 		if vndkVersion == "" {
 			return
 		}
-
-		if vndkVersion == mctx.DeviceConfig().PlatformVndkVersion() {
-			vndkVersion = "current"
-		} else {
-			vndkVersion = "v" + vndkVersion
-		}
+		vndkVersion = "v" + vndkVersion
 
 		vndkApexName := "com.android.vndk." + vndkVersion
 
diff --git a/cc/cc.go b/cc/cc.go
index 90185ea..88ebca2 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1896,9 +1896,6 @@
 		vndkVersion = ctx.DeviceConfig().VndkVersion()
 		nameSuffix = VendorSuffix
 	}
-	if vndkVersion == "current" {
-		vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
-	}
 	if c.VndkVersion() != vndkVersion && c.VndkVersion() != "" {
 		// add version suffix only if the module is using different vndk version than the
 		// version in product or vendor partition.
diff --git a/cc/genrule.go b/cc/genrule.go
index 0fb3e2d..23e97d0 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -121,18 +121,7 @@
 		}
 	} else {
 		if vendorVariantRequired {
-			// If vndkVersion is current, we can always use PlatformVndkVersion.
-			// If not, we assume modules under proprietary paths are compatible for
-			// BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
-			// PLATFORM_VNDK_VERSION.
-			if vndkVersion == "current" || !snapshot.IsVendorProprietaryModule(ctx) {
-				variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
-			} else {
-				variants = append(variants, VendorVariationPrefix+vndkVersion)
-			}
-		}
-		if productVariantRequired {
-			variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
+			variants = append(variants, VendorVariationPrefix+vndkVersion)
 		}
 	}
 
diff --git a/cc/image.go b/cc/image.go
index d02a2f3..50d1b23 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -429,7 +429,6 @@
 	var vendorVariants []string
 	var productVariants []string
 
-	platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion()
 	boardVndkVersion := mctx.DeviceConfig().VndkVersion()
 	recoverySnapshotVersion := mctx.DeviceConfig().RecoverySnapshotVersion()
 	usingRecoverySnapshot := recoverySnapshotVersion != "current" &&
@@ -444,17 +443,13 @@
 			needVndkVersionVendorVariantForLlndk = boardVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(mctx, "30"))
 		}
 	}
-	if boardVndkVersion == "current" {
-		boardVndkVersion = platformVndkVersion
-	}
-
 	if m.NeedsLlndkVariants() {
 		// This is an LLNDK library.  The implementation of the library will be on /system,
 		// and vendor and product variants will be created with LLNDK stubs.
 		// The LLNDK libraries need vendor variants even if there is no VNDK.
 		coreVariantNeeded = true
-		vendorVariants = append(vendorVariants, platformVndkVersion)
-		productVariants = append(productVariants, platformVndkVersion)
+		vendorVariants = append(vendorVariants, "")
+		productVariants = append(productVariants, "")
 		// Generate vendor variants for boardVndkVersion only if the VNDK snapshot does not
 		// provide the LLNDK stub libraries.
 		if needVndkVersionVendorVariantForLlndk {
@@ -465,7 +460,7 @@
 		// for system and product.
 		coreVariantNeeded = true
 		vendorVariants = append(vendorVariants, boardVndkVersion)
-		productVariants = append(productVariants, platformVndkVersion)
+		productVariants = append(productVariants, "")
 	} else if m.IsSnapshotPrebuilt() {
 		// Make vendor variants only for the versions in BOARD_VNDK_VERSION and
 		// PRODUCT_EXTRA_VNDK_VERSIONS.
@@ -486,13 +481,13 @@
 			if snapshot.IsVendorProprietaryModule(mctx) {
 				vendorVariants = append(vendorVariants, boardVndkVersion)
 			} else {
-				vendorVariants = append(vendorVariants, platformVndkVersion)
+				vendorVariants = append(vendorVariants, "")
 			}
 		}
 
 		// product_available modules are available to /product.
 		if m.HasProductVariant() {
-			productVariants = append(productVariants, platformVndkVersion)
+			productVariants = append(productVariants, "")
 		}
 	} else if vendorSpecific && m.SdkVersion() == "" {
 		// This will be available in /vendor (or /odm) only
@@ -505,13 +500,13 @@
 		// are regarded as AOSP, which is PLATFORM_VNDK_VERSION.
 		if m.KernelHeadersDecorator() {
 			vendorVariants = append(vendorVariants,
-				platformVndkVersion,
+				"",
 				boardVndkVersion,
 			)
 		} else if snapshot.IsVendorProprietaryModule(mctx) {
 			vendorVariants = append(vendorVariants, boardVndkVersion)
 		} else {
-			vendorVariants = append(vendorVariants, platformVndkVersion)
+			vendorVariants = append(vendorVariants, "")
 		}
 	} else {
 		// This is either in /system (or similar: /data), or is a
@@ -523,7 +518,7 @@
 	if coreVariantNeeded && productSpecific && m.SdkVersion() == "" {
 		// The module has "product_specific: true" that does not create core variant.
 		coreVariantNeeded = false
-		productVariants = append(productVariants, platformVndkVersion)
+		productVariants = append(productVariants, "")
 	}
 
 	if m.RamdiskAvailable() {
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index e769fe9..7d003a9 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -324,7 +324,7 @@
 
 	variations = append(ctx.Target().Variations(), blueprint.Variation{
 		Mutator:   "image",
-		Variation: ProductVariationPrefix + ctx.DeviceConfig().PlatformVndkVersion()})
+		Variation: ProductVariation})
 
 	if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(LinkableInterface).BaseModuleName()) {
 		p.baseProperties.Androidmk_suffix = p.Image.moduleNameSuffix()
diff --git a/cc/vndk.go b/cc/vndk.go
index 2b2ea64..ad0dcf3 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -42,28 +42,6 @@
 )
 
 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()))
-		if currentVndkSnapshotted {
-			// If the current VNDK is already snapshotted (which can happen with
-			// the `next` config), use the prebuilt txt files in the snapshot.
-			// This is because the txt files built from source are probably be
-			// for the in-development version.
-			vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
-		} else {
-			// Use the txt files generated from the source
-			return []string{
-				llndkLibrariesTxtForApex,
-				vndkCoreLibrariesTxt,
-				vndkSpLibrariesTxt,
-				vndkPrivateLibrariesTxt,
-				vndkProductLibrariesTxt,
-			}
-		}
-	}
-
 	// Snapshot vndks have their own *.libraries.VER.txt files.
 	// Note that snapshots don't have "vndkcorevariant.libraries.VER.txt"
 	result := []string{
@@ -376,15 +354,6 @@
 		if !p.MatchesWithDevice(mctx.DeviceConfig()) {
 			return false
 		}
-
-		platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion()
-		if platformVndkVersion != "" {
-			// ignore prebuilt vndk modules that are newer than or equal to the platform vndk version
-			platformVndkApiLevel := android.ApiLevelOrPanic(mctx, platformVndkVersion)
-			if platformVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(mctx, p.Version())) {
-				return false
-			}
-		}
 	}
 
 	if lib, ok := m.linker.(libraryInterface); ok {
@@ -392,8 +361,7 @@
 		if lib.buildStubs() {
 			return false
 		}
-		useCoreVariant := m.VndkVersion() == mctx.DeviceConfig().PlatformVndkVersion() &&
-			mctx.DeviceConfig().VndkUseCoreVariant() && !m.MustUseVendorVariant()
+		useCoreVariant := mctx.DeviceConfig().VndkUseCoreVariant() && !m.MustUseVendorVariant()
 		return lib.shared() && m.InVendor() && m.IsVndk() && !m.IsVndkExt() && !useCoreVariant
 	}
 	return false
@@ -548,22 +516,9 @@
 	return filename
 }
 
-func (txt *vndkLibrariesTxt) DepsMutator(mctx android.BottomUpMutatorContext) {
-	versionedName := insertVndkVersion(txt.Name(), mctx.DeviceConfig().PlatformVndkVersion())
-	if mctx.OtherModuleExists(versionedName) {
-		// If the prebuilt vndk libraries txt files exist, install them instead.
-		txt.HideFromMake()
-		mctx.AddDependency(txt, nil, versionedName)
-	}
-}
-
 func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	filename := proptools.StringDefault(txt.properties.Stem, txt.Name())
 
-	if Bool(txt.properties.Insert_vndk_version) {
-		filename = insertVndkVersion(filename, ctx.DeviceConfig().PlatformVndkVersion())
-	}
-
 	txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
 
 	installPath := android.PathForModuleInstall(ctx, "etc")
@@ -639,34 +594,6 @@
 
 func isVndkSnapshotAware(config android.DeviceConfig, m LinkableInterface,
 	apexInfo android.ApexInfo) (vndkType string, isVndkSnapshotLib bool) {
-
-	if m.Target().NativeBridge == android.NativeBridgeEnabled {
-		return "", false
-	}
-	// !inVendor: There's product/vendor variants for VNDK libs. We only care about vendor variants.
-	// !installable: Snapshot only cares about "installable" modules.
-	// !m.IsLlndk: llndk stubs are required for building against snapshots.
-	// IsSnapshotPrebuilt: Snapshotting a snapshot doesn't make sense.
-	// !outputFile.Valid: Snapshot requires valid output file.
-	if !m.InVendor() || (!installable(m, apexInfo) && !m.IsLlndk()) || m.IsSnapshotPrebuilt() || !m.OutputFile().Valid() {
-		return "", false
-	}
-	if !m.IsSnapshotLibrary() || !m.Shared() {
-		return "", false
-	}
-	if m.VndkVersion() == config.PlatformVndkVersion() {
-		if m.IsVndk() && !m.IsVndkExt() {
-			if m.IsVndkSp() {
-				return "vndk-sp", true
-			} else {
-				return "vndk-core", true
-			}
-		} else if m.HasLlndkStubs() && m.StubsVersion() == "" {
-			// Use default version for the snapshot.
-			return "llndk-stub", true
-		}
-	}
-
 	return "", false
 }
 
@@ -679,10 +606,6 @@
 		return
 	}
 
-	if ctx.DeviceConfig().PlatformVndkVersion() == "" {
-		return
-	}
-
 	var snapshotOutputs android.Paths
 
 	/*
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 43030b8..f4ba163 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -131,16 +131,6 @@
 
 func (p *vndkPrebuiltLibraryDecorator) link(ctx ModuleContext,
 	flags Flags, deps PathDeps, objs Objects) android.Path {
-	platformVndkVersion := ctx.DeviceConfig().PlatformVndkVersion()
-	if platformVndkVersion != "" {
-		platformVndkApiLevel := android.ApiLevelOrPanic(ctx, platformVndkVersion)
-		if platformVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(ctx, p.Version())) {
-			// This prebuilt VNDK module is not required for the current build
-			ctx.Module().HideFromMake()
-			return nil
-		}
-	}
-
 	if !p.MatchesWithDevice(ctx.DeviceConfig()) {
 		ctx.Module().HideFromMake()
 		return nil