diff options
author | 2023-03-01 19:46:18 +0000 | |
---|---|---|
committer | 2023-03-01 20:11:21 +0000 | |
commit | ffb31afdacc5bd4e79930c36aa00f53c7bb022bb (patch) | |
tree | f537084e98d09275626ccc5d5423230f62c4f7ac /android/sdk_version.go | |
parent | 7ba7b46fce25a1c71ff75d9ed7ee22d37d9e854b (diff) |
Support two active sdks in EffectiveVersionString
Currently it would return the default one even if the requested one is
an active sdk.
Bug: 270609292
Test: go test ./java
Test: built `rkpdapp` locally in internal and verified that its
targetSdkVersion is U and V
Test: TH
Change-Id: Idb03ff4786ff87fb7911bf31205941618a662404
Diffstat (limited to 'android/sdk_version.go')
-rw-r--r-- | android/sdk_version.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/android/sdk_version.go b/android/sdk_version.go index 8953eaecd..a7e03dcd8 100644 --- a/android/sdk_version.go +++ b/android/sdk_version.go @@ -211,7 +211,29 @@ func (s SdkSpec) EffectiveVersionString(ctx EarlyModuleContext) (string, error) if !s.ApiLevel.IsPreview() { return s.ApiLevel.String(), nil } - return ctx.Config().DefaultAppTargetSdk(ctx).String(), nil + // Determine the default sdk + ret := ctx.Config().DefaultAppTargetSdk(ctx) + if !ret.IsPreview() { + // If the default sdk has been finalized, return that + return ret.String(), nil + } + // There can be more than one active in-development sdks + // If an app is targeting an active sdk, but not the default one, return the requested active sdk. + // e.g. + // SETUP + // In-development: UpsideDownCake, VanillaIceCream + // Default: VanillaIceCream + // Android.bp + // min_sdk_version: `UpsideDownCake` + // RETURN + // UpsideDownCake and not VanillaIceCream + for _, preview := range ctx.Config().PreviewApiLevels() { + if s.ApiLevel.String() == preview.String() { + return preview.String(), nil + } + } + // Otherwise return the default one + return ret.String(), nil } var ( |