Add PLATFORM_SYSTEMSDK_VERSIONS and BOARD_SYSTEMSDK_VERSIONS

PLATFORM_SYSTEMSDK_VERSIONS is the list of System SDK versions that the
platform is supporting. Contrary to the public SDK where platform
essentially supports all previous SDK versions, platform support only a
few recent System SDK versions, since some of old System APIs are
gradually deprecated, removed from the following SDKs and then finally
deleted from the platform. This will be part of the framework manifest.

The list can be specified by setting PLATFORM_SYSTEMSDK_MIN_VERSION. If
it is set to an old version number, then System SDKs from the version
to the current version (PLATFORM_SDK_VERSION) are considered to be
supported by the platform. If PLATFORM_SYSTEMSDK_MIN_VERSION is not set,
only the latest System SDK version is supported.

Next, BOARD_SYSTEMSDK_VERSIONS is the list of System SDK versions that
the device is using. This is put to the device compatibility matrix
device is using. The device and the platform is considered as compatible
only BOARD_SYSTEMSDK_VERSIONS in the device compatibility matrix are
in the PLATFORM_SYSTEMSDK_VERSIONS in the framework manifest.

When BOARD_SYSTEMSDK_VERSIONS is set, a Java app or library in vendor or
odm partitions which didn't specify LOCAL_SDK_VERSION  is forced to use
System SDK. Also, the build system does the additional integrity check
to ensure that LOCAL_SDK_VERSION is within BOARD_SYSTEMSDK_VERSIONS or
PLATFORM_SYSTEMSDK_VERSIONS (if BOARD_SYSTEMSDK_VERSIONS isn't set).

Bug: 69088799
Test: m -j
Test: BOARD_SYSTEMSDK_VERSIONS=P m -j
Change-Id: Id38f02b4be86710411be22bc28109e6894f8a483
This commit is contained in:
Jiyong Park 2018-01-15 15:05:10 +09:00
parent 64946fec54
commit 1a5d7b1539
4 changed files with 42 additions and 10 deletions

View File

@ -31,6 +31,7 @@ import (
var Bool = proptools.Bool
var String = proptools.String
var FutureApiLevel = 10000
// The configuration file name
const configFileName = "soong.config"
@ -453,7 +454,7 @@ func (c *config) DefaultAppTargetSdkInt() int {
if Bool(c.ProductVariables.Platform_sdk_final) {
return c.PlatformSdkVersionInt()
} else {
return 10000
return FutureApiLevel
}
}
@ -657,6 +658,17 @@ func (c *deviceConfig) ExtraVndkVersions() []string {
return c.config.ProductVariables.ExtraVndkVersions
}
func (c *deviceConfig) SystemSdkVersions() []string {
if c.config.ProductVariables.DeviceSystemSdkVersions == nil {
return nil
}
return *c.config.ProductVariables.DeviceSystemSdkVersions
}
func (c *deviceConfig) PlatformSystemSdkVersions() []string {
return c.config.ProductVariables.Platform_systemsdk_versions
}
func (c *deviceConfig) OdmPath() string {
if c.config.ProductVariables.OdmPath != nil {
return *c.config.ProductVariables.OdmPath

View File

@ -115,13 +115,15 @@ type productVariables struct {
Platform_version_active_codenames []string `json:",omitempty"`
Platform_version_future_codenames []string `json:",omitempty"`
Platform_vndk_version *string `json:",omitempty"`
Platform_systemsdk_versions []string `json:",omitempty"`
DeviceName *string `json:",omitempty"`
DeviceArch *string `json:",omitempty"`
DeviceArchVariant *string `json:",omitempty"`
DeviceCpuVariant *string `json:",omitempty"`
DeviceAbi *[]string `json:",omitempty"`
DeviceVndkVersion *string `json:",omitempty"`
DeviceName *string `json:",omitempty"`
DeviceArch *string `json:",omitempty"`
DeviceArchVariant *string `json:",omitempty"`
DeviceCpuVariant *string `json:",omitempty"`
DeviceAbi *[]string `json:",omitempty"`
DeviceVndkVersion *string `json:",omitempty"`
DeviceSystemSdkVersions *[]string `json:",omitempty"`
DeviceSecondaryArch *string `json:",omitempty"`
DeviceSecondaryArchVariant *string `json:",omitempty"`

View File

@ -308,7 +308,7 @@ type sdkDep struct {
func sdkStringToNumber(ctx android.BaseContext, v string) int {
switch v {
case "", "current", "system_current", "test_current":
return 10000
return android.FutureApiLevel
default:
if i, err := strconv.Atoi(android.GetNumericSdkVersion(v)); err != nil {
ctx.PropertyErrorf("sdk_version", "invalid sdk version")
@ -336,6 +336,22 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
return 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 {
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) {
ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q",
v, allowed_versions)
}
}
toFile := func(v string) sdkDep {
dir := filepath.Join("prebuilts/sdk", v)
jar := filepath.Join(dir, "android.jar")
@ -638,7 +654,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
flags.javaVersion = "1.7"
} else if ctx.Device() && sdk <= 26 || !ctx.Config().TargetOpenJDK9() {
flags.javaVersion = "1.8"
} else if ctx.Device() && String(j.deviceProperties.Sdk_version) != "" && sdk == 10000 {
} else if ctx.Device() && String(j.deviceProperties.Sdk_version) != "" && sdk == android.FutureApiLevel {
// TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current"
flags.javaVersion = "1.8"
} else {

View File

@ -59,7 +59,9 @@ func testConfig(env map[string]string) android.Config {
if env["ANDROID_JAVA8_HOME"] == "" {
env["ANDROID_JAVA8_HOME"] = "jdk8"
}
return android.TestArchConfig(buildDir, env)
config := android.TestArchConfig(buildDir, env)
config.ProductVariables.DeviceSystemSdkVersions = &[]string{"14", "15"}
return config
}