README.md
1# SdkExtensions module
2
3SdkExtensions is a module that decides the extension SDK level of the device,
4and provides APIs for applications to query the extension SDK level.
5
6## Structure
7
8The module is packaged in an apex, `com.android.sdkext`, and has two components:
9- `bin/derive_sdk`: Native binary that runs early in the device boot process and
10 reads metadata of other modules, to set system properties relating to the
11 extension SDK (for instance `build.version.extensions.r`).
12- `javalib/framework-sdkextension.jar`: This is a jar on the bootclasspath that
13 exposes APIs to applications to query the extension SDK level.
14
15## Deriving extension SDK level
16`derive_sdk` is a program that reads metadata stored in other apex modules, in
17the form of binary protobuf files in subpath `etc/sdkinfo.binarypb` inside each
18apex. The structure of this protobuf can be seen [here][sdkinfo-proto]. The
19exact steps for converting a set of metadata files to actual extension versions
20is likely to change over time, and should not be depended upon.
21
22## Reading extension SDK level
23The module exposes a java class [`SdkExtensions`][sdkextensions-java] in the
24package `android.os.ext`. The method `getExtensionVersion(int)` can be used to
25read the version of a particular sdk extension, e.g.
26`getExtensionVersion(Build.VERSION_CODES.R)`.
27
28[sdkinfo-proto]: sdk.proto
29[sdkextensions-java]: framework/java/android/os/ext/SdkExtensions.java
30