mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-01-11 15:29:30 -05:00
android fixes
This commit is contained in:
parent
1817679460
commit
e112cc4527
13
Cargo.lock
generated
13
Cargo.lock
generated
@ -4736,6 +4736,17 @@ dependencies = [
|
|||||||
"tracing-core",
|
"tracing-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-android"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "12612be8f868a09c0ceae7113ff26afe79d81a24473a393cb9120ece162e86c0"
|
||||||
|
dependencies = [
|
||||||
|
"android_log-sys",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-appender"
|
name = "tracing-appender"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@ -5102,7 +5113,6 @@ dependencies = [
|
|||||||
name = "veilid-core"
|
name = "veilid-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_logger 0.11.0",
|
|
||||||
"async-io",
|
"async-io",
|
||||||
"async-lock",
|
"async-lock",
|
||||||
"async-std",
|
"async-std",
|
||||||
@ -5177,6 +5187,7 @@ dependencies = [
|
|||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tokio-util 0.7.3",
|
"tokio-util 0.7.3",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"tracing-android",
|
||||||
"tracing-error",
|
"tracing-error",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"tracing-wasm",
|
"tracing-wasm",
|
||||||
|
@ -133,7 +133,7 @@ jni = "^0"
|
|||||||
jni-sys = "^0"
|
jni-sys = "^0"
|
||||||
ndk = { version = "^0", features = ["trace"] }
|
ndk = { version = "^0", features = ["trace"] }
|
||||||
ndk-glue = { version = "^0", features = ["logger"] }
|
ndk-glue = { version = "^0", features = ["logger"] }
|
||||||
android_logger = { version = "^0" }
|
tracing-android = { version = "^0" }
|
||||||
backtrace = { version = "^0" }
|
backtrace = { version = "^0" }
|
||||||
|
|
||||||
# Dependenices for all Unix (Linux, Android, MacOS, iOS)
|
# Dependenices for all Unix (Linux, Android, MacOS, iOS)
|
||||||
|
@ -195,7 +195,7 @@ impl VeilidCoreContext {
|
|||||||
) -> Result<VeilidCoreContext, VeilidAPIError> {
|
) -> Result<VeilidCoreContext, VeilidAPIError> {
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_os = "android")] {
|
if #[cfg(target_os = "android")] {
|
||||||
if utils::android::ANDROID_GLOBALS.lock().is_none() {
|
if crate::intf::utils::android::ANDROID_GLOBALS.lock().is_none() {
|
||||||
error!("Android globals are not set up");
|
error!("Android globals are not set up");
|
||||||
return Err(VeilidAPIError::Internal { message: "Android globals are not set up".to_owned() });
|
return Err(VeilidAPIError::Internal { message: "Android globals are not set up".to_owned() });
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,17 @@
|
|||||||
mod get_directories;
|
mod get_directories;
|
||||||
pub use get_directories::*;
|
pub use get_directories::*;
|
||||||
|
|
||||||
|
use crate::veilid_config::VeilidConfigLogLevel;
|
||||||
use crate::xx::*;
|
use crate::xx::*;
|
||||||
use android_logger::{Config, FilterBuilder};
|
use crate::*;
|
||||||
use backtrace::Backtrace;
|
use backtrace::Backtrace;
|
||||||
use jni::errors::Result as JniResult;
|
use jni::errors::Result as JniResult;
|
||||||
use jni::{objects::GlobalRef, objects::JObject, objects::JString, JNIEnv, JavaVM};
|
use jni::{objects::GlobalRef, objects::JObject, objects::JString, JNIEnv, JavaVM};
|
||||||
use lazy_static::*;
|
use lazy_static::*;
|
||||||
use log::*;
|
|
||||||
use std::panic;
|
use std::panic;
|
||||||
|
use tracing::*;
|
||||||
|
use tracing_subscriber::prelude::*;
|
||||||
|
use tracing_subscriber::*;
|
||||||
|
|
||||||
pub struct AndroidGlobals {
|
pub struct AndroidGlobals {
|
||||||
pub vm: JavaVM,
|
pub vm: JavaVM,
|
||||||
@ -41,19 +44,25 @@ pub fn veilid_core_setup_android<'a>(
|
|||||||
env: JNIEnv<'a>,
|
env: JNIEnv<'a>,
|
||||||
ctx: JObject<'a>,
|
ctx: JObject<'a>,
|
||||||
log_tag: &'a str,
|
log_tag: &'a str,
|
||||||
log_level: Level,
|
log_level: VeilidConfigLogLevel,
|
||||||
) {
|
) {
|
||||||
android_logger::init_once(
|
// Set up subscriber and layers
|
||||||
Config::default()
|
let subscriber = Registry::default();
|
||||||
.with_min_level(log_level)
|
let mut layers = Vec::new();
|
||||||
.with_tag(log_tag)
|
let mut filters = BTreeMap::new();
|
||||||
.with_filter(
|
let filter = VeilidLayerFilter::new(log_level, None);
|
||||||
FilterBuilder::new()
|
let layer = tracing_android::layer(log_tag)
|
||||||
.filter(Some(log_tag), log_level.to_level_filter())
|
.expect("failed to set up android logging")
|
||||||
.build(),
|
.with_filter(filter.clone());
|
||||||
),
|
filters.insert("system", filter);
|
||||||
);
|
layers.push(layer.boxed());
|
||||||
|
|
||||||
|
let subscriber = subscriber.with(layers);
|
||||||
|
subscriber
|
||||||
|
.try_init()
|
||||||
|
.expect("failed to init android tracing");
|
||||||
|
|
||||||
|
// Set up panic hook for backtraces
|
||||||
panic::set_hook(Box::new(|panic_info| {
|
panic::set_hook(Box::new(|panic_info| {
|
||||||
let bt = Backtrace::new();
|
let bt = Backtrace::new();
|
||||||
if let Some(location) = panic_info.location() {
|
if let Some(location) = panic_info.location() {
|
||||||
|
@ -3,7 +3,6 @@ use super::*;
|
|||||||
use futures_util::stream::FuturesUnordered;
|
use futures_util::stream::FuturesUnordered;
|
||||||
use futures_util::FutureExt;
|
use futures_util::FutureExt;
|
||||||
use stop_token::future::FutureExt as StopTokenFutureExt;
|
use stop_token::future::FutureExt as StopTokenFutureExt;
|
||||||
use tokio::task::spawn_blocking;
|
|
||||||
|
|
||||||
struct DetectedPublicDialInfo {
|
struct DetectedPublicDialInfo {
|
||||||
dial_info: DialInfo,
|
dial_info: DialInfo,
|
||||||
|
@ -68,7 +68,7 @@ cargo {
|
|||||||
prebuiltToolchains = true
|
prebuiltToolchains = true
|
||||||
profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release"
|
profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release"
|
||||||
features {
|
features {
|
||||||
defaultAnd("android_tests")
|
defaultAnd("android_tests", "rt-tokio")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,12 @@ pub extern "system" fn Java_com_veilid_veilidcore_veilidcore_1android_1tests_Mai
|
|||||||
_class: JClass,
|
_class: JClass,
|
||||||
ctx: JObject,
|
ctx: JObject,
|
||||||
) {
|
) {
|
||||||
crate::intf::utils::android::veilid_core_setup_android(env, ctx, "veilid_core", Level::Trace);
|
crate::intf::utils::android::veilid_core_setup_android(
|
||||||
|
env,
|
||||||
|
ctx,
|
||||||
|
"veilid_core",
|
||||||
|
crate::veilid_config::VeilidConfigLogLevel::Trace,
|
||||||
|
);
|
||||||
run_all_tests();
|
run_all_tests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user