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
|
||||
// final R build.
|
||||
if Bool(config.productVariables.Platform_sdk_final) {
|
||||
apiLevelsMap["current"] = config.PlatformSdkVersionInt()
|
||||
apiLevelsMap["current"] = config.PlatformSdkVersion().FinalOrFutureInt()
|
||||
}
|
||||
|
||||
return apiLevelsMap
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
|
@ -228,15 +227,17 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
|||
|
||||
config := &config{
|
||||
productVariables: productVariables{
|
||||
DeviceName: stringPtr("test_device"),
|
||||
Platform_sdk_version: intPtr(30),
|
||||
DeviceSystemSdkVersions: []string{"14", "15"},
|
||||
Platform_systemsdk_versions: []string{"29", "30"},
|
||||
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
|
||||
AAPTPreferredConfig: stringPtr("xhdpi"),
|
||||
AAPTCharacteristics: stringPtr("nosdcard"),
|
||||
AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"},
|
||||
UncompressPrivAppDex: boolPtr(true),
|
||||
DeviceName: stringPtr("test_device"),
|
||||
Platform_sdk_version: intPtr(30),
|
||||
Platform_sdk_codename: stringPtr("S"),
|
||||
Platform_version_active_codenames: []string{"S"},
|
||||
DeviceSystemSdkVersions: []string{"14", "15"},
|
||||
Platform_systemsdk_versions: []string{"29", "30"},
|
||||
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
|
||||
AAPTPreferredConfig: stringPtr("xhdpi"),
|
||||
AAPTCharacteristics: stringPtr("nosdcard"),
|
||||
AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"},
|
||||
UncompressPrivAppDex: boolPtr(true),
|
||||
},
|
||||
|
||||
buildDir: buildDir,
|
||||
|
@ -620,12 +621,8 @@ func (c *config) PlatformVersionName() string {
|
|||
return String(c.productVariables.Platform_version_name)
|
||||
}
|
||||
|
||||
func (c *config) PlatformSdkVersionInt() int {
|
||||
return *c.productVariables.Platform_sdk_version
|
||||
}
|
||||
|
||||
func (c *config) PlatformSdkVersion() string {
|
||||
return strconv.Itoa(c.PlatformSdkVersionInt())
|
||||
func (c *config) PlatformSdkVersion() ApiLevel {
|
||||
return uncheckedFinalApiLevel(*c.productVariables.Platform_sdk_version)
|
||||
}
|
||||
|
||||
func (c *config) PlatformSdkCodename() string {
|
||||
|
@ -654,7 +651,7 @@ func (c *config) MinSupportedSdkVersion() ApiLevel {
|
|||
|
||||
func (c *config) FinalApiLevels() []ApiLevel {
|
||||
var levels []ApiLevel
|
||||
for i := 1; i <= c.PlatformSdkVersionInt(); i++ {
|
||||
for i := 1; i <= c.PlatformSdkVersion().FinalOrFutureInt(); i++ {
|
||||
levels = append(levels, uncheckedFinalApiLevel(i))
|
||||
}
|
||||
return levels
|
||||
|
@ -678,20 +675,18 @@ func (c *config) AllSupportedApiLevels() []ApiLevel {
|
|||
return append(levels, c.PreviewApiLevels()...)
|
||||
}
|
||||
|
||||
// TODO: Merge this and DefaultAppTargetSdk to just return an ApiLevel.
|
||||
func (c *config) DefaultAppTargetSdkInt() int {
|
||||
if Bool(c.productVariables.Platform_sdk_final) {
|
||||
return c.PlatformSdkVersionInt()
|
||||
} else {
|
||||
return FutureApiLevelInt
|
||||
}
|
||||
}
|
||||
|
||||
func (c *config) DefaultAppTargetSdk() string {
|
||||
func (c *config) DefaultAppTargetSdk(ctx EarlyModuleContext) ApiLevel {
|
||||
if Bool(c.productVariables.Platform_sdk_final) {
|
||||
return c.PlatformSdkVersion()
|
||||
} 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.Platform_sdk_codename = proptools.StringPtr("Q")
|
||||
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")
|
||||
|
||||
for _, handler := range handlers {
|
||||
|
|
|
@ -533,9 +533,9 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||
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.
|
||||
minSdkVersion := ctx.Config().DefaultAppTargetSdk()
|
||||
minSdkVersion := ctx.Config().DefaultAppTargetSdk(ctx).String()
|
||||
|
||||
moduleMinSdkVersion := a.minSdkVersion(ctx)
|
||||
if moduleMinSdkVersion.EqualTo(android.SdkVersion_Android10) {
|
||||
|
|
|
@ -326,7 +326,7 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
Args: map[string]string{
|
||||
"abis": strings.Join(java.SupportedAbis(ctx), ","),
|
||||
"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
|
||||
if !hasVersionCode {
|
||||
linkFlags = append(linkFlags, "--version-code", ctx.Config().PlatformSdkVersion())
|
||||
linkFlags = append(linkFlags, "--version-code", ctx.Config().PlatformSdkVersion().String())
|
||||
}
|
||||
|
||||
if !hasVersionName {
|
||||
|
|
|
@ -157,7 +157,7 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||
"abis": strings.Join(SupportedAbis(ctx), ","),
|
||||
"allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)),
|
||||
"screen-densities": screenDensities,
|
||||
"sdk-version": ctx.Config().PlatformSdkVersion(),
|
||||
"sdk-version": ctx.Config().PlatformSdkVersion().String(),
|
||||
"stem": as.BaseModuleName(),
|
||||
"apkcerts": as.apkcertsFile.String(),
|
||||
"partition": as.PartitionTag(ctx.DeviceConfig()),
|
||||
|
|
|
@ -1078,6 +1078,7 @@ func TestAppSdkVersion(t *testing.T) {
|
|||
platformSdkFinal bool
|
||||
expectedMinSdkVersion string
|
||||
platformApis bool
|
||||
activeCodenames []string
|
||||
}{
|
||||
{
|
||||
name: "current final SDK",
|
||||
|
@ -1094,6 +1095,7 @@ func TestAppSdkVersion(t *testing.T) {
|
|||
platformSdkCodename: "OMR1",
|
||||
platformSdkFinal: false,
|
||||
expectedMinSdkVersion: "OMR1",
|
||||
activeCodenames: []string{"OMR1"},
|
||||
},
|
||||
{
|
||||
name: "default final SDK",
|
||||
|
@ -1112,11 +1114,14 @@ func TestAppSdkVersion(t *testing.T) {
|
|||
platformSdkCodename: "OMR1",
|
||||
platformSdkFinal: false,
|
||||
expectedMinSdkVersion: "OMR1",
|
||||
activeCodenames: []string{"OMR1"},
|
||||
},
|
||||
{
|
||||
name: "14",
|
||||
sdkVersion: "14",
|
||||
expectedMinSdkVersion: "14",
|
||||
platformSdkCodename: "S",
|
||||
activeCodenames: []string{"S"},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1137,6 +1142,7 @@ func TestAppSdkVersion(t *testing.T) {
|
|||
config := testAppConfig(nil, bp, nil)
|
||||
config.TestProductVariables.Platform_sdk_version = &test.platformSdkInt
|
||||
config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename
|
||||
config.TestProductVariables.Platform_version_active_codenames = test.activeCodenames
|
||||
config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal
|
||||
checkSdkVersion(t, config, test.expectedMinSdkVersion)
|
||||
|
||||
|
@ -1173,15 +1179,6 @@ func TestVendorAppSdkVersion(t *testing.T) {
|
|||
deviceCurrentApiLevelForVendorModules: "28",
|
||||
expectedMinSdkVersion: "28",
|
||||
},
|
||||
{
|
||||
name: "current final SDK",
|
||||
sdkVersion: "current",
|
||||
platformSdkInt: 29,
|
||||
platformSdkCodename: "Q",
|
||||
platformSdkFinal: false,
|
||||
deviceCurrentApiLevelForVendorModules: "current",
|
||||
expectedMinSdkVersion: "Q",
|
||||
},
|
||||
{
|
||||
name: "current final SDK",
|
||||
sdkVersion: "current",
|
||||
|
|
|
@ -1228,7 +1228,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
|
|||
|
||||
cmd.FlagWithOutput("--generate-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())
|
||||
|
||||
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() {
|
||||
return v.String()
|
||||
} 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() {
|
||||
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
|
||||
|
@ -255,8 +255,8 @@ func (s sdkSpec) effectiveVersion(ctx android.EarlyModuleContext) (sdkVersion, e
|
|||
// it returns the codename (P, Q, R, etc.)
|
||||
func (s sdkSpec) effectiveVersionString(ctx android.EarlyModuleContext) (string, error) {
|
||||
ver, err := s.effectiveVersion(ctx)
|
||||
if err == nil && int(ver) == ctx.Config().DefaultAppTargetSdkInt() {
|
||||
return ctx.Config().DefaultAppTargetSdk(), nil
|
||||
if err == nil && int(ver) == ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt() {
|
||||
return ctx.Config().DefaultAppTargetSdk(ctx).String(), nil
|
||||
}
|
||||
return ver.String(), err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue