android fixes
This commit is contained in:
parent
f79b13a6d1
commit
ffcf16711b
42
Cargo.lock
generated
42
Cargo.lock
generated
@ -86,24 +86,6 @@ version = "0.2.16"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
|
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "android-logd-logger"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "89d7b9303373a56714732e3371513edd14d12987d04ff4f48527444e804bc3ae"
|
|
||||||
dependencies = [
|
|
||||||
"bytes 1.4.0",
|
|
||||||
"env_logger 0.10.0",
|
|
||||||
"lazy_static",
|
|
||||||
"libc",
|
|
||||||
"log",
|
|
||||||
"parking_lot 0.12.1",
|
|
||||||
"redox_syscall 0.3.5",
|
|
||||||
"thiserror",
|
|
||||||
"time 0.3.28",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "android-tzdata"
|
name = "android-tzdata"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@ -116,13 +98,31 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
|
checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_log-sys"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "android_logger"
|
name = "android_logger"
|
||||||
version = "0.11.3"
|
version = "0.11.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a"
|
checksum = "8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_log-sys",
|
"android_log-sys 0.2.0",
|
||||||
|
"env_logger 0.10.0",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_logger"
|
||||||
|
version = "0.13.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f"
|
||||||
|
dependencies = [
|
||||||
|
"android_log-sys 0.3.1",
|
||||||
"env_logger 0.10.0",
|
"env_logger 0.10.0",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
@ -3047,7 +3047,7 @@ version = "0.7.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f"
|
checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_logger",
|
"android_logger 0.11.3",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"ndk",
|
"ndk",
|
||||||
@ -5821,7 +5821,7 @@ dependencies = [
|
|||||||
name = "veilid-tools"
|
name = "veilid-tools"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android-logd-logger",
|
"android_logger 0.13.3",
|
||||||
"async-lock",
|
"async-lock",
|
||||||
"async-std",
|
"async-std",
|
||||||
"async_executors",
|
"async_executors",
|
||||||
|
@ -123,7 +123,7 @@ if [ "$BREW_USER" == "" ]; then
|
|||||||
BREW_USER=`whoami`
|
BREW_USER=`whoami`
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
sudo -H -u $BREW_USER brew install capnp cmake wabt llvm protobuf openjdk@11 jq
|
sudo -H -u $BREW_USER brew install capnp cmake wabt llvm protobuf openjdk@17 jq
|
||||||
|
|
||||||
# Ensure android sdk packages are installed
|
# Ensure android sdk packages are installed
|
||||||
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager build-tools\;33.0.1 ndk\;25.1.8937393 cmake\;3.22.1 platform-tools platforms\;android-33
|
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager build-tools\;33.0.1 ndk\;25.1.8937393 cmake\;3.22.1 platform-tools platforms\;android-33
|
||||||
|
2
external/keyring-manager
vendored
2
external/keyring-manager
vendored
@ -1 +1 @@
|
|||||||
Subproject commit ee21446f822fa397057e88083ebbcd3c1bae7adf
|
Subproject commit e00be7d4130f3e3f69548121de26b24aeb935df2
|
@ -1,13 +1,14 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
use jni::errors::Result as JniResult;
|
||||||
use jni::objects::JString;
|
use jni::objects::JString;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn get_files_dir() -> String {
|
pub fn get_files_dir() -> String {
|
||||||
let aglock = ANDROID_GLOBALS.lock();
|
let aglock = ANDROID_GLOBALS.lock();
|
||||||
let ag = aglock.as_ref().unwrap();
|
let ag = aglock.as_ref().unwrap();
|
||||||
let env = ag.vm.attach_current_thread().unwrap();
|
let mut env = ag.vm.attach_current_thread().unwrap();
|
||||||
|
|
||||||
with_null_local_frame(*env, 64, || {
|
env.with_local_frame(64, |env| {
|
||||||
// context.getFilesDir().getAbsolutePath()
|
// context.getFilesDir().getAbsolutePath()
|
||||||
let file = env
|
let file = env
|
||||||
.call_method(ag.ctx.as_obj(), "getFilesDir", "()Ljava/io/File;", &[])
|
.call_method(ag.ctx.as_obj(), "getFilesDir", "()Ljava/io/File;", &[])
|
||||||
@ -20,8 +21,9 @@ pub fn get_files_dir() -> String {
|
|||||||
.l()
|
.l()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let jstrval = env.get_string(JString::from(path)).unwrap();
|
let jstr = JString::from(path);
|
||||||
Ok(String::from(jstrval.to_string_lossy()))
|
let jstrval = env.get_string(&jstr).unwrap();
|
||||||
|
JniResult::Ok(String::from(jstrval.to_string_lossy()))
|
||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
@ -30,9 +32,9 @@ pub fn get_files_dir() -> String {
|
|||||||
pub fn get_cache_dir() -> String {
|
pub fn get_cache_dir() -> String {
|
||||||
let aglock = ANDROID_GLOBALS.lock();
|
let aglock = ANDROID_GLOBALS.lock();
|
||||||
let ag = aglock.as_ref().unwrap();
|
let ag = aglock.as_ref().unwrap();
|
||||||
let env = ag.vm.attach_current_thread().unwrap();
|
let mut env = ag.vm.attach_current_thread().unwrap();
|
||||||
|
|
||||||
with_null_local_frame(*env, 64, || {
|
env.with_local_frame(64, |env| {
|
||||||
// context.getCacheDir().getAbsolutePath()
|
// context.getCacheDir().getAbsolutePath()
|
||||||
let file = env
|
let file = env
|
||||||
.call_method(ag.ctx.as_obj(), "getCacheDir", "()Ljava/io/File;", &[])
|
.call_method(ag.ctx.as_obj(), "getCacheDir", "()Ljava/io/File;", &[])
|
||||||
@ -45,8 +47,9 @@ pub fn get_cache_dir() -> String {
|
|||||||
.l()
|
.l()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let jstrval = env.get_string(JString::from(path)).unwrap();
|
let jstr = JString::from(path);
|
||||||
Ok(String::from(jstrval.to_string_lossy()))
|
let jstrval = env.get_string(&jstr).unwrap();
|
||||||
|
JniResult::Ok(String::from(jstrval.to_string_lossy()))
|
||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ mod get_directories;
|
|||||||
pub use get_directories::*;
|
pub use get_directories::*;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use jni::errors::Result as JniResult;
|
|
||||||
use jni::{objects::GlobalRef, objects::JObject, JNIEnv, JavaVM};
|
use jni::{objects::GlobalRef, objects::JObject, JNIEnv, JavaVM};
|
||||||
use lazy_static::*;
|
use lazy_static::*;
|
||||||
|
|
||||||
@ -41,13 +40,3 @@ pub fn get_android_globals() -> (JavaVM, GlobalRef) {
|
|||||||
let ctx = globals.ctx.clone();
|
let ctx = globals.ctx.clone();
|
||||||
(vm, ctx)
|
(vm, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_null_local_frame<'b, T, F>(env: JNIEnv<'b>, s: i32, f: F) -> JniResult<T>
|
|
||||||
where
|
|
||||||
F: FnOnce() -> JniResult<T>,
|
|
||||||
{
|
|
||||||
env.push_local_frame(s)?;
|
|
||||||
let out = f();
|
|
||||||
env.pop_local_frame(JObject::null())?;
|
|
||||||
out
|
|
||||||
}
|
|
||||||
|
@ -85,7 +85,7 @@ ndk = { version = "0.7.0" }
|
|||||||
ndk-glue = { version = "0.7.0", features = ["logger"] }
|
ndk-glue = { version = "0.7.0", features = ["logger"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
paranoid-android = { version = "0.2.1", optional = true }
|
paranoid-android = { version = "0.2.1", optional = true }
|
||||||
android-logd-logger = "0.4.2"
|
android_logger = "0.13.3"
|
||||||
|
|
||||||
# Dependencies for Windows
|
# Dependencies for Windows
|
||||||
# [target.'cfg(target_os = "windows")'.dependencies]
|
# [target.'cfg(target_os = "windows")'.dependencies]
|
||||||
|
@ -44,14 +44,20 @@ pub fn veilid_tools_setup_android_tests() {
|
|||||||
.try_init()
|
.try_init()
|
||||||
.expect("failed to init android tracing");
|
.expect("failed to init android tracing");
|
||||||
} else {
|
} else {
|
||||||
let mut builder = android_logd_logger::builder();
|
use log::LevelFilter;
|
||||||
builder.tag("veilid-tools");
|
use android_logger::{Config,FilterBuilder};
|
||||||
builder.prepend_module(true);
|
|
||||||
|
let mut builder = FilterBuilder::new();
|
||||||
builder.filter_level(LevelFilter::Trace);
|
builder.filter_level(LevelFilter::Trace);
|
||||||
for ig in DEFAULT_LOG_IGNORE_LIST {
|
for ig in DEFAULT_LOG_IGNORE_LIST {
|
||||||
builder.filter_module(ig, LevelFilter::Off);
|
builder.filter_module(ig, LevelFilter::Off);
|
||||||
}
|
}
|
||||||
builder.init();
|
android_logger::init_once(
|
||||||
|
Config::default()
|
||||||
|
.with_max_level(LevelFilter::Trace) // limit log level
|
||||||
|
.with_tag("veilid-tools") // logs will show under mytag tag
|
||||||
|
.with_filter(builder.build())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user