Loading libs/binder/JvmUtils.h 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) #include <dlfcn.h> #include <jni.h> extern "C" JavaVM* AndroidRuntimeGetJavaVM(); #endif namespace { #if !defined(__ANDROID__) || defined(__ANDROID_RECOVERY__) static void* getJavaVM() { return nullptr; } #else static JavaVM* getJavaVM() { static auto fn = reinterpret_cast<decltype(&AndroidRuntimeGetJavaVM)>( dlsym(RTLD_DEFAULT, "AndroidRuntimeGetJavaVM")); if (fn == nullptr) return nullptr; return fn(); } #endif } // namespace libs/binder/RpcSession.cpp +1 −13 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ #include <binder/RpcSession.h> #include <dlfcn.h> #include <inttypes.h> #include <netinet/tcp.h> #include <poll.h> Loading @@ -36,6 +35,7 @@ #include "BuildFlags.h" #include "FdTrigger.h" #include "JvmUtils.h" #include "OS.h" #include "RpcSocketAddress.h" #include "RpcState.h" Loading @@ -43,11 +43,6 @@ #include "RpcWireFormat.h" #include "Utils.h" #if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) #include <jni.h> extern "C" JavaVM* AndroidRuntimeGetJavaVM(); #endif namespace android { using namespace android::binder::impl; Loading Loading @@ -414,13 +409,6 @@ private: void operator=(const JavaThreadAttacher&) = delete; bool mAttached = false; static JavaVM* getJavaVM() { static auto fn = reinterpret_cast<decltype(&AndroidRuntimeGetJavaVM)>( dlsym(RTLD_DEFAULT, "AndroidRuntimeGetJavaVM")); if (fn == nullptr) return nullptr; return fn(); } }; #endif } // namespace Loading Loading
libs/binder/JvmUtils.h 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) #include <dlfcn.h> #include <jni.h> extern "C" JavaVM* AndroidRuntimeGetJavaVM(); #endif namespace { #if !defined(__ANDROID__) || defined(__ANDROID_RECOVERY__) static void* getJavaVM() { return nullptr; } #else static JavaVM* getJavaVM() { static auto fn = reinterpret_cast<decltype(&AndroidRuntimeGetJavaVM)>( dlsym(RTLD_DEFAULT, "AndroidRuntimeGetJavaVM")); if (fn == nullptr) return nullptr; return fn(); } #endif } // namespace
libs/binder/RpcSession.cpp +1 −13 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ #include <binder/RpcSession.h> #include <dlfcn.h> #include <inttypes.h> #include <netinet/tcp.h> #include <poll.h> Loading @@ -36,6 +35,7 @@ #include "BuildFlags.h" #include "FdTrigger.h" #include "JvmUtils.h" #include "OS.h" #include "RpcSocketAddress.h" #include "RpcState.h" Loading @@ -43,11 +43,6 @@ #include "RpcWireFormat.h" #include "Utils.h" #if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) #include <jni.h> extern "C" JavaVM* AndroidRuntimeGetJavaVM(); #endif namespace android { using namespace android::binder::impl; Loading Loading @@ -414,13 +409,6 @@ private: void operator=(const JavaThreadAttacher&) = delete; bool mAttached = false; static JavaVM* getJavaVM() { static auto fn = reinterpret_cast<decltype(&AndroidRuntimeGetJavaVM)>( dlsym(RTLD_DEFAULT, "AndroidRuntimeGetJavaVM")); if (fn == nullptr) return nullptr; return fn(); } }; #endif } // namespace Loading