diff --git a/android/sdk_version.go b/android/sdk_version.go index 7ace638b5..1192f7db9 100644 --- a/android/sdk_version.go +++ b/android/sdk_version.go @@ -28,9 +28,9 @@ type SdkContext interface { // MinSdkVersion returns ApiLevel that corresponds to the min_sdk_version property of the current module, // or from sdk_version if it is not set. MinSdkVersion(ctx EarlyModuleContext) ApiLevel - // ReplaceMaxSdkVersionPlaceholder returns SdkSpec to replace the maxSdkVersion property of permission and + // ReplaceMaxSdkVersionPlaceholder returns Apilevel to replace the maxSdkVersion property of permission and // uses-permission tags if it is set. - ReplaceMaxSdkVersionPlaceholder(ctx EarlyModuleContext) SdkSpec + ReplaceMaxSdkVersionPlaceholder(ctx EarlyModuleContext) ApiLevel // TargetSdkVersion returns the ApiLevel that corresponds to the target_sdk_version property of the current module, // or from sdk_version if it is not set. TargetSdkVersion(ctx EarlyModuleContext) ApiLevel diff --git a/java/aar.go b/java/aar.go index f162a1722..47e6efae3 100644 --- a/java/aar.go +++ b/java/aar.go @@ -721,8 +721,8 @@ func (a *AARImport) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLev return a.SdkVersion(ctx).ApiLevel } -func (a *AARImport) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec { - return android.SdkSpecFrom(ctx, "") +func (a *AARImport) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.ApiLevel { + return android.SdkSpecFrom(ctx, "").ApiLevel } func (a *AARImport) TargetSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { diff --git a/java/base.go b/java/base.go index 2d213a192..1bcff2ed5 100644 --- a/java/base.go +++ b/java/base.go @@ -490,7 +490,7 @@ type Module struct { sdkVersion android.SdkSpec minSdkVersion android.ApiLevel - maxSdkVersion android.SdkSpec + maxSdkVersion android.ApiLevel sourceExtensions []string } @@ -672,16 +672,20 @@ func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel return j.SdkVersion(ctx).ApiLevel } -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) MaxSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { + if j.deviceProperties.Max_sdk_version != nil { + return android.ApiLevelFrom(ctx, *j.deviceProperties.Max_sdk_version) + } + // Default is PrivateApiLevel + return android.SdkSpecPrivate.ApiLevel } -func (j *Module) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec { - replaceMaxSdkVersionPlaceholder := proptools.StringDefault(j.deviceProperties.Replace_max_sdk_version_placeholder, "") - return android.SdkSpecFrom(ctx, replaceMaxSdkVersionPlaceholder) +func (j *Module) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.ApiLevel { + if j.deviceProperties.Replace_max_sdk_version_placeholder != nil { + return android.ApiLevelFrom(ctx, *j.deviceProperties.Replace_max_sdk_version_placeholder) + } + // Default is PrivateApiLevel + return android.SdkSpecPrivate.ApiLevel } func (j *Module) MinSdkVersionString() string { diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index 45e6175f2..bc9de5043 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -136,11 +136,11 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars jar.minSdkVersion = s.minSdkVersion.String() } } - if s.maxSdkVersion.ApiLevel.Specified() { - if s.maxSdkVersion.ApiLevel.IsCurrent() { + if s.maxSdkVersion.Specified() { + if s.maxSdkVersion.IsCurrent() { jar.maxSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String() } else { - jar.maxSdkVersion = s.maxSdkVersion.ApiLevel.String() + jar.maxSdkVersion = s.maxSdkVersion.String() } } } diff --git a/java/droiddoc.go b/java/droiddoc.go index c5a957e26..dbe021d00 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -252,8 +252,8 @@ func (j *Javadoc) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel return j.SdkVersion(ctx).ApiLevel } -func (j *Javadoc) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec { - return j.SdkVersion(ctx) +func (j *Javadoc) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.ApiLevel { + return j.SdkVersion(ctx).ApiLevel } func (j *Javadoc) TargetSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { diff --git a/java/java.go b/java/java.go index 370781599..c0636f716 100644 --- a/java/java.go +++ b/java/java.go @@ -1898,11 +1898,12 @@ func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel return j.SdkVersion(ctx).ApiLevel } -func (j *Import) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec { +func (j *Import) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.ApiLevel { if j.properties.Replace_max_sdk_version_placeholder != nil { - return android.SdkSpecFrom(ctx, *j.properties.Replace_max_sdk_version_placeholder) + return android.ApiLevelFrom(ctx, *j.properties.Replace_max_sdk_version_placeholder) } - return android.SdkSpecFrom(ctx, "") + // Default is PrivateApiLevel + return android.SdkSpecPrivate.ApiLevel } func (j *Import) TargetSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { diff --git a/java/rro.go b/java/rro.go index 6a9ad9aaa..53faca069 100644 --- a/java/rro.go +++ b/java/rro.go @@ -182,8 +182,8 @@ func (r *RuntimeResourceOverlay) MinSdkVersion(ctx android.EarlyModuleContext) a return r.SdkVersion(ctx).ApiLevel } -func (r *RuntimeResourceOverlay) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec { - return android.SdkSpecFrom(ctx, "") +func (r *RuntimeResourceOverlay) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.ApiLevel { + return android.SdkSpecPrivate.ApiLevel } func (r *RuntimeResourceOverlay) TargetSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {