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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user