Convert more versions in config to ApiLevel.
The test case I removed is invalid. The codename has had its int assigned, but the config claims it is not final. If this ever does need to be supported it's just a matter of making sure the Q -> 29 mapping (or whatever) in the finalized codenames map in android/api_levels.go. Test: treehugger Bug: http://b/154667674 Change-Id: I4f42ec2fd4a37750519ee3937938a1c65b6bb1e8
This commit is contained in:
parent
0b176c8038
commit
4f378d75aa
11 changed files with 41 additions and 49 deletions
|
@ -274,7 +274,7 @@ func getFinalCodenamesMap(config Config) map[string]int {
|
||||||
// neither R nor S are final, but the S APIs stop being available in a
|
// neither R nor S are final, but the S APIs stop being available in a
|
||||||
// final R build.
|
// final R build.
|
||||||
if Bool(config.productVariables.Platform_sdk_final) {
|
if Bool(config.productVariables.Platform_sdk_final) {
|
||||||
apiLevelsMap["current"] = config.PlatformSdkVersionInt()
|
apiLevelsMap["current"] = config.PlatformSdkVersion().FinalOrFutureInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiLevelsMap
|
return apiLevelsMap
|
||||||
|
|
|
@ -21,7 +21,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
@ -228,15 +227,17 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
||||||
|
|
||||||
config := &config{
|
config := &config{
|
||||||
productVariables: productVariables{
|
productVariables: productVariables{
|
||||||
DeviceName: stringPtr("test_device"),
|
DeviceName: stringPtr("test_device"),
|
||||||
Platform_sdk_version: intPtr(30),
|
Platform_sdk_version: intPtr(30),
|
||||||
DeviceSystemSdkVersions: []string{"14", "15"},
|
Platform_sdk_codename: stringPtr("S"),
|
||||||
Platform_systemsdk_versions: []string{"29", "30"},
|
Platform_version_active_codenames: []string{"S"},
|
||||||
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
|
DeviceSystemSdkVersions: []string{"14", "15"},
|
||||||
AAPTPreferredConfig: stringPtr("xhdpi"),
|
Platform_systemsdk_versions: []string{"29", "30"},
|
||||||
AAPTCharacteristics: stringPtr("nosdcard"),
|
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
|
||||||
AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"},
|
AAPTPreferredConfig: stringPtr("xhdpi"),
|
||||||
UncompressPrivAppDex: boolPtr(true),
|
AAPTCharacteristics: stringPtr("nosdcard"),
|
||||||
|
AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"},
|
||||||
|
UncompressPrivAppDex: boolPtr(true),
|
||||||
},
|
},
|
||||||
|
|
||||||
buildDir: buildDir,
|
buildDir: buildDir,
|
||||||
|
@ -620,12 +621,8 @@ func (c *config) PlatformVersionName() string {
|
||||||
return String(c.productVariables.Platform_version_name)
|
return String(c.productVariables.Platform_version_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) PlatformSdkVersionInt() int {
|
func (c *config) PlatformSdkVersion() ApiLevel {
|
||||||
return *c.productVariables.Platform_sdk_version
|
return uncheckedFinalApiLevel(*c.productVariables.Platform_sdk_version)
|
||||||
}
|
|
||||||
|
|
||||||
func (c *config) PlatformSdkVersion() string {
|
|
||||||
return strconv.Itoa(c.PlatformSdkVersionInt())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) PlatformSdkCodename() string {
|
func (c *config) PlatformSdkCodename() string {
|
||||||
|
@ -654,7 +651,7 @@ func (c *config) MinSupportedSdkVersion() ApiLevel {
|
||||||
|
|
||||||
func (c *config) FinalApiLevels() []ApiLevel {
|
func (c *config) FinalApiLevels() []ApiLevel {
|
||||||
var levels []ApiLevel
|
var levels []ApiLevel
|
||||||
for i := 1; i <= c.PlatformSdkVersionInt(); i++ {
|
for i := 1; i <= c.PlatformSdkVersion().FinalOrFutureInt(); i++ {
|
||||||
levels = append(levels, uncheckedFinalApiLevel(i))
|
levels = append(levels, uncheckedFinalApiLevel(i))
|
||||||
}
|
}
|
||||||
return levels
|
return levels
|
||||||
|
@ -678,20 +675,18 @@ func (c *config) AllSupportedApiLevels() []ApiLevel {
|
||||||
return append(levels, c.PreviewApiLevels()...)
|
return append(levels, c.PreviewApiLevels()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Merge this and DefaultAppTargetSdk to just return an ApiLevel.
|
func (c *config) DefaultAppTargetSdk(ctx EarlyModuleContext) ApiLevel {
|
||||||
func (c *config) DefaultAppTargetSdkInt() int {
|
|
||||||
if Bool(c.productVariables.Platform_sdk_final) {
|
|
||||||
return c.PlatformSdkVersionInt()
|
|
||||||
} else {
|
|
||||||
return FutureApiLevelInt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *config) DefaultAppTargetSdk() string {
|
|
||||||
if Bool(c.productVariables.Platform_sdk_final) {
|
if Bool(c.productVariables.Platform_sdk_final) {
|
||||||
return c.PlatformSdkVersion()
|
return c.PlatformSdkVersion()
|
||||||
} else {
|
} else {
|
||||||
return c.PlatformSdkCodename()
|
codename := c.PlatformSdkCodename()
|
||||||
|
if codename == "" {
|
||||||
|
return NoneApiLevel
|
||||||
|
}
|
||||||
|
if codename == "REL" {
|
||||||
|
panic("Platform_sdk_codename should not be REL when Platform_sdk_final is true")
|
||||||
|
}
|
||||||
|
return ApiLevelOrPanic(ctx, codename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
|
||||||
config.TestProductVariables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"}
|
config.TestProductVariables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"}
|
||||||
config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Q")
|
config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Q")
|
||||||
config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false)
|
config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false)
|
||||||
config.TestProductVariables.Platform_version_active_codenames = []string{"R"}
|
config.TestProductVariables.Platform_version_active_codenames = []string{"Q"}
|
||||||
config.TestProductVariables.Platform_vndk_version = proptools.StringPtr("VER")
|
config.TestProductVariables.Platform_vndk_version = proptools.StringPtr("VER")
|
||||||
|
|
||||||
for _, handler := range handlers {
|
for _, handler := range handlers {
|
||||||
|
|
|
@ -533,9 +533,9 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
||||||
optFlags = append(optFlags, "--android_manifest "+androidManifestFile.String())
|
optFlags = append(optFlags, "--android_manifest "+androidManifestFile.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
targetSdkVersion := ctx.Config().DefaultAppTargetSdk()
|
targetSdkVersion := ctx.Config().DefaultAppTargetSdk(ctx).String()
|
||||||
// TODO(b/157078772): propagate min_sdk_version to apexer.
|
// TODO(b/157078772): propagate min_sdk_version to apexer.
|
||||||
minSdkVersion := ctx.Config().DefaultAppTargetSdk()
|
minSdkVersion := ctx.Config().DefaultAppTargetSdk(ctx).String()
|
||||||
|
|
||||||
moduleMinSdkVersion := a.minSdkVersion(ctx)
|
moduleMinSdkVersion := a.minSdkVersion(ctx)
|
||||||
if moduleMinSdkVersion.EqualTo(android.SdkVersion_Android10) {
|
if moduleMinSdkVersion.EqualTo(android.SdkVersion_Android10) {
|
||||||
|
|
|
@ -326,7 +326,7 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"abis": strings.Join(java.SupportedAbis(ctx), ","),
|
"abis": strings.Join(java.SupportedAbis(ctx), ","),
|
||||||
"allow-prereleased": strconv.FormatBool(proptools.Bool(a.properties.Prerelease)),
|
"allow-prereleased": strconv.FormatBool(proptools.Bool(a.properties.Prerelease)),
|
||||||
"sdk-version": ctx.Config().PlatformSdkVersion(),
|
"sdk-version": ctx.Config().PlatformSdkVersion().String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext,
|
||||||
|
|
||||||
// Version code
|
// Version code
|
||||||
if !hasVersionCode {
|
if !hasVersionCode {
|
||||||
linkFlags = append(linkFlags, "--version-code", ctx.Config().PlatformSdkVersion())
|
linkFlags = append(linkFlags, "--version-code", ctx.Config().PlatformSdkVersion().String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !hasVersionName {
|
if !hasVersionName {
|
||||||
|
|
|
@ -157,7 +157,7 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
||||||
"abis": strings.Join(SupportedAbis(ctx), ","),
|
"abis": strings.Join(SupportedAbis(ctx), ","),
|
||||||
"allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)),
|
"allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)),
|
||||||
"screen-densities": screenDensities,
|
"screen-densities": screenDensities,
|
||||||
"sdk-version": ctx.Config().PlatformSdkVersion(),
|
"sdk-version": ctx.Config().PlatformSdkVersion().String(),
|
||||||
"stem": as.BaseModuleName(),
|
"stem": as.BaseModuleName(),
|
||||||
"apkcerts": as.apkcertsFile.String(),
|
"apkcerts": as.apkcertsFile.String(),
|
||||||
"partition": as.PartitionTag(ctx.DeviceConfig()),
|
"partition": as.PartitionTag(ctx.DeviceConfig()),
|
||||||
|
|
|
@ -1078,6 +1078,7 @@ func TestAppSdkVersion(t *testing.T) {
|
||||||
platformSdkFinal bool
|
platformSdkFinal bool
|
||||||
expectedMinSdkVersion string
|
expectedMinSdkVersion string
|
||||||
platformApis bool
|
platformApis bool
|
||||||
|
activeCodenames []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "current final SDK",
|
name: "current final SDK",
|
||||||
|
@ -1094,6 +1095,7 @@ func TestAppSdkVersion(t *testing.T) {
|
||||||
platformSdkCodename: "OMR1",
|
platformSdkCodename: "OMR1",
|
||||||
platformSdkFinal: false,
|
platformSdkFinal: false,
|
||||||
expectedMinSdkVersion: "OMR1",
|
expectedMinSdkVersion: "OMR1",
|
||||||
|
activeCodenames: []string{"OMR1"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "default final SDK",
|
name: "default final SDK",
|
||||||
|
@ -1112,11 +1114,14 @@ func TestAppSdkVersion(t *testing.T) {
|
||||||
platformSdkCodename: "OMR1",
|
platformSdkCodename: "OMR1",
|
||||||
platformSdkFinal: false,
|
platformSdkFinal: false,
|
||||||
expectedMinSdkVersion: "OMR1",
|
expectedMinSdkVersion: "OMR1",
|
||||||
|
activeCodenames: []string{"OMR1"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "14",
|
name: "14",
|
||||||
sdkVersion: "14",
|
sdkVersion: "14",
|
||||||
expectedMinSdkVersion: "14",
|
expectedMinSdkVersion: "14",
|
||||||
|
platformSdkCodename: "S",
|
||||||
|
activeCodenames: []string{"S"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1137,6 +1142,7 @@ func TestAppSdkVersion(t *testing.T) {
|
||||||
config := testAppConfig(nil, bp, nil)
|
config := testAppConfig(nil, bp, nil)
|
||||||
config.TestProductVariables.Platform_sdk_version = &test.platformSdkInt
|
config.TestProductVariables.Platform_sdk_version = &test.platformSdkInt
|
||||||
config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename
|
config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename
|
||||||
|
config.TestProductVariables.Platform_version_active_codenames = test.activeCodenames
|
||||||
config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal
|
config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal
|
||||||
checkSdkVersion(t, config, test.expectedMinSdkVersion)
|
checkSdkVersion(t, config, test.expectedMinSdkVersion)
|
||||||
|
|
||||||
|
@ -1173,15 +1179,6 @@ func TestVendorAppSdkVersion(t *testing.T) {
|
||||||
deviceCurrentApiLevelForVendorModules: "28",
|
deviceCurrentApiLevelForVendorModules: "28",
|
||||||
expectedMinSdkVersion: "28",
|
expectedMinSdkVersion: "28",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "current final SDK",
|
|
||||||
sdkVersion: "current",
|
|
||||||
platformSdkInt: 29,
|
|
||||||
platformSdkCodename: "Q",
|
|
||||||
platformSdkFinal: false,
|
|
||||||
deviceCurrentApiLevelForVendorModules: "current",
|
|
||||||
expectedMinSdkVersion: "Q",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "current final SDK",
|
name: "current final SDK",
|
||||||
sdkVersion: "current",
|
sdkVersion: "current",
|
||||||
|
|
|
@ -1228,7 +1228,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
|
||||||
|
|
||||||
cmd.FlagWithOutput("--generate-api-levels ", d.apiVersionsXml)
|
cmd.FlagWithOutput("--generate-api-levels ", d.apiVersionsXml)
|
||||||
cmd.FlagWithInput("--apply-api-levels ", d.apiVersionsXml)
|
cmd.FlagWithInput("--apply-api-levels ", d.apiVersionsXml)
|
||||||
cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion())
|
cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String())
|
||||||
cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename())
|
cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename())
|
||||||
|
|
||||||
filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar")
|
filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar")
|
||||||
|
|
|
@ -1658,7 +1658,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
||||||
if v := sdkSpec.version; v.isNumbered() {
|
if v := sdkSpec.version; v.isNumbered() {
|
||||||
return v.String()
|
return v.String()
|
||||||
} else {
|
} else {
|
||||||
return ctx.Config().DefaultAppTargetSdk()
|
return ctx.Config().DefaultAppTargetSdk(ctx).String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,7 @@ func (s sdkSpec) effectiveVersion(ctx android.EarlyModuleContext) (sdkVersion, e
|
||||||
if s.version.isNumbered() {
|
if s.version.isNumbered() {
|
||||||
return s.version, nil
|
return s.version, nil
|
||||||
}
|
}
|
||||||
return sdkVersion(ctx.Config().DefaultAppTargetSdkInt()), nil
|
return sdkVersion(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// effectiveVersionString converts an sdkSpec into the concrete version string that the module
|
// effectiveVersionString converts an sdkSpec into the concrete version string that the module
|
||||||
|
@ -255,8 +255,8 @@ func (s sdkSpec) effectiveVersion(ctx android.EarlyModuleContext) (sdkVersion, e
|
||||||
// it returns the codename (P, Q, R, etc.)
|
// it returns the codename (P, Q, R, etc.)
|
||||||
func (s sdkSpec) effectiveVersionString(ctx android.EarlyModuleContext) (string, error) {
|
func (s sdkSpec) effectiveVersionString(ctx android.EarlyModuleContext) (string, error) {
|
||||||
ver, err := s.effectiveVersion(ctx)
|
ver, err := s.effectiveVersion(ctx)
|
||||||
if err == nil && int(ver) == ctx.Config().DefaultAppTargetSdkInt() {
|
if err == nil && int(ver) == ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt() {
|
||||||
return ctx.Config().DefaultAppTargetSdk(), nil
|
return ctx.Config().DefaultAppTargetSdk(ctx).String(), nil
|
||||||
}
|
}
|
||||||
return ver.String(), err
|
return ver.String(), err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue