Android device manufacturers change the source code of AOSP libraries for various reasons. Some vendors reimplement functions in AOSP libraries to boost the performance while other vendors add new hooks, new APIs, or new functionalities to AOSP libraries. This section provides guidelines for extending AOSP libraries in a way that does not break CTS/VTS.

Drop-in replacement

All modified shared libraries must be binary-compatible, drop-in replacements of their AOSP counterpart. All existing AOSP users must be able to use the modified shared library without recompilations. This requirement implies the following:

Extended module classifications

Classify modules by the functionalities they define and use.

Note: Functionalities is used here instead of API/ABI because it is possible to add functionality without changing any API/ABI.

Depending on the functionalities defined in a module, modules can be classified into DA-Module and DX-Module:

Depending on the functionalities used by a module, modules can be classified into UA-Module and UX-Module.

Definitions and usages are independent from each other:

Used Functionalities
Only AOSP (UA) Extended (UX)
Defined Functionalities Only AOSP (DA) DAUA DAUX
Extended (DX) DXUA DXUX

VNDK extension mechanism

Vendor modules that rely on extended functionalities won't work because the AOSP library with the same name does not have the extended functionality. If vendor modules directly or indirectly depend on extended functionalities, vendors should copy DAUX, DXUA, and DXUX shared libraries to the vendor partition (vendor processes always look for shared libraries in the vendor partition first). However, LL-NDK libraries must not be copied, so vendor modules must not rely on the extended functionalities defined by the modified LL-NDK libraries.

DAUA shared libraries can remain on the system partition if the corresponding AOSP library can provide the same functionality and vendor modules continue to work when the system partition is overwritten by an Generic System Image (GSI).

Drop-in replacement is important because the unmodified VNDK libraries in the GSI will link with the modified shared libraries on name collision. If the AOSP libraries are modified in an API/ABI incompatible manner, the AOSP libraries in the GSI might fail to link or result in undefined behaviors.