Commit ce2ed51a authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Switch ContentShell to use implicit JNI registration

Explicit registration is needed only when using the custom linker.
Content shell doesn't use the custom linker, so has no need to jump
through the extra hoops involved with explicit registration.

Change motivated by JNI refactorings, which are made simpler by having
fewer targets use manual JNI registration.

Bug: 898261
Change-Id: Ia38529c1df92264781ba64235a7aea749ef0356a
Reviewed-on: https://chromium-review.googlesource.com/c/1317338Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605344}
parent 12c65088
...@@ -19,18 +19,10 @@ generate_jni("content_shell_jni_headers") { ...@@ -19,18 +19,10 @@ generate_jni("content_shell_jni_headers") {
] ]
} }
generate_jni_registration("content_shell_jni_registration") {
testonly = true
target = ":content_shell_apk"
output = "$root_gen_dir/content/shell/android/${target_name}.h"
exception_files = jni_exception_files
}
shared_library("libcontent_shell_content_view") { shared_library("libcontent_shell_content_view") {
testonly = true testonly = true
deps = [ deps = [
":content_shell_jni_headers", ":content_shell_jni_headers",
":content_shell_jni_registration",
"//components/crash/content/browser", "//components/crash/content/browser",
"//content/shell:content_shell_lib", "//content/shell:content_shell_lib",
"//content/shell:pak", "//content/shell:pak",
...@@ -49,12 +41,13 @@ shared_library("libcontent_shell_content_view") { ...@@ -49,12 +41,13 @@ shared_library("libcontent_shell_content_view") {
sources = [ sources = [
"shell_library_loader.cc", "shell_library_loader.cc",
] ]
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
configs += [ "//build/config/android:hide_all_but_jni" ]
} }
shared_library("libcontent_native_test") { shared_library("libcontent_native_test") {
testonly = true testonly = true
deps = [ deps = [
":content_test_jni_registration",
"//base", "//base",
"//content/public/test/android:content_native_test_support", "//content/public/test/android:content_native_test_support",
"//content/shell:content_shell_lib", "//content/shell:content_shell_lib",
...@@ -63,6 +56,8 @@ shared_library("libcontent_native_test") { ...@@ -63,6 +56,8 @@ shared_library("libcontent_native_test") {
sources = [ sources = [
"shell_test_library_loader.cc", "shell_test_library_loader.cc",
] ]
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
configs += [ "//build/config/android:hide_all_but_jni" ]
} }
android_resources("content_shell_java_resources") { android_resources("content_shell_java_resources") {
...@@ -216,13 +211,6 @@ android_library("content_shell_test_java") { ...@@ -216,13 +211,6 @@ android_library("content_shell_test_java") {
] ]
} }
generate_jni_registration("content_test_jni_registration") {
testonly = true
target = ":content_shell_test_apk__apk"
output = "$root_gen_dir/content/shell/android/${target_name}.h"
exception_files = jni_exception_files
}
instrumentation_test_apk("content_shell_test_apk") { instrumentation_test_apk("content_shell_test_apk") {
deps = [ deps = [
"//base:base_java_test_support", "//base:base_java_test_support",
......
...@@ -3,27 +3,15 @@ ...@@ -3,27 +3,15 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_utils.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/bind.h"
#include "content/public/app/content_jni_onload.h" #include "content/public/app/content_jni_onload.h"
#include "content/public/app/content_main.h" #include "content/public/app/content_main.h"
#include "content/public/browser/android/compositor.h" #include "content/public/browser/android/compositor.h"
#include "content/shell/android/content_shell_jni_registration.h"
#include "content/shell/app/shell_main_delegate.h" #include "content/shell/app/shell_main_delegate.h"
// This is called by the VM when the shared library is first loaded. // This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
base::android::InitVM(vm); base::android::InitVM(vm);
JNIEnv* env = base::android::AttachCurrentThread();
if (!RegisterMainDexNatives(env))
return -1;
// Do not register JNI methods in secondary dex for non-browser process.
bool is_browser_process =
!base::android::IsSelectiveJniRegistrationEnabled(env);
if (is_browser_process && !RegisterNonMainDexNatives(env))
return -1;
if (!content::android::OnJNIOnLoadInit()) if (!content::android::OnJNIOnLoadInit())
return -1; return -1;
......
...@@ -3,26 +3,14 @@ ...@@ -3,26 +3,14 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_utils.h"
#include "content/public/app/content_jni_onload.h" #include "content/public/app/content_jni_onload.h"
#include "content/public/app/content_main.h" #include "content/public/app/content_main.h"
#include "content/public/browser/android/compositor.h" #include "content/public/browser/android/compositor.h"
#include "content/shell/android/content_test_jni_registration.h"
#include "content/shell/app/shell_main_delegate.h" #include "content/shell/app/shell_main_delegate.h"
// This is called by the VM when the shared library is first loaded. // This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
base::android::InitVM(vm); base::android::InitVM(vm);
JNIEnv* env = base::android::AttachCurrentThread();
if (!base::android::IsSelectiveJniRegistrationEnabled(env)) {
if (!RegisterNonMainDexNatives(env)) {
return -1;
}
}
if (!RegisterMainDexNatives(env)) {
return -1;
}
if (!content::android::OnJNIOnLoadInit()) if (!content::android::OnJNIOnLoadInit())
return -1; return -1;
content::Compositor::Initialize(); content::Compositor::Initialize();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment