This commit is contained in:
Christien Rioux 2023-10-06 16:41:25 -04:00
parent ff56634667
commit 86dee2b6ed
6 changed files with 45 additions and 11 deletions

1
Cargo.lock generated
View File

@ -5380,6 +5380,7 @@ dependencies = [
"opentelemetry", "opentelemetry",
"opentelemetry-otlp", "opentelemetry-otlp",
"opentelemetry-semantic-conventions", "opentelemetry-semantic-conventions",
"paranoid-android",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"serde", "serde",
"serde_json", "serde_json",

View File

@ -41,6 +41,8 @@ impl ProtectedStore {
#[instrument(level = "debug", skip(self), err)] #[instrument(level = "debug", skip(self), err)]
pub async fn init(&self) -> EyreResult<()> { pub async fn init(&self) -> EyreResult<()> {
log_pstore!(error "ASDFASDFASDF");
let delete = { let delete = {
let c = self.config.get(); let c = self.config.get();
let mut inner = self.inner.lock(); let mut inner = self.inner.lock();
@ -48,11 +50,19 @@ impl ProtectedStore {
// Attempt to open the secure keyring // Attempt to open the secure keyring
cfg_if! { cfg_if! {
if #[cfg(target_os = "android")] { if #[cfg(target_os = "android")] {
inner.keyring_manager = KeyringManager::new_secure(&c.program_name, crate::intf::android::get_android_globals()).ok(); let maybe_km = KeyringManager::new_secure(&c.program_name, crate::intf::android::get_android_globals());
} else { } else {
inner.keyring_manager = KeyringManager::new_secure(&c.program_name).ok(); let maybe_km = KeyringManager::new_secure(&c.program_name);
} }
} }
inner.keyring_manager = match maybe_km {
Ok(v) => Some(v),
Err(e) => {
log_pstore!(error "Failed to create secure keyring manager: {}", e);
None
}
};
} }
if (c.protected_store.always_use_insecure_storage if (c.protected_store.always_use_insecure_storage
|| c.protected_store.allow_insecure_fallback) || c.protected_store.allow_insecure_fallback)
@ -78,6 +88,7 @@ impl ProtectedStore {
); );
} }
if inner.keyring_manager.is_none() { if inner.keyring_manager.is_none() {
log_pstore!(error "QWERQWER");
bail!("Could not initialize the protected store."); bail!("Could not initialize the protected store.");
} }
c.protected_store.delete c.protected_store.delete

View File

@ -2,8 +2,8 @@ import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:fixnum/fixnum.dart'; import 'package:fixnum/fixnum.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////

View File

@ -63,3 +63,4 @@ hostname = "^0"
# Dependencies for Android builds only # Dependencies for Android builds only
[target.'cfg(target_os = "android")'.dependencies] [target.'cfg(target_os = "android")'.dependencies]
jni = "^0" jni = "^0"
paranoid-android = "0.2.1"

View File

@ -166,14 +166,26 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) {
// Terminal logger // Terminal logger
if platform_config.logging.terminal.enabled { if platform_config.logging.terminal.enabled {
let filter = cfg_if! {
veilid_core::VeilidLayerFilter::new(platform_config.logging.terminal.level, None); if #[cfg(target_os = "android")] {
let layer = tracing_subscriber::fmt::Layer::new() let filter =
.compact() veilid_core::VeilidLayerFilter::new(platform_config.logging.terminal.level, None);
.with_writer(std::io::stdout) let layer = paranoid_android::layer("veilid-flutter")
.with_filter(filter.clone()); .with_ansi(false)
filters.insert("terminal", filter); .with_filter(filter.clone());
layers.push(layer.boxed()); filters.insert("terminal", filter);
layers.push(layer.boxed());
} else {
let filter =
veilid_core::VeilidLayerFilter::new(platform_config.logging.terminal.level, None);
let layer = tracing_subscriber::fmt::Layer::new()
.compact()
.with_writer(std::io::stdout)
.with_filter(filter.clone());
filters.insert("terminal", filter);
layers.push(layer.boxed());
}
}
}; };
// OpenTelemetry logger // OpenTelemetry logger
@ -237,6 +249,7 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) {
.try_init() .try_init()
.map_err(|e| format!("failed to initialize logging: {}", e)) .map_err(|e| format!("failed to initialize logging: {}", e))
.expect("failed to initalize ffi platform"); .expect("failed to initalize ffi platform");
} }
#[no_mangle] #[no_mangle]

View File

@ -177,6 +177,14 @@ macro_rules! log_pstore {
(warn $fmt:literal, $($arg:expr),+) => { (warn $fmt:literal, $($arg:expr),+) => {
warn!(target:"pstore", $fmt, $($arg),+); warn!(target:"pstore", $fmt, $($arg),+);
}; };
(debug $text:expr) => { debug!(
target: "pstore",
"{}",
$text,
)};
(debug $fmt:literal, $($arg:expr),+) => {
debug!(target:"pstore", $fmt, $($arg),+);
};
($text:expr) => {trace!( ($text:expr) => {trace!(
target: "pstore", target: "pstore",
"{}", "{}",