From 652d5b31ef7822b2fe9ba59638011864718eb568 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Wed, 20 May 2020 17:12:13 +0900 Subject: [PATCH] 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. Exempt-From-Owner-Approval: cherrypick from internal Bug: 145796956 Test: m Merged-In: I2c4dbb79ae8712004dc3a9e647aa53cd5de7b508 Change-Id: I2c4dbb79ae8712004dc3a9e647aa53cd5de7b508 (cherry picked from commit 9d2c0f7af2c726dc62d6df28bc06302965129219) --- java/app.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/app.go b/java/app.go index 4a28fd929..0bc89d456 100755 --- a/java/app.go +++ b/java/app.go @@ -441,8 +441,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 + // We can rely on sdkSpec to convert it to 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