summaryrefslogtreecommitdiff
path: root/android/api_levels.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/api_levels.go')
-rw-r--r--android/api_levels.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/android/api_levels.go b/android/api_levels.go
index 93583bc07..c1b3ba2ba 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -177,6 +177,10 @@ var FirstPackedRelocationsVersion = uncheckedFinalApiLevel(23)
// libandroid_support.
var FirstNonLibAndroidSupportVersion = uncheckedFinalApiLevel(21)
+// LastWithoutModuleLibCoreSystemModules is the last API level where prebuilts/sdk does not contain
+// a core-for-system-modules.jar for the module-lib API scope.
+var LastWithoutModuleLibCoreSystemModules = uncheckedFinalApiLevel(31)
+
// If the `raw` input is the codename of an API level has been finalized, this
// function returns the API level number associated with that API level. If the
// input is *not* a finalized codename, the input is returned unmodified.
@@ -236,6 +240,27 @@ func ApiLevelFromUser(ctx PathContext, raw string) (ApiLevel, error) {
return apiLevel, nil
}
+// ApiLevelForTest returns an ApiLevel constructed from the supplied raw string.
+//
+// This only supports "current" and numeric levels, code names are not supported.
+func ApiLevelForTest(raw string) ApiLevel {
+ if raw == "" {
+ panic("API level string must be non-empty")
+ }
+
+ if raw == "current" {
+ return FutureApiLevel
+ }
+
+ 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))
+ }
+
+ apiLevel := uncheckedFinalApiLevel(asInt)
+ return apiLevel
+}
+
// Converts an API level string `raw` into an ApiLevel in the same method as
// `ApiLevelFromUser`, but the input is assumed to have no errors and any errors
// will panic instead of returning an error.