1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Android only: hand `ndk-context` the process's JavaVM and application Context.
//!
//! On Android, hickory-resolver (libp2p's DNS transport inside a [`crate::Node`]) reads the system
//! DNS servers from the ConnectivityManager through `ndk-context`, and panics if that was never
//! initialized, which takes down every node dialing a real network (device linking by QR, relays,
//! `/dnsaddr`). Other crates that reach Android services through `ndk-context` (keystores) need
//! the same. Call [`init_context`] once, before any node starts; the
//! [`android_context_init!`](crate::android_context_init) macro exports the JNI function an app's
//! Kotlin calls for that.
pub use jni_sys;
use Once;
use ;
use ;
static INIT: Once = new;
static SET: AtomicBool = new;
/// Gives `ndk-context` the JavaVM behind `env` and a global reference to `context` (kept for the
/// life of the process, as `ndk-context` expects). Only the first call does anything; it returns
/// whether the context is set (false if the JVM refused the VM or the global reference).
///
/// # Safety
/// `env` must be the calling thread's valid `JNIEnv` and `context` a live reference to the
/// application `Context`, as when called from a JNI native method.
pub unsafe