Introduce max_sdk_version device property.

Artifacts that go into apexes should only be active on certain SDK
versions. There is now a need to upper bound the range to support
expressiong statements like "this jar should only run on platforms
30-31".

Bug: 190818041
Test: presubmit
Change-Id: I6985ebb671841cdd9f0f37f916267ac5ed76e4f4
This commit is contained in:
satayev
2021-11-29 17:25:52 +00:00
parent 0ee2f913ef
commit 0a420e771a
2 changed files with 13 additions and 0 deletions

View File

@@ -197,6 +197,10 @@ type DeviceProperties struct {
// Defaults to sdk_version if not set. See sdk_version for possible values.
Min_sdk_version *string
// if not blank, set the maximum version of the sdk that the compiled artifacts will run against.
// Defaults to empty string "". See sdk_version for possible values.
Max_sdk_version *string
// if not blank, set the targetSdkVersion in the AndroidManifest.xml.
// Defaults to sdk_version if not set. See sdk_version for possible values.
Target_sdk_version *string
@@ -460,6 +464,7 @@ type Module struct {
sdkVersion android.SdkSpec
minSdkVersion android.SdkSpec
maxSdkVersion android.SdkSpec
}
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
@@ -617,6 +622,13 @@ func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
return j.SdkVersion(ctx)
}
func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
maxSdkVersion := proptools.StringDefault(j.deviceProperties.Max_sdk_version, "")
// SdkSpecFrom returns SdkSpecPrivate for this, which may be confusing.
// TODO(b/208456999): ideally MaxSdkVersion should be an ApiLevel and not SdkSpec.
return android.SdkSpecFrom(ctx, maxSdkVersion)
}
func (j *Module) MinSdkVersionString() string {
return j.minSdkVersion.Raw
}