Merge "Update max_sdk_version from SdkSpec to ApiLevel"

This commit is contained in:
Spandan Das 2023-03-28 19:17:48 +00:00 committed by Gerrit Code Review
commit 5aade5f52d
7 changed files with 28 additions and 23 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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 {

View file

@ -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()
}
}
}

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {