blob: bf5191c473dc5472ad7e83317579dccd6afdd86b [file] [log] [blame] [view]
Anton Hanssona6caee82020-07-15 12:34:13 +01001# 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
Anton Hanssonb1a217c2020-11-30 11:43:05 +00006## General information
7
8### Structure
Anton Hanssona6caee82020-07-15 12:34:13 +01009
10The module is packaged in an apex, `com.android.sdkext`, and has two components:
11- `bin/derive_sdk`: Native binary that runs early in the device boot process and
12 reads metadata of other modules, to set system properties relating to the
13 extension SDK (for instance `build.version.extensions.r`).
14- `javalib/framework-sdkextension.jar`: This is a jar on the bootclasspath that
15 exposes APIs to applications to query the extension SDK level.
16
Anton Hanssonb1a217c2020-11-30 11:43:05 +000017### Deriving extension SDK level
Anton Hanssona6caee82020-07-15 12:34:13 +010018`derive_sdk` is a program that reads metadata stored in other apex modules, in
19the form of binary protobuf files in subpath `etc/sdkinfo.binarypb` inside each
20apex. The structure of this protobuf can be seen [here][sdkinfo-proto]. The
21exact steps for converting a set of metadata files to actual extension versions
22is likely to change over time, and should not be depended upon.
23
Anton Hanssonb1a217c2020-11-30 11:43:05 +000024### Reading extension SDK level
Anton Hanssona6caee82020-07-15 12:34:13 +010025The module exposes a java class [`SdkExtensions`][sdkextensions-java] in the
26package `android.os.ext`. The method `getExtensionVersion(int)` can be used to
27read the version of a particular sdk extension, e.g.
28`getExtensionVersion(Build.VERSION_CODES.R)`.
29
30[sdkinfo-proto]: sdk.proto
31[sdkextensions-java]: framework/java/android/os/ext/SdkExtensions.java
Anton Hanssonb1a217c2020-11-30 11:43:05 +000032
33## Developer information
34
35### Adding a new extension version
36For every new Android SDK level a new extension version should be defined. These
37are the steps necessary to do that:
Anton Hanssoncda99fa2021-01-15 08:15:57 +000038- Add the new modules in this extension version to the SdkModule enum in
39 sdk.proto.
40- Update `derive_sdk.cpp` by:
41 * mapping the modules' package names to the new enum values
42 * creating a new set with the new enum values
43 * set a new sysprop to the value of `GetSdkLevel` with the new enum set
44 * add a unit test to `derive_sdk_test.cpp` verifying the new extensions works
Anton Hanssonb1a217c2020-11-30 11:43:05 +000045- Make the `SdkExtensions.getExtensionVersion` API support the new extensions.
46- Extend the CTS test to verify the above two behaviors.
47- Update `RollbackManagerServiceImpl#getExtensionVersions` to account for the
48 new extension version.