From fa9b3f30fd5da13519c14c3ac281662879c6be3e Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Tue, 30 Mar 2021 10:38:26 +0900 Subject: [PATCH] Set the usesNonSdk manifest attribute whan targeting module SDKs. From an ART perspective, calling module-lib APIs requires the ability to bypass hiddenapi enforcement entirely. This CL ensures that if an APK compiles against module-lib APIs, it will be able to call those APIs. Currently, compiling against module-lib APIs is not safe because APKs that are subject to hiddenapi protection will crash at runtime. Bug: 181309531 Test: made NetworkStackNext compile against module-current, and: Test: aapt dump xmltree .../NetworkStackNext.apk AndroidManifest.xml | grep usesNonSdk Change-Id: I5ca3328c64412078d803e0e3ffa1d8383602416f --- java/app.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/app.go b/java/app.go index ec30b4940..2befac8db 100755 --- a/java/app.go +++ b/java/app.go @@ -380,7 +380,11 @@ func (a *AndroidApp) renameResourcesPackage() bool { } func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) { - a.aapt.usesNonSdkApis = Bool(a.Module.deviceProperties.Platform_apis) + usePlatformAPI := proptools.Bool(a.Module.deviceProperties.Platform_apis) + if ctx.Module().(android.SdkContext).SdkVersion().Kind == android.SdkModule { + usePlatformAPI = true + } + a.aapt.usesNonSdkApis = usePlatformAPI // Ask manifest_fixer to add or update the application element indicating this app has no code. a.aapt.hasNoCode = !a.hasCode(ctx)