Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f378d75 authored by Dan Albert's avatar Dan Albert
Browse files

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
parent 0b176c80
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+23 −28
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import (
	"os"
	"path/filepath"
	"runtime"
	"strconv"
	"strings"
	"sync"

@@ -230,6 +229,8 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
		productVariables: productVariables{
			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"},
@@ -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 {
func (c *config) DefaultAppTargetSdk(ctx EarlyModuleContext) ApiLevel {
	if Bool(c.productVariables.Platform_sdk_final) {
		return c.PlatformSdkVersionInt()
		return c.PlatformSdkVersion()
	} else {
		return FutureApiLevelInt
		codename := c.PlatformSdkCodename()
		if codename == "" {
			return NoneApiLevel
		}
		if codename == "REL" {
			panic("Platform_sdk_codename should not be REL when Platform_sdk_final is true")
		}

func (c *config) DefaultAppTargetSdk() string {
	if Bool(c.productVariables.Platform_sdk_final) {
		return c.PlatformSdkVersion()
	} else {
		return c.PlatformSdkCodename()
		return ApiLevelOrPanic(ctx, codename)
	}
}

+1 −1
Original line number Diff line number Diff line
@@ -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 {
+2 −2
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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(),
			},
		})

Loading