diff options
Diffstat (limited to 'android/api_levels.go')
-rw-r--r-- | android/api_levels.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/android/api_levels.go b/android/api_levels.go index 44c86403d..3f538c038 100644 --- a/android/api_levels.go +++ b/android/api_levels.go @@ -19,6 +19,7 @@ import ( "encoding/json" "fmt" "strconv" + "strings" ) func init() { @@ -237,6 +238,14 @@ func uncheckedFinalApiLevel(num int) ApiLevel { } } +func uncheckedFinalIncrementalApiLevel(num int, increment int) ApiLevel { + return ApiLevel{ + value: strconv.Itoa(num) + "." + strconv.Itoa(increment), + number: num, + isPreview: false, + } +} + var NoneApiLevel = ApiLevel{ value: "(no version)", // Not 0 because we don't want this to compare equal with the first preview. @@ -371,6 +380,22 @@ func ApiLevelForTest(raw string) ApiLevel { return FutureApiLevel } + if strings.Contains(raw, ".") { + // Check prebuilt incremental API format MM.m for major (API level) and minor (incremental) revisions + parts := strings.Split(raw, ".") + if len(parts) != 2 { + panic(fmt.Errorf("Found unexpected version '%s' for incremental API - expect MM.m format for incremental API with both major (MM) an minor (m) revision.", raw)) + } + sdk, sdk_err := strconv.Atoi(parts[0]) + qpr, qpr_err := strconv.Atoi(parts[1]) + if sdk_err != nil || qpr_err != nil { + panic(fmt.Errorf("Unable to read version number for incremental api '%s'", raw)) + } + + apiLevel := uncheckedFinalIncrementalApiLevel(sdk, qpr) + return apiLevel + } + asInt, err := strconv.Atoi(raw) if err != nil { panic(fmt.Errorf("%q could not be parsed as an integer and is not a recognized codename", raw)) |