Use sdkSpec to compare sdk_versions of APK/JNI

"current" is converted to int differently if we use
sdkSpec.effectiveVersion for APK and android.ApiStrToNum for JNI.
For example, in REL branch, "current" is equiv to PlatformSdkVersion
for APK, but 10000(FutureApiVersion) for JNI.

Use sdkSpec.effectiveVersion to compare APK.min_sdk_version and
JNI.sdk_version.

Bug: 145796956
Test: m
Change-Id: I2c4dbb79ae8712004dc3a9e647aa53cd5de7b508
This commit is contained in:
Jooyung Han 2020-05-20 17:12:13 +09:00
parent af7f91fc9d
commit 9d2c0f7af2
1 changed files with 5 additions and 2 deletions

View File

@ -445,8 +445,11 @@ func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVer
return
}
dep, _ := m.(*cc.Module)
jniSdkVersion, err := android.ApiStrToNum(ctx, dep.SdkVersion())
if err != nil || int(minSdkVersion) < jniSdkVersion {
// The domain of cc.sdk_version is "current" and <number>
// We can rely on sdkSpec to convert it to <number> so that "current" is handled
// properly regardless of sdk finalization.
jniSdkVersion, err := sdkSpecFrom(dep.SdkVersion()).effectiveVersion(ctx)
if err != nil || minSdkVersion < jniSdkVersion {
ctx.OtherModuleErrorf(dep, "sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)",
dep.SdkVersion(), minSdkVersion, ctx.ModuleName())
return