Fix sdk_version: "system_current" when Platform_sdk_final=true

When PLATFORM_VERSION_CODENAME is set to REL Platform_sdk_final
becomes true, which causes the return value of sdkVersionToNumber
for "system_current" to a real version number instead of
FutureApiLevel.  This enables the check against
PlatformSystemSdkVersions, which doesn't contain "current".  Use
the numeric value instead.

Fixes: 129786845
Test: sdk_test.go
Change-Id: If7cf211cc01c5fbf3e3ece3c3f604718a13d5a9b
This commit is contained in:
Colin Cross
2019-04-02 16:10:56 -07:00
parent 9a4f3f7ea8
commit ff0daf4ccf
5 changed files with 66 additions and 25 deletions

View File

@@ -84,7 +84,7 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
v = strconv.Itoa(latestSdkVersion)
}
i, err := sdkVersionToNumber(ctx, v)
numericSdkVersion, err := sdkVersionToNumber(ctx, v)
if err != nil {
ctx.PropertyErrorf("sdk_version", "%s", err)
return sdkDep{}
@@ -151,15 +151,14 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
// Ensures that the specificed system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor apks)
// or PRODUCT_SYSTEMSDK_VERSIONS (for other apks or when BOARD_SYSTEMSDK_VERSIONS is not set)
if strings.HasPrefix(v, "system_") && i != android.FutureApiLevel {
if strings.HasPrefix(v, "system_") && numericSdkVersion != android.FutureApiLevel {
allowed_versions := ctx.DeviceConfig().PlatformSystemSdkVersions()
if ctx.DeviceSpecific() || ctx.SocSpecific() {
if len(ctx.DeviceConfig().SystemSdkVersions()) > 0 {
allowed_versions = ctx.DeviceConfig().SystemSdkVersions()
}
}
version := strings.TrimPrefix(v, "system_")
if len(allowed_versions) > 0 && !android.InList(version, allowed_versions) {
if len(allowed_versions) > 0 && !android.InList(strconv.Itoa(numericSdkVersion), allowed_versions) {
ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q",
v, allowed_versions)
}