The Vendor Native Development Kit (VNDK) is a set of libraries
exclusively for vendors to implement their HALs. The VNDK ships in
system.img
and is dynamically linked to vendor code at runtime.
Android 8.0 and higher enables framework-only updates in which the system partition can be upgraded to the latest version while vendor partitions are left unchanged. This implies that binaries built at different times must be able to work with each other; VNDK covers API/ABI changes across Android releases.
Framework-only updates include the following challenges:
To address these challenges, Android 8.0 introduces several techniques such as VNDK (described in this section), HIDL, hwbinder, device tree overlay, and sepolicy overlay.
This section includes the following VNDK resources:
In an ideal Android 8.0 and higher world, framework processes do not load vendor shared libraries, all vendor processes load only vendor shared libraries (and a portion of framework shared libraries), and communications between framework processes and vendor processes are governed by HIDL and hardware binder.
Such a world includes the possibility that stable, public APIs from framework shared libraries might not be sufficient for vendor module developers (although APIs can change between Android releases), requiring that some portion of framework shared libraries be accessible to vendor processes. In addition, as performance requirements can lead to compromises, some response-time-critical HALs must be treated differently.
The following sections detail how VNDK handles framework shared libraries for vendors and Same-Process HALs (SP-HALs).
This section describes the criteria for classifying shared libraries that are accessible to vendor processes. There are two approaches to support vendor modules across multiple Android releases:
Different approaches are used depending on the characteristics of the shared libraries. As a result, framework shared libraries are classified into three sub-categories:
libEGL.so
, libGLESv1_CM.so
,
libGLESv2.so
, libGLESv3.so
,
libandroid_net.so
, libc.so
, libdl.so
,
liblog.so
, libm.so
, libnativewindow.so
,
libneuralnetworks.so
, libsync.so
,
libvndksupport.so
, and libvulkan.so
,
Same-Process HAL (SP-HAL) is a set of predetermined HALs implemented as Vendor Shared Libraries and loaded into Framework Processes. SP-HALs are isolated by a linker namespace (controls the libraries and symbols that are visible to the shared libraries). SP-HALs must depend only on LL-NDK and VNDK-SP.
VNDK-SP is a predefined subset of eligible VNDK libraries. VNDK-SP libraries are carefully reviewed to ensure double-loading VNDK-SP libraries into framework processes does not cause problems. Both SP-HALs and VNDK-SPs are defined by Google.
The following libraries are approved SP-HALs:
libGLESv1_CM_${driver}.so
libGLESv2_${driver}.so
libGLESv3_${driver}.so
libEGL_${driver}.so
vulkan.${driver}.so
android.hardware.renderscript@1.0-impl.so
android.hardware.graphics.mapper@2.0-impl.so
The following libraries are VNDK-SP libraries that are accessible by SP-HALs:
android.hardware.graphics.common@1.0.so
android.hardware.graphics.mapper@2.0.so
android.hardware.renderscript@1.0.so
(Renderscript)libRS_internal.so
(Renderscript)libbase.so
libc++.so
libcutils.so
libhardware.so
libhidlbase.so
libhidltransport.so
libhwbinder.so
libion.so
libutils.so
libz.so
The following VNDK-SP dependencies (VNDK-SP-Private) are invisible to SP-HALs:
libRSCpuRef.so
(Renderscript)libRSDriver.so
(Renderscript)libbacktrace.so
libblas.so
(Renderscript)libbcinfo.so
(Renderscript)liblzma.so
libunwind.so
The following are framework-only libraries with RS exceptions (FWK-ONLY-RS):
libft2.so
(Renderscript)libmediandk.so
(Renderscript)For example:
/system/bin
or /system/xbin
./system/lib[64]
./system/bin/app_process
)./vendor/bin
/vendor/lib[64]
./vendor/bin/android.hardware.camera.provider@2.4-service
).
In Android {{ androidPVersionNumber }}, VNDK shared libraries are versioned:
ro.vndk.version
system property is automatically added to
/vendor/default.prop
./system/lib[64]/vndk-${ro.vndk.version}
./system/lib[64]/vndk-sp-${ro.vndk.version}
./system/etc/ld.config.${ro.vndk.version}.txt
.The value of ro.vndk.version
is chosen by the algorithm
below:
BOARD_VNDK_VERSION
is not equal to
current
, use BOARD_VNDK_VERSION
.BOARD_VNDK_VERSION
is equal to
current
:PLATFORM_VERSION_CODENAME
is REL
, use
PLATFORM_SDK_VERSION
(e.g. 28
).PLATFORM_VERSION_CODENAME
(e.g.
P
).If an Android 8.x device disabled VNDK run-time enforcement (i.e. either
built without BOARD_VNDK_VERSION
or built with
BOARD_VNDK_RUNTIME_DISABLE
), it may add
PRODUCT_USE_VNDK_OVERRIDE := false
to BoardConfig.mk
while upgrading to Android {{ androidPVersionNumber }}.
If PRODUCT_USE_VNDK_OVERRIDE
is false
, the
ro.vndk.lite
property will be automatically added to
/vendor/default.prop
and its value will be true
.
Consequently, the dynamic linker will load the linker namespace configuration
from /system/etc/ld.config.vndk_lite.txt
, which isolates only
SP-HAL and VNDK-SP.
To upgrade an Android 7.0 or lower device to Android
{{ androidPVersionNumber }}, add
PRODUCT_TREBLE_LINKER_NAMESPACES_OVERRIDE := false
to
BoardConfig.mk
.
The Android {{ androidPVersionNumber }} Vendor Test Suite (VTS) mandates a
non-empty ro.vndk.version
property. Both newly-launched devices
and upgrading devices must define ro.vndk.version
. Some VNDK test
cases (e.g. VtsVndkFilesTest
and
VtsVndkDependencyTest
) rely on the ro.vndk.version
property to load the matching eligible VNDK libraries data sets.
If the ro.product.first_api_level
property is greater than 27,
the ro.vndk.lite
property must not be defined.
VtsTreblePlatformVersionTest
will fail if
ro.vndk.lite
is defined in a newly-launched Android
{{ androidPVersionNumber }} device.
This section tracks changes to VNDK documentation.
libui.so
with libft2.so
in RS namespace
section. It was an error to include libui.so
.libGLESv3.so
and libandroid_net.so
to LL-NDK
libraries.libion.so
to VNDK-SP libraries.libstdc++.so
from LL-NDK libraries. Use
libc++.so
instead. Some versions of standalone toolchains may add
-lstdc++
to the default linker flags. To disable the defaults, add
-nodefaultlibs -lc -lm -ldl
to LDFLAGS
.libz.so
from LL-NDK to VNDK-SP libraries. In some
configurations, libz.so
may continue being LL-NDK. However,
there should be no observable differences.