Update min_sdk_version from SdkSpec to ApiLevel

This relands aosp/2457063. The original change broke T and U since those
branches still contain soong modules of type (kind+level). Those soong
modules have been cleaned up now

Test: Used go/abtd to test T and U branches with this change

Bug: 208456999
Change-Id: I0ef7933c055f88cb512a02108f1173e51156ef1c
This commit is contained in:
Spandan Das
2023-03-03 21:20:36 +00:00
parent 7947b31a55
commit 8c9ae7ed67
18 changed files with 83 additions and 71 deletions

View File

@@ -185,6 +185,14 @@ func (l ApiLevel) EffectiveVersionString(ctx EarlyModuleContext) (string, error)
return ret.String(), nil
}
// Specified returns true if the module is targeting a recognzized api_level.
// It returns false if either
// 1. min_sdk_version is not an int or a recognized codename
// 2. both min_sdk_version and sdk_version are empty. In this case, MinSdkVersion() defaults to SdkSpecPrivate.ApiLevel
func (this ApiLevel) Specified() bool {
return !this.IsInvalid() && !this.IsPrivate()
}
// Returns -1 if the current API level is less than the argument, 0 if they
// are equal, and 1 if it is greater than the argument.
func (this ApiLevel) CompareTo(other ApiLevel) int {
@@ -289,6 +297,16 @@ func ReplaceFinalizedCodenames(config Config, raw string) string {
return strconv.Itoa(num)
}
// ApiLevelFrom converts the given string `raw` to an ApiLevel.
// If `raw` is invalid (empty string, unrecognized codename etc.) it returns an invalid ApiLevel
func ApiLevelFrom(ctx PathContext, raw string) ApiLevel {
ret, err := ApiLevelFromUser(ctx, raw)
if err != nil {
return NewInvalidApiLevel(raw)
}
return ret
}
// ApiLevelFromUser converts the given string `raw` to an ApiLevel, possibly returning an error.
//
// `raw` must be non-empty. Passing an empty string results in a panic.