MCPcopy Create free account
hub / github.com/Tencent/tgfx / Current

Method Current

src/platform/android/JNIEnvironment.cpp:58–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58JNIEnv* JNIEnvironment::Current() {
59 JavaVM* javaVM = globalJavaVM;
60 if (javaVM == nullptr) {
61 LOGE(
62 "JNIEnvironment::Current(): The global JavaVM has not been set yet! "
63 "Please use JNIEnvironment::SetJavaVM() to initialize the global JavaVM.");
64 return nullptr;
65 }
66 JNIEnv* env = nullptr;
67 auto result = javaVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_4);
68 if (result == JNI_EDETACHED || env == nullptr) {
69 JavaVMAttachArgs args = {JNI_VERSION_1_4, "tgfx_JNIEnvironment", nullptr};
70 if (javaVM->AttachCurrentThread(&env, &args) == JNI_OK) {
71 pthread_setspecific(envKey, (void*)env);
72 }
73 }
74 return env;
75}
76
77JNIEnvironment::JNIEnvironment() {
78 env = JNIEnvironment::Current();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected