target_sdk_version replacement should respect REL branches
Currently, target_sdk_version of MTS tests were being set to 10000 even
in release branches. This should only happen in active branches.
Test: Unit test
Test: aapt2 on CtsContentTestCases in udc-dev and verified
targetSdkVersion is 34
Bug: 279507428
Change-Id: Ib79318febc0f6e771b3679c0281a97357930ec56
Merged-In: Ib79318febc0f6e771b3679c0281a97357930ec56
(cherry picked from commit fb6a1ee68b
)
This commit is contained in:
@@ -63,9 +63,11 @@ func targetSdkVersionForManifestFixer(ctx android.ModuleContext, params Manifest
|
|||||||
// 2. The module is run as part of MTS, and should be testable on stable branches
|
// 2. The module is run as part of MTS, and should be testable on stable branches
|
||||||
// Do not return 10000 if we are enforcing default targetSdkVersion and sdk has been finalised
|
// Do not return 10000 if we are enforcing default targetSdkVersion and sdk has been finalised
|
||||||
func shouldReturnFinalOrFutureInt(ctx android.ModuleContext, targetSdkVersionLevel android.ApiLevel, enforceDefaultTargetSdkVersion bool) bool {
|
func shouldReturnFinalOrFutureInt(ctx android.ModuleContext, targetSdkVersionLevel android.ApiLevel, enforceDefaultTargetSdkVersion bool) bool {
|
||||||
if enforceDefaultTargetSdkVersion && ctx.Config().PlatformSdkFinal() {
|
// If this is a REL branch, do not return 10000
|
||||||
|
if ctx.Config().PlatformSdkFinal() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// If this a module targeting an unreleased SDK (MTS or unbundled builds), return 10000
|
||||||
return targetSdkVersionLevel.IsPreview() && (ctx.Config().UnbundledBuildApps() || includedInMts(ctx.Module()))
|
return targetSdkVersionLevel.IsPreview() && (ctx.Config().UnbundledBuildApps() || includedInMts(ctx.Module()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3034,11 +3034,13 @@ func TestExportedProguardFlagFiles(t *testing.T) {
|
|||||||
|
|
||||||
func TestTargetSdkVersionManifestFixer(t *testing.T) {
|
func TestTargetSdkVersionManifestFixer(t *testing.T) {
|
||||||
platform_sdk_codename := "Tiramisu"
|
platform_sdk_codename := "Tiramisu"
|
||||||
|
platform_sdk_version := 33
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
targetSdkVersionInBp string
|
targetSdkVersionInBp string
|
||||||
targetSdkVersionExpected string
|
targetSdkVersionExpected string
|
||||||
unbundledBuild bool
|
unbundledBuild bool
|
||||||
|
platformSdkFinal bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Non-Unbundled build: Android.bp has targetSdkVersion",
|
name: "Non-Unbundled build: Android.bp has targetSdkVersion",
|
||||||
@@ -3075,6 +3077,12 @@ func TestTargetSdkVersionManifestFixer(t *testing.T) {
|
|||||||
targetSdkVersionExpected: "10000",
|
targetSdkVersionExpected: "10000",
|
||||||
unbundledBuild: true,
|
unbundledBuild: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Bundled build in REL branches",
|
||||||
|
targetSdkVersionExpected: "33",
|
||||||
|
unbundledBuild: false,
|
||||||
|
platformSdkFinal: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
targetSdkVersionTemplate := ""
|
targetSdkVersionTemplate := ""
|
||||||
@@ -3091,8 +3099,12 @@ func TestTargetSdkVersionManifestFixer(t *testing.T) {
|
|||||||
fixture := android.GroupFixturePreparers(
|
fixture := android.GroupFixturePreparers(
|
||||||
prepareForJavaTest,
|
prepareForJavaTest,
|
||||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
|
if testCase.platformSdkFinal {
|
||||||
|
variables.Platform_sdk_final = proptools.BoolPtr(true)
|
||||||
|
}
|
||||||
// explicitly set platform_sdk_codename to make the test deterministic
|
// explicitly set platform_sdk_codename to make the test deterministic
|
||||||
variables.Platform_sdk_codename = &platform_sdk_codename
|
variables.Platform_sdk_codename = &platform_sdk_codename
|
||||||
|
variables.Platform_sdk_version = &platform_sdk_version
|
||||||
variables.Platform_version_active_codenames = []string{platform_sdk_codename}
|
variables.Platform_version_active_codenames = []string{platform_sdk_codename}
|
||||||
// create a non-empty list if unbundledBuild==true
|
// create a non-empty list if unbundledBuild==true
|
||||||
if testCase.unbundledBuild {
|
if testCase.unbundledBuild {
|
||||||
|
Reference in New Issue
Block a user