Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a420e77 authored by satayev's avatar satayev
Browse files

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
parent 0ee2f913
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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
}
+1 −0
Original line number Diff line number Diff line
@@ -545,6 +545,7 @@ func setUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter, dexer
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	j.sdkVersion = j.SdkVersion(ctx)
	j.minSdkVersion = j.MinSdkVersion(ctx)
	j.maxSdkVersion = j.MaxSdkVersion(ctx)

	apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
	if !apexInfo.IsForPlatform() {