Index: webrtc/modules/utility/source/jvm_android.cc |
diff --git a/webrtc/modules/utility/source/jvm_android.cc b/webrtc/modules/utility/source/jvm_android.cc |
index 2228d3ad255db605dfaf5ce5387fa2c2513826b8..9d08688700748b0fce3f0defbd3e9b7810448e60 100644 |
--- a/webrtc/modules/utility/source/jvm_android.cc |
+++ b/webrtc/modules/utility/source/jvm_android.cc |
@@ -217,10 +217,10 @@ |
} |
// static |
-void JVM::Initialize(JavaVM* jvm) { |
+void JVM::Initialize(JavaVM* jvm, jobject context) { |
ALOGD("JVM::Initialize%s", GetThreadInfo().c_str()); |
RTC_CHECK(!g_jvm); |
- g_jvm = new JVM(jvm); |
+ g_jvm = new JVM(jvm, context); |
} |
// static |
@@ -237,9 +237,11 @@ |
return g_jvm; |
} |
-JVM::JVM(JavaVM* jvm) : jvm_(jvm) { |
+JVM::JVM(JavaVM* jvm, jobject context) |
+ : jvm_(jvm) { |
ALOGD("JVM::JVM%s", GetThreadInfo().c_str()); |
RTC_CHECK(jni()) << "AttachCurrentThread() must be called on this thread."; |
+ context_ = NewGlobalRef(jni(), context); |
LoadClasses(jni()); |
} |
@@ -247,6 +249,7 @@ |
ALOGD("JVM::~JVM%s", GetThreadInfo().c_str()); |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
FreeClassReferences(jni()); |
+ DeleteGlobalRef(jni(), context_); |
} |
std::unique_ptr<JNIEnvironment> JVM::environment() { |