Merge "Build and dist updatepackage" into main am: dd87ef7fef

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3558149

Change-Id: Ie0dff2adc8ad611de8b5853a9270bfd24a9b8e70
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/aconfig/Android.bp b/aconfig/Android.bp
index 33e04a4..a15fe86 100644
--- a/aconfig/Android.bp
+++ b/aconfig/Android.bp
@@ -31,9 +31,6 @@
     pluginFor: ["soong_build"],
 }
 
-// All FlaggedApi flags associated with platform API.
-// By default this uses the platform APIs associated with android.jar
-// but other verticals/platforms can override via soong config setting.
 all_aconfig_declarations {
     name: "all_aconfig_declarations",
     visibility: [
diff --git a/android/config.go b/android/config.go
index 52d7f3b..b92eb7e 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1114,6 +1114,10 @@
 	return uncheckedFinalApiLevel(*c.productVariables.Platform_sdk_version)
 }
 
+func (c *config) PlatformSdkVersionFull() string {
+	return proptools.StringDefault(c.productVariables.Platform_sdk_version_full, "")
+}
+
 func (c *config) RawPlatformSdkVersion() *int {
 	return c.productVariables.Platform_sdk_version
 }
diff --git a/android/variable.go b/android/variable.go
index 5980efd..f00dd13 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -210,7 +210,7 @@
 	Platform_display_version_name          *string  `json:",omitempty"`
 	Platform_version_name                  *string  `json:",omitempty"`
 	Platform_sdk_version                   *int     `json:",omitempty"`
-	Platform_sdk_minor_version             *int     `json:",omitempty"`
+	Platform_sdk_version_full              *string  `json:",omitempty"`
 	Platform_sdk_codename                  *string  `json:",omitempty"`
 	Platform_sdk_version_or_codename       *string  `json:",omitempty"`
 	Platform_sdk_final                     *bool    `json:",omitempty"`
diff --git a/cc/config/global.go b/cc/config/global.go
index 5011acd..e81ac0d 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -373,6 +373,9 @@
 	// Flags that must not appear in any command line.
 	IllegalFlags = []string{
 		"-w",
+		"-pedantic",
+		"-pedantic-errors",
+		"-Werror=pedantic",
 	}
 
 	CStdVersion               = "gnu23"
diff --git a/java/droidstubs.go b/java/droidstubs.go
index c215925..b30c844 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -564,7 +564,15 @@
 		})
 	}
 	if apiVersions != nil {
-		cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String())
+		// We are migrating from a single API level to major.minor
+		// versions and PlatformSdkVersionFull is not yet set in all
+		// release configs. If it is not set, fall back on the single
+		// API level.
+		if fullSdkVersion := ctx.Config().PlatformSdkVersionFull(); len(fullSdkVersion) > 0 {
+			cmd.FlagWithArg("--current-version ", fullSdkVersion)
+		} else {
+			cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String())
+		}
 		cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename())
 		cmd.FlagWithInput("--apply-api-levels ", apiVersions)
 	}
diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go
index 4be7d04..21895d4 100644
--- a/java/legacy_core_platform_api_usage.go
+++ b/java/legacy_core_platform_api_usage.go
@@ -47,8 +47,8 @@
 	"sam",
 	"saminterfacelibrary",
 	"sammanagerlibrary",
-	"services",
 	"services.core.unboosted",
+	"services.impl",
 	"Settings-core",
 	"SettingsGoogle",
 	"SettingsGoogleOverlayCoral",
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go
index 527e479..31f149e 100644
--- a/java/prebuilt_apis.go
+++ b/java/prebuilt_apis.go
@@ -55,11 +55,6 @@
 
 	// If set to true, compile dex for java_import modules. Defaults to false.
 	Imports_compile_dex *bool
-
-	// If set to true, allow incremental platform API of the form MM.m where MM is the major release
-	// version corresponding to the API level/SDK_INT and m is an incremental release version
-	// (e.g. API changes associated with QPR). Defaults to false.
-	Allow_incremental_platform_api *bool
 }
 
 type prebuiltApis struct {
@@ -97,28 +92,28 @@
 }
 
 // parseFinalizedPrebuiltPath is like parsePrebuiltPath, but verifies the version is numeric (a finalized version).
-func parseFinalizedPrebuiltPath(ctx android.LoadHookContext, p string, allowIncremental bool) (module string, version int, release int, scope string) {
+func parseFinalizedPrebuiltPath(ctx android.LoadHookContext, p string) (module string, version int, release int, scope string) {
 	module, v, scope := parsePrebuiltPath(ctx, p)
-	if allowIncremental {
-		parts := strings.Split(v, ".")
-		if len(parts) != 2 {
-			ctx.ModuleErrorf("Found unexpected version '%v' for incremental prebuilts - expect MM.m format for incremental API with both major (MM) an minor (m) revision.", v)
-			return
-		}
+
+	// assume a major.minor version code
+	parts := strings.Split(v, ".")
+	if len(parts) == 2 {
 		sdk, sdk_err := strconv.Atoi(parts[0])
 		qpr, qpr_err := strconv.Atoi(parts[1])
 		if sdk_err != nil || qpr_err != nil {
-			ctx.ModuleErrorf("Unable to read version number for incremental prebuilt api '%v'", v)
+			ctx.ModuleErrorf("Unable to read major.minor version for prebuilt api '%v'", v)
 			return
 		}
 		version = sdk
 		release = qpr
 		return
 	}
+
+	// assume a legacy integer only api level
 	release = 0
 	version, err := strconv.Atoi(v)
 	if err != nil {
-		ctx.ModuleErrorf("Found finalized API files in non-numeric dir '%v'", v)
+		ctx.ModuleErrorf("Unable to read API level for prebuilt api '%v'", v)
 		return
 	}
 	return
@@ -279,12 +274,11 @@
 	}
 
 	// Create modules for all (<module>, <scope, <version>) triplets,
-	allowIncremental := proptools.BoolDefault(p.properties.Allow_incremental_platform_api, false)
 	for _, f := range apiLevelFiles {
-		module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f, allowIncremental)
-		if allowIncremental {
-			incrementalVersion := strconv.Itoa(version) + "." + strconv.Itoa(release)
-			createApiModule(mctx, PrebuiltApiModuleName(module, scope, incrementalVersion), f)
+		module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f)
+		if release != 0 {
+			majorDotMinorVersion := strconv.Itoa(version) + "." + strconv.Itoa(release)
+			createApiModule(mctx, PrebuiltApiModuleName(module, scope, majorDotMinorVersion), f)
 		} else {
 			createApiModule(mctx, PrebuiltApiModuleName(module, scope, strconv.Itoa(version)), f)
 		}
@@ -300,7 +294,7 @@
 	getLatest := func(files []string, isExtensionApiFile bool) map[string]latestApiInfo {
 		m := make(map[string]latestApiInfo)
 		for _, f := range files {
-			module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f, allowIncremental)
+			module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f)
 			if strings.HasSuffix(module, "incompatibilities") {
 				continue
 			}
diff --git a/java/prebuilt_apis_test.go b/java/prebuilt_apis_test.go
index 1f095e4..17fdae9 100644
--- a/java/prebuilt_apis_test.go
+++ b/java/prebuilt_apis_test.go
@@ -102,15 +102,15 @@
 	android.AssertStringEquals(t, "Expected latest baz = api level 32", "prebuilts/sdk/32/public/api/baz.txt", baz_input)
 }
 
-func TestPrebuiltApis_WithIncrementalApi(t *testing.T) {
+func TestPrebuiltApis_WithMixedVersionCodes(t *testing.T) {
 	t.Parallel()
 	runTestWithIncrementalApi := func() (foo_input, bar_input, baz_input string) {
 		result := android.GroupFixturePreparers(
 			prepareForJavaTest,
-			FixtureWithPrebuiltIncrementalApis(map[string][]string{
+			FixtureWithPrebuiltApis(map[string][]string{
 				"33.0":    {"foo"},
-				"33.1":    {"foo", "bar", "baz"},
-				"33.2":    {"foo", "bar"},
+				"34":      {"foo", "bar", "baz"},
+				"34.1":    {"foo", "bar"},
 				"current": {"foo", "bar"},
 			}),
 		).RunTest(t)
@@ -119,9 +119,9 @@
 		baz_input = result.ModuleForTests(t, "baz.api.public.latest", "").Rule("generator").Implicits[0].String()
 		return
 	}
-	// 33.1 is the latest for baz, 33.2 is the latest for both foo & bar
+	// 34 is the latest for baz, 34.1 is the latest for both foo & bar
 	foo_input, bar_input, baz_input := runTestWithIncrementalApi()
-	android.AssertStringEquals(t, "Expected latest foo = api level 33.2", "prebuilts/sdk/33.2/public/api/foo.txt", foo_input)
-	android.AssertStringEquals(t, "Expected latest bar = api level 33.2", "prebuilts/sdk/33.2/public/api/bar.txt", bar_input)
-	android.AssertStringEquals(t, "Expected latest baz = api level 33.1", "prebuilts/sdk/33.1/public/api/baz.txt", baz_input)
+	android.AssertStringEquals(t, "Expected latest foo = api level 34.1", "prebuilts/sdk/34.1/public/api/foo.txt", foo_input)
+	android.AssertStringEquals(t, "Expected latest bar = api level 34.1", "prebuilts/sdk/34.1/public/api/bar.txt", bar_input)
+	android.AssertStringEquals(t, "Expected latest baz = api level 34", "prebuilts/sdk/34/public/api/baz.txt", baz_input)
 }
diff --git a/java/testing.go b/java/testing.go
index d7878d6..82dbcee 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -236,29 +236,6 @@
 	)
 }
 
-func FixtureWithPrebuiltIncrementalApis(apiLevel2Modules map[string][]string) android.FixturePreparer {
-	mockFS := android.MockFS{}
-	path := "prebuilts/sdk/Android.bp"
-
-	bp := fmt.Sprintf(`
-			prebuilt_apis {
-				name: "sdk",
-				api_dirs: ["%s"],
-				allow_incremental_platform_api: true,
-				imports_sdk_version: "none",
-				imports_compile_dex: true,
-			}
-		`, strings.Join(android.SortedKeys(apiLevel2Modules), `", "`))
-
-	for release, modules := range apiLevel2Modules {
-		mockFS.Merge(prebuiltApisFilesForModules([]string{release}, modules))
-	}
-	return android.GroupFixturePreparers(
-		android.FixtureAddTextFile(path, bp),
-		android.FixtureMergeMockFs(mockFS),
-	)
-}
-
 func prebuiltApisFilesForModules(apiLevels []string, modules []string) map[string][]byte {
 	libs := append([]string{"android"}, modules...)
 
diff --git a/scripts/gen_build_prop.py b/scripts/gen_build_prop.py
index a0d2546..cef7241 100644
--- a/scripts/gen_build_prop.py
+++ b/scripts/gen_build_prop.py
@@ -165,7 +165,7 @@
   print(f"ro.{partition}.build.version.release={config['Platform_version_last_stable']}")
   print(f"ro.{partition}.build.version.release_or_codename={config['Platform_version_name']}")
   print(f"ro.{partition}.build.version.sdk={config['Platform_sdk_version']}")
-  print(f"ro.{partition}.build.version.sdk_minor={build_flags['RELEASE_PLATFORM_SDK_MINOR_VERSION']}")
+  print(f"ro.{partition}.build.version.sdk_full={config['Platform_sdk_version_full']}")
 
 def generate_build_info(args):
   print()
@@ -198,7 +198,7 @@
     print(f"ro.build.display.id?={config['BuildDesc']}")
   print(f"ro.build.version.incremental={config['BuildNumber']}")
   print(f"ro.build.version.sdk={config['Platform_sdk_version']}")
-  print(f"ro.build.version.sdk_minor={build_flags['RELEASE_PLATFORM_SDK_MINOR_VERSION']}")
+  print(f"ro.build.version.sdk_full={config['Platform_sdk_version_full']}")
   print(f"ro.build.version.preview_sdk={config['Platform_preview_sdk_version']}")
   print(f"ro.build.version.preview_sdk_fingerprint={config['PlatformPreviewSdkFingerprint']}")
   print(f"ro.build.version.codename={config['Platform_sdk_codename']}")