xref: /aosp_15_r20/external/cronet/testing/android/native_test/native_test_jni_onload.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/android/base_jni_onload.h"
6 #include "base/android/jni_android.h"
7 #include "base/android/library_loader/library_loader_hooks.h"
8 #include "base/functional/bind.h"
9 #include "testing/android/native_test/native_test_launcher.h"
10 
11 namespace {
12 
NativeInit()13 bool NativeInit() {
14   if (!base::android::OnJNIOnLoadInit())
15     return false;
16   testing::android::InstallHandlers();
17   return true;
18 }
19 
20 }  // namespace
21 
22 
23 // This is called by the VM when the shared library is first loaded.
JNI_OnLoad(JavaVM * vm,void * reserved)24 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
25   base::android::InitVM(vm);
26   if (!NativeInit()) {
27     return -1;
28   }
29   return JNI_VERSION_1_4;
30 }
31