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
This commit is contained in:
Lorenzo Colitti 2021-03-30 10:38:26 +09:00
parent 0774773a65
commit fa9b3f30fd
1 changed files with 5 additions and 1 deletions

View File

@ -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)