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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Android system DNS reader.
//!
//! Forwards to [`hickory_resolver::system_conf::read_system_conf`], which
//! reads `LinkProperties.getDnsServers()` through [`ndk_context`]. iroh on
//! Android therefore requires [`ndk_context`] to be initialized before any
//! [`DnsResolver`] is constructed, either by ndk-glue or android-activity
//! (both do this before `main`) or by an explicit
//! [`install_android_jni_context`] call.
//!
//! Without an initialized [`ndk_context`], the JNI lookup panics. Debug
//! builds wrap the call in `std::panic::catch_unwind` so unit tests on
//! Android (where no JVM is in scope) fall back to the resolver's
//! default servers instead of aborting the test binary. Release builds
//! let the panic propagate; uninitialized [`ndk_context`] in production
//! is a programming error and should surface loudly.
//!
//! [`DnsResolver`]: crate::dns::DnsResolver
//! [`ndk_context`]: https://docs.rs/ndk-context
use c_void;
use ;
/// Reads the active network's DNS configuration via JNI.
pub
/// Publishes a `JavaVM` and `Application` `Context` to [`ndk_context`] so
/// iroh's system DNS reader can use JNI.
///
/// The default [`DnsResolver`] reads DNS configuration through JNI and panics
/// if [`ndk_context`] has not been initialized. Apps that already initialize
/// the context (directly, or via ndk-glue or android-activity) do not need
/// this. Apps that don't use either glue crate must call this once at
/// process startup, before any `DnsResolver` or `Endpoint` is constructed.
///
/// Pass the `JavaVM` from `JNI_OnLoad` (or `JNIEnv::GetJavaVM`) and a JNI
/// global reference to the singleton `Application` from
/// `ActivityThread.currentApplication()`. Both pointers must remain valid
/// until the process exits.
///
/// # Safety
///
/// See [`ndk_context::initialize_android_context`].
///
/// [`DnsResolver`]: crate::dns::DnsResolver
/// [`ndk_context`]: https://docs.rs/ndk-context
pub unsafe