diff options
author | Narayan Kamath <narayan@google.com> | 2020-02-18 12:14:51 +0000 |
---|---|---|
committer | Zim <zezeozue@google.com> | 2020-03-10 11:28:35 +0000 |
commit | de3fe17e9bd9d775d2cd0c001a40241fbc8eae67 (patch) | |
tree | 32c37dd8182452395fefcc05cf235afa9fcda882 /jni/com_android_providers_media_FuseDaemon.cpp | |
parent | b688afe8d76fb4fc2d814e57b63e791199e74f02 (diff) | |
download | MediaProvider-de3fe17e9bd9d775d2cd0c001a40241fbc8eae67.tar.gz |
FuseDaemon: Update JNI threading model.
JNI up-calls are now performed on the same thread on which
they're required (usually a libfuse thread) and not on a
separate dedicated thread. We attach each thread the first
time we make a call on it and detach it when the thread is
about to be destroyed.
Test: atest FuseDaemonHostTest
Bug: 149198252
Merged-In: I04795d069e8e5c3ac2d572dfc48a7e2146bc31c5
Change-Id: I04795d069e8e5c3ac2d572dfc48a7e2146bc31c5
(cherry picked from commit 402a85fa39e9f8b12fc9967ceb7ca52c3db35b41)
Diffstat (limited to 'jni/com_android_providers_media_FuseDaemon.cpp')
-rw-r--r-- | jni/com_android_providers_media_FuseDaemon.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/jni/com_android_providers_media_FuseDaemon.cpp b/jni/com_android_providers_media_FuseDaemon.cpp index 87861cae6..9de00b6b8 100644 --- a/jni/com_android_providers_media_FuseDaemon.cpp +++ b/jni/com_android_providers_media_FuseDaemon.cpp @@ -22,6 +22,7 @@ #include <string> #include "FuseDaemon.h" +#include "MediaProviderWrapper.h" #include "android-base/logging.h" namespace mediaprovider { @@ -103,7 +104,7 @@ const JNINativeMethod methods[] = { com_android_providers_media_FuseDaemon_invalidate_fuse_dentry_cache)}}; } // namespace -void register_android_providers_media_FuseDaemon(JNIEnv* env) { +void register_android_providers_media_FuseDaemon(JavaVM* vm, JNIEnv* env) { gFuseDaemonClass = static_cast<jclass>(env->NewGlobalRef(env->FindClass(CLASS_NAME))); if (gFuseDaemonClass == nullptr) { @@ -113,5 +114,7 @@ void register_android_providers_media_FuseDaemon(JNIEnv* env) { if (env->RegisterNatives(gFuseDaemonClass, methods, sizeof(methods) / sizeof(methods[0])) < 0) { LOG(FATAL) << "Unable to register native methods"; } + + fuse::MediaProviderWrapper::OneTimeInit(vm); } } // namespace mediaprovider |