cc: use platform sdk version for vendor/product variants

This enables LLNDK symbols to work with INTRODUCED_IN and
builtin_available.

This should work well with TrunkStable as well.

Instead of passing 10000 in trunk_staging, we can pass e.g. 35 to vendor
modules. Then, vendor code can benefit from __builtin_available because
it's compiled as a runtime check (isOSVersionAtLeast) and handle the
version at runtime based on the actual platform version.

With this change, using new symbols (e.g. symbols introduced in
in-development version) can be detected even in the "trunk_stging"
configuration. Prevously, since 10000 is assumed in trunk_staging, new
symbols were okay in trunk_staging while required __builtin_available
guard in "next" configuration.

This also helps to build a vendor apex which can be built in a new
Android release while it's meant to be installed and run on an old
Android release by setting min_sdk_version.

Bug: 362658565
Test: m --no-skip-soong-tests
Change-Id: I06f46940f0b994b460c2c69171c708583391f836
diff --git a/cc/cc.go b/cc/cc.go
index 5dee32e..0ed6238 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1567,12 +1567,11 @@
 	}
 
 	if ctx.ctx.Device() {
-		config := ctx.ctx.Config()
-		if ctx.inVendor() {
-			// If building for vendor with final API, then use the latest _stable_ API as "current".
-			if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") {
-				ver = config.PlatformSdkVersion().String()
-			}
+		// When building for vendor/product, use the latest _stable_ API as "current".
+		// This is passed to clang/aidl compilers so that compiled/generated code works
+		// with the system.
+		if (ctx.inVendor() || ctx.inProduct()) && (ver == "" || ver == "current") {
+			ver = ctx.ctx.Config().PlatformSdkVersion().String()
 		}
 	}