Fix aapt2 --min-sdk-version after finalized SDK
aapt2 --min-sdk-version was using AppsDefaultVersionName(), which
is OMR1 for a non-finalized SDK, but 8.1.0 after finalization.
Add PlatformSdkCodename() for non-finalized SDKs, use it for
DefaultAppTargetSdk(), and pass it for aapt2 --min-sdk-version.
Bug: 78224641
Test: TestAppSdkVersion in app_test.go
Change-Id: I622eaf92f8a940f79007c2a579536da325700b06
diff --git a/android/config.go b/android/config.go
index 7122f48..40ba8c1 100644
--- a/android/config.go
+++ b/android/config.go
@@ -476,6 +476,10 @@
return strconv.Itoa(c.PlatformSdkVersionInt())
}
+func (c *config) PlatformSdkCodename() string {
+ return String(c.productVariables.Platform_sdk_codename)
+}
+
func (c *config) MinSupportedSdkVersion() int {
return 14
}
@@ -488,6 +492,14 @@
}
}
+func (c *config) DefaultAppTargetSdk() string {
+ if Bool(c.productVariables.Platform_sdk_final) {
+ return c.PlatformSdkVersion()
+ } else {
+ return c.PlatformSdkCodename()
+ }
+}
+
func (c *config) AppsDefaultVersionName() string {
return String(c.productVariables.AppsDefaultVersionName)
}