| Index: chromecast/app/android/cast_jni_loader.cc
|
| diff --git a/chromecast/app/android/cast_jni_loader.cc b/chromecast/app/android/cast_jni_loader.cc
|
| index 03211a89a09125bf19ab9b31423d0e9dacdb2c5d..e4e9bfb874dabeab64c6b7ac9a6e2a55205cc998 100644
|
| --- a/chromecast/app/android/cast_jni_loader.cc
|
| +++ b/chromecast/app/android/cast_jni_loader.cc
|
| @@ -3,6 +3,7 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/android/jni_android.h"
|
| +#include "base/android/library_loader/library_loader_hooks.h"
|
| #include "base/bind.h"
|
| #include "chromecast/android/cast_jni_registrar.h"
|
| #include "chromecast/android/platform_jni_loader.h"
|
| @@ -13,7 +14,8 @@
|
|
|
| namespace {
|
|
|
| -bool RegisterJNI(JNIEnv* env) {
|
| +bool RegisterJNI() {
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| // To be called only from the UI thread. If loading the library is done on
|
| // a separate thread, this should be moved elsewhere.
|
| if (!chromecast::android::RegisterJni(env))
|
| @@ -24,7 +26,9 @@ bool RegisterJNI(JNIEnv* env) {
|
| return true;
|
| }
|
|
|
| -bool Init() {
|
| +bool NativeInit() {
|
| + if (!content::android::OnJNIOnLoadInit())
|
| + return false;
|
| content::Compositor::Initialize();
|
| content::SetContentMainDelegate(new chromecast::shell::CastMainDelegate);
|
| return true;
|
| @@ -34,12 +38,8 @@ bool Init() {
|
|
|
| // This is called by the VM when the shared library is first loaded.
|
| JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
| - std::vector<base::android::RegisterCallback> register_callbacks;
|
| - register_callbacks.push_back(base::Bind(&RegisterJNI));
|
| - std::vector<base::android::InitCallback> init_callbacks;
|
| - init_callbacks.push_back(base::Bind(&Init));
|
| - if (!content::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
|
| - !content::android::OnJNIOnLoadInit(init_callbacks)) {
|
| + if (!content::android::OnJNIOnLoadRegisterJNI(vm) || !RegisterJNI() ||
|
| + !NativeInit()) {
|
| return -1;
|
| }
|
| return JNI_VERSION_1_4;
|
|
|