apex: choose stub according to min_sdk_version

Native modules within APEX should be linked with proper stub version
according to its min_sdk_version.

For example, when min_sdk_version is set to "29", libfoo in the apex
would be linked to libbar of version 29 from platform, even if it has
a newer version like 30.

Bug: 145796956
Test: m nothing (soong tests)
Merged-In: I4a0b2002587bc24b7deeb5d59b6eeba5e1db5b1f
Change-Id: I4a0b2002587bc24b7deeb5d59b6eeba5e1db5b1f
(cherry picked from commit 03b5185b88)

Exempt-From-Owner-Approval: got ORV already.
This commit is contained in:
Jooyung Han
2020-02-26 22:45:42 +09:00
parent d10db8f8e3
commit 0c4e016428
7 changed files with 374 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ import (
"path"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
@@ -1042,9 +1043,11 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) {
var apexBundles []android.ApexInfo
var directDep bool
if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
minSdkVersion := a.minSdkVersion(mctx)
apexBundles = []android.ApexInfo{android.ApexInfo{
ApexName: mctx.ModuleName(),
LegacyAndroid10Support: proptools.Bool(a.properties.Legacy_android10_support),
MinSdkVersion: minSdkVersion,
}}
directDep = true
} else if am, ok := mctx.Module().(android.ApexModule); ok {
@@ -1994,6 +1997,18 @@ func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext,
})
}
func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
ver := proptools.StringDefault(a.properties.Min_sdk_version, "current")
if ver != "current" {
minSdkVersion, err := strconv.Atoi(ver)
if err != nil {
ctx.PropertyErrorf("min_sdk_version", "should be \"current\" or <number>, but %q", ver)
}
return minSdkVersion
}
return android.FutureApiLevel
}
// Ensures that the dependencies are marked as available for this APEX
func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
// Let's be practical. Availability for test, host, and the VNDK apex isn't important