mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Namespaces have been updated to reflect the move from //flutter/sky/shell to //flutter/shell. * shell/BUILD.gn file has been split into smaller GN files for each subcomponent of the shell (common, GPU, diagnostic, testing). * GN dependencies have been rewritten to stop exposing common shell dependencies as public. Duplicates have also been removed. * GPU subcomponent has been updated make it more suitable for Vulkan integration. * The GLFW backend has been resurrected.
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "base/android/base_jni_onload.h"
|
|
#include "base/android/base_jni_registrar.h"
|
|
#include "base/android/jni_android.h"
|
|
#include "base/android/jni_registrar.h"
|
|
#include "base/android/library_loader/library_loader_hooks.h"
|
|
#include "base/bind.h"
|
|
#include "base/logging.h"
|
|
#include "flutter/lib/jni/dart_jni.h"
|
|
#include "mojo/android/system/base_run_loop.h"
|
|
#include "mojo/android/system/core_impl.h"
|
|
#include "flutter/shell/platform/android/flutter_main.h"
|
|
#include "flutter/shell/platform/android/platform_view_android.h"
|
|
|
|
namespace {
|
|
|
|
base::android::RegistrationMethod kSkyRegisteredMethods[] = {
|
|
{"CoreImpl", mojo::android::RegisterCoreImpl},
|
|
{"BaseRunLoop", mojo::android::RegisterBaseRunLoop},
|
|
{"FlutterView", shell::PlatformViewAndroid::Register},
|
|
{"FlutterMain", shell::RegisterFlutterMain},
|
|
};
|
|
|
|
bool RegisterJNI(JNIEnv* env) {
|
|
if (!base::android::RegisterJni(env))
|
|
return false;
|
|
|
|
return RegisterNativeMethods(env, kSkyRegisteredMethods,
|
|
arraysize(kSkyRegisteredMethods));
|
|
}
|
|
|
|
bool InitJNI() {
|
|
return blink::DartJni::InitJni();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
// 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(&InitJNI));
|
|
|
|
if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
|
|
!base::android::OnJNIOnLoadInit(init_callbacks)) {
|
|
return -1;
|
|
}
|
|
|
|
return JNI_VERSION_1_4;
|
|
}
|