Merge "Simplify logic in Soong ApiLevelFromUserWithConfig" am: 2173e6545a am: 0e5c5598aa

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2509779

Change-Id: Ib404917275df195b9aa6fbdea8cfef386b880b22
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Alix Espino
2023-04-03 14:38:24 +00:00
committed by Automerger Merge Worker

View File

@@ -344,14 +344,17 @@ func ApiLevelFromUserWithConfig(config Config, raw string) (ApiLevel, error) {
}
}
canonical := ReplaceFinalizedCodenames(config, raw)
asInt, err := strconv.Atoi(canonical)
canonical, ok := getApiLevelsMapReleasedVersions()[raw]
if !ok {
asInt, err := strconv.Atoi(raw)
if err != nil {
return NoneApiLevel, fmt.Errorf("%q could not be parsed as an integer and is not a recognized codename", canonical)
return NoneApiLevel, fmt.Errorf("%q could not be parsed as an integer and is not a recognized codename", raw)
}
return uncheckedFinalApiLevel(asInt), nil
}
apiLevel := uncheckedFinalApiLevel(asInt)
return apiLevel, nil
return uncheckedFinalApiLevel(canonical), nil
}
// ApiLevelForTest returns an ApiLevel constructed from the supplied raw string.