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
diff --git a/java/java.go b/java/java.go
index 94ec85e..65e3b41 100644
--- a/java/java.go
+++ b/java/java.go
@@ -308,7 +308,7 @@
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 @@
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 @@
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 {