Move to renamed NDK symbol AFileDescriptor_getFd
Ignore-AOSP-First: automerger issue from aosp http://b/187941100#comment11 Bug: 185256332 Test: TH Change-Id: I77f7551a97d015fe5cc54c053020504f5fb93ab7
This commit is contained in:
@@ -74,19 +74,19 @@ int GetNativeFileDescriptorWithNdk(JNIEnv* env, jobject javaFd) {
|
|||||||
// Since Android S, there is an NDK API to get a file descriptor present in libnativehelper.so.
|
// Since Android S, there is an NDK API to get a file descriptor present in libnativehelper.so.
|
||||||
// libnativehelper is loaded into all processes by the zygote since the zygote uses it
|
// libnativehelper is loaded into all processes by the zygote since the zygote uses it
|
||||||
// to load the Android Runtime and is also a public library (because of the NDK API).
|
// to load the Android Runtime and is also a public library (because of the NDK API).
|
||||||
typedef int (*ndkGetFD_t)(JNIEnv*, jobject);
|
typedef int (*ndkGetFd_t)(JNIEnv*, jobject);
|
||||||
static const ndkGetFD_t ndkGetFD = []() -> ndkGetFD_t {
|
static const ndkGetFd_t ndkGetFd = []() -> ndkGetFd_t {
|
||||||
void* handle = dlopen("libnativehelper.so", RTLD_NOLOAD | RTLD_NODELETE);
|
void* handle = dlopen("libnativehelper.so", RTLD_NOLOAD | RTLD_NODELETE);
|
||||||
auto ndkGetFD = reinterpret_cast<ndkGetFD_t>(dlsym(handle, "AFileDescriptor_getFD"));
|
auto ndkGetFd = reinterpret_cast<ndkGetFd_t>(dlsym(handle, "AFileDescriptor_getFd"));
|
||||||
if (ndkGetFD == nullptr) {
|
if (ndkGetFd == nullptr) {
|
||||||
__android_log_print(ANDROID_LOG_FATAL, LOG_TAG,
|
__android_log_print(ANDROID_LOG_FATAL, LOG_TAG,
|
||||||
"Failed to dlsym(AFileDescriptor_getFD): %s", dlerror());
|
"Failed to dlsym(AFileDescriptor_getFd): %s", dlerror());
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
}
|
}
|
||||||
return ndkGetFD;
|
return ndkGetFd;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
return javaFd != nullptr ? ndkGetFD(env, javaFd) : -1;
|
return javaFd != nullptr ? ndkGetFd(env, javaFd) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user