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:
Dan Albert
2020-07-23 17:32:15 -07:00
parent 0b176c8038
commit 4f378d75aa
11 changed files with 41 additions and 49 deletions

View File

@@ -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)
}
}