Replace stringly-typed API levels.
Handling of API levels within Soong is currently fairly difficult since it isn't always clear based on context what kind of API level a given string represents, how much canonicalizing and error checking the code receiving the string are expected to do, or how those errors should be treated. The API level struct does not export its raw data, so as to keep its "constructor" private to the android package, and to prevent misuse of the `number` field, which is only an implementation detail for preview API levels. API levels can be parsed with either `android.ApiLevelFromUser`, which returns any errors to the caller, or `android.ApiLevelOrPanic`, which is used in the case where the input is trusted and any errors in parsing should panic. Even within the `android` package, these APIs should be preferred over direct construction. For cases where there are context specific parsing requirements, such as handling the "minimum" alias in the cc module, `nativeApiLevelFromUser` and `nativeApiLevelOrPanic` should be used instead. Test: treehugger Bug: http://b/154667674 Change-Id: Id52921fda32cb437fb1775ac2183299dedc0cf20
Loading
Please register or sign in to comment