Apply sdk version check to product apps
1. Check if system sdk version of apps from product partition is one of BOARD_SYSTEMSDK_VERSIONS. 2. The logic that check system sdk version doesn't work after aosp/1212908 because it always returns early Bug: 147711383 Test: m Test: set sdk_version the version that doesn't exist in BOARD_SYSTEMSDK_VERSIONS, and check if it cannot build Change-Id: I923477cffbcd9c763ee2deb5e7cce29aa005c715
This commit is contained in:
parent
323a4c3ab3
commit
7c7083163a
40
java/sdk.go
40
java/sdk.go
|
@ -283,6 +283,28 @@ func sdkSpecFrom(str string) sdkSpec {
|
|||
}
|
||||
}
|
||||
|
||||
func (s sdkSpec) validateSystemSdk(ctx android.EarlyModuleContext) bool {
|
||||
// Ensures that the specified system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor/product Java module)
|
||||
// Assuming that BOARD_SYSTEMSDK_VERSIONS := 28 29,
|
||||
// sdk_version of the modules in vendor/product that use system sdk must be either system_28, system_29 or system_current
|
||||
if s.kind != sdkSystem || !s.version.isNumbered() {
|
||||
return true
|
||||
}
|
||||
allowedVersions := ctx.DeviceConfig().PlatformSystemSdkVersions()
|
||||
if ctx.DeviceSpecific() || ctx.SocSpecific() || (ctx.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
|
||||
systemSdkVersions := ctx.DeviceConfig().SystemSdkVersions()
|
||||
if len(systemSdkVersions) > 0 {
|
||||
allowedVersions = systemSdkVersions
|
||||
}
|
||||
}
|
||||
if len(allowedVersions) > 0 && !android.InList(s.version.String(), allowedVersions) {
|
||||
ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q",
|
||||
s.raw, allowedVersions)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep {
|
||||
sdkVersion := sdkContext.sdkVersion()
|
||||
if !sdkVersion.valid() {
|
||||
|
@ -293,6 +315,9 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep
|
|||
if ctx.Config().IsPdkBuild() {
|
||||
sdkVersion = sdkVersion.forPdkBuild(ctx)
|
||||
}
|
||||
if !sdkVersion.validateSystemSdk(ctx) {
|
||||
return sdkDep{}
|
||||
}
|
||||
|
||||
if sdkVersion.usePrebuilt(ctx) {
|
||||
dir := filepath.Join("prebuilts", "sdk", sdkVersion.version.String(), sdkVersion.kind.String())
|
||||
|
@ -340,21 +365,6 @@ func decodeSdkDep(ctx android.EarlyModuleContext, 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 sdkVersion.kind == sdkSystem && sdkVersion.version.isNumbered() {
|
||||
allowed_versions := ctx.DeviceConfig().PlatformSystemSdkVersions()
|
||||
if ctx.DeviceSpecific() || ctx.SocSpecific() {
|
||||
if len(ctx.DeviceConfig().SystemSdkVersions()) > 0 {
|
||||
allowed_versions = ctx.DeviceConfig().SystemSdkVersions()
|
||||
}
|
||||
}
|
||||
if len(allowed_versions) > 0 && !android.InList(sdkVersion.version.String(), allowed_versions) {
|
||||
ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q",
|
||||
sdkVersion.raw, allowed_versions)
|
||||
}
|
||||
}
|
||||
|
||||
switch sdkVersion.kind {
|
||||
case sdkPrivate:
|
||||
return sdkDep{
|
||||
|
|
Loading…
Reference in New Issue