Revert "Revert "Allow codename.fingerprint format for minSdkVersion""

This reverts commit 230e241f58.

Reason for revert: This is a revert of a revert.  Downstream problem has been fixed and have been validated locally and via Forrest build.

Change-Id: I89c51d25b3adb818ea44a983d0ac681a88790d8c
This commit is contained in:
Baligh Uddin
2020-01-24 23:15:44 +00:00
parent 230e241f58
commit f62013736a
3 changed files with 33 additions and 17 deletions

View File

@@ -47,13 +47,29 @@ type sdkContext interface {
targetSdkVersion() string
}
func UseApiFingerprint(ctx android.BaseModuleContext, v string) bool {
if v == ctx.Config().PlatformSdkCodename() &&
ctx.Config().UnbundledBuild() &&
!ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
return true
}
return false
}
func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
var sdkVersion string
switch v {
case "", "none", "current", "test_current", "system_current", "core_current", "core_platform":
return ctx.Config().DefaultAppTargetSdk()
sdkVersion = ctx.Config().DefaultAppTargetSdk()
default:
return v
sdkVersion = v
}
if UseApiFingerprint(ctx, sdkVersion) {
apiFingerprint := ApiFingerprintPath(ctx)
sdkVersion += fmt.Sprintf(".$$(cat %s)", apiFingerprint.String())
}
return sdkVersion
}
// Returns a sdk version as a number. For modules targeting an unreleased SDK (meaning it does not yet have a number)