• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //! Implementation of JNI protocol functionality.
18 use crate::unique_jvm;
19 use crate::utils::get_boolean_result;
20 use jni::objects::JObject;
21 use jni::sys::jboolean;
22 use jni::JNIEnv;
23 
24 /// Initialize native library. Captures Java VM:
25 #[no_mangle]
Java_com_android_server_remoteauth_jni_NativeRemoteAuthJavaPlatform_native_init( env: JNIEnv, _: JObject, ) -> jboolean26 pub extern "system" fn Java_com_android_server_remoteauth_jni_NativeRemoteAuthJavaPlatform_native_init(
27     env: JNIEnv,
28     _: JObject,
29 ) -> jboolean {
30     logger::init(
31         logger::Config::default()
32             .with_tag_on_device("remoteauth")
33             .with_max_level(log::LevelFilter::Trace)
34             .with_filter("trace,jni=info"),
35     );
36     get_boolean_result(native_init(env), "native_init")
37 }
38 
native_init(env: JNIEnv) -> anyhow::Result<()>39 fn native_init(env: JNIEnv) -> anyhow::Result<()> {
40     let jvm = env.get_java_vm()?;
41     unique_jvm::set_once(jvm)
42 }
43