summaryrefslogtreecommitdiff
path: root/android/sdk.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2022-07-26 23:53:00 +0000
committer Paul Duffin <paulduffin@google.com> 2022-09-14 16:47:18 +0100
commit1938dba8b62a15b9a589e7aaf8ec5a120b7915fe (patch)
treea6619499d1c8a5304d0830bc11d2f9666e3891cd /android/sdk.go
parent887efdd779ecf6b264ea1ca510e47ef74d66f03c (diff)
Exclude unsupported libraries from sdk snapshot
When an sdk snapshot is targeted at release X then it cannot include bootclasspath fragment libraries which are not present in that build as otherwise it causes build failures. It should also not include any unsupported libraries, i.e. libraries that cannot work on that release. This change causes sdk snapshot to exclude libraries that have a min_sdk_version > target build release It also ensures that hidden API flags do not include any information from excluded libraries. Bug: 240406019 Test: BUILD_NUMBER=fixed packages/modules/common/build/mainline_modules_sdks.sh # Ran the previous command with and without this change to make # sure that this change excludes framework-connectivity-t library from the # tethering sdk snapshot for S, including from the hidden API flag files. Change-Id: I57969b85a12e9e5a3fc76c055b260cec5d5f7d7f
Diffstat (limited to 'android/sdk.go')
-rw-r--r--android/sdk.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/android/sdk.go b/android/sdk.go
index a477cbaaf..a9cc547e0 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -74,6 +74,26 @@ type SdkAware interface {
sdkAwareWithoutModule
}
+// minApiLevelForSdkSnapshot provides access to the min_sdk_version for MinApiLevelForSdkSnapshot
+type minApiLevelForSdkSnapshot interface {
+ MinSdkVersion(ctx EarlyModuleContext) SdkSpec
+}
+
+// MinApiLevelForSdkSnapshot returns the ApiLevel of the min_sdk_version of the supplied module.
+//
+// If the module does not provide a min_sdk_version then it defaults to 1.
+func MinApiLevelForSdkSnapshot(ctx EarlyModuleContext, module Module) ApiLevel {
+ minApiLevel := NoneApiLevel
+ if m, ok := module.(minApiLevelForSdkSnapshot); ok {
+ minApiLevel = m.MinSdkVersion(ctx).ApiLevel
+ }
+ if minApiLevel == NoneApiLevel {
+ // The default min API level is 1.
+ minApiLevel = uncheckedFinalApiLevel(1)
+ }
+ return minApiLevel
+}
+
// SdkRef refers to a version of an SDK
type SdkRef struct {
Name string