问题
I am interested in using the AServiceManager_get/addService() APIs that are made available via the NDK implementation of binder, libbinder_ndk
.
The sources for this can be found here for 10.0.0r30 - API29, and in your AOSP tree at:
$SDK/frameworks/native/libs/binder/ndk/
However, the libbinder_ndk.so
bundled with the latest r21c NDK does not have all of these APIs exported. Many are, but the get/add services endpoints are not available. The libbinder_ndk.so
for API29 can be found at:
$NDK/platforms/android-29/$PLAT/usr/lib/libbinder_ndk.so
As well as the sysroot directories of each respective toolchain, but only for API29
$NDK/toolchains/llvm/prebuilt/$HOST/sysroot/usr/lib/$PLAT/29/libbinder_ndk.so
But the symbols are of course available if you build the AOSP tree for this same release:
$ readelf --wide -s libbinder_ndk.so | grep AService
180: 000000000000e148 256 FUNC GLOBAL DEFAULT 15 AServiceManager_addService@@LIBBINDER_NDK
181: 000000000000e248 244 FUNC GLOBAL DEFAULT 15 AServiceManager_checkService@@LIBBINDER_NDK
224: 000000000000e33c 244 FUNC GLOBAL DEFAULT 15 AServiceManager_getService@@LIBBINDER_NDK
In fact, a search of the documentation returns no results for these APIs, but the source has been available since 2018-08-20 according to the blame records.
Am I missing something?
回答1:
The reason they are not exported is because they are not a part of the app API surface. They exist for vendor and APEX modules. Those domains do not have the same API permanence guarantees that apps do (read: they might disappear in any given release).
来源:https://stackoverflow.com/questions/62219306/latest-android-ndk-r21cs-libbinder-ndk-is-missing-several-exported-apis