From 86dee2b6ed98f8f067082d8567d2bd0a4d59742d Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Fri, 6 Oct 2023 16:41:25 -0400 Subject: [PATCH] xfer --- Cargo.lock | 1 + .../src/intf/native/protected_store.rs | 15 ++++++++-- veilid-flutter/lib/veilid.dart | 2 +- veilid-flutter/rust/Cargo.toml | 1 + veilid-flutter/rust/src/dart_ffi.rs | 29 ++++++++++++++----- veilid-tools/src/log_thru.rs | 8 +++++ 6 files changed, 45 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fcaf2e1..d2fbe3f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5380,6 +5380,7 @@ dependencies = [ "opentelemetry", "opentelemetry-otlp", "opentelemetry-semantic-conventions", + "paranoid-android", "parking_lot 0.12.1", "serde", "serde_json", diff --git a/veilid-core/src/intf/native/protected_store.rs b/veilid-core/src/intf/native/protected_store.rs index 7faa0f49..accae460 100644 --- a/veilid-core/src/intf/native/protected_store.rs +++ b/veilid-core/src/intf/native/protected_store.rs @@ -41,6 +41,8 @@ impl ProtectedStore { #[instrument(level = "debug", skip(self), err)] pub async fn init(&self) -> EyreResult<()> { + log_pstore!(error "ASDFASDFASDF"); + let delete = { let c = self.config.get(); let mut inner = self.inner.lock(); @@ -48,11 +50,19 @@ impl ProtectedStore { // Attempt to open the secure keyring cfg_if! { 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 { - 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 || c.protected_store.allow_insecure_fallback) @@ -78,6 +88,7 @@ impl ProtectedStore { ); } if inner.keyring_manager.is_none() { + log_pstore!(error "QWERQWER"); bail!("Could not initialize the protected store."); } c.protected_store.delete diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index 84709a11..e17ec7e9 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:equatable/equatable.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:fixnum/fixnum.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; ////////////////////////////////////////////////////////// diff --git a/veilid-flutter/rust/Cargo.toml b/veilid-flutter/rust/Cargo.toml index 11fb0f05..4b45d99e 100644 --- a/veilid-flutter/rust/Cargo.toml +++ b/veilid-flutter/rust/Cargo.toml @@ -63,3 +63,4 @@ hostname = "^0" # Dependencies for Android builds only [target.'cfg(target_os = "android")'.dependencies] jni = "^0" +paranoid-android = "0.2.1" diff --git a/veilid-flutter/rust/src/dart_ffi.rs b/veilid-flutter/rust/src/dart_ffi.rs index 812f8ab9..00388f67 100644 --- a/veilid-flutter/rust/src/dart_ffi.rs +++ b/veilid-flutter/rust/src/dart_ffi.rs @@ -166,14 +166,26 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) { // Terminal logger if platform_config.logging.terminal.enabled { - 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()); + cfg_if! { + if #[cfg(target_os = "android")] { + let filter = + veilid_core::VeilidLayerFilter::new(platform_config.logging.terminal.level, None); + let layer = paranoid_android::layer("veilid-flutter") + .with_ansi(false) + .with_filter(filter.clone()); + 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 @@ -237,6 +249,7 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) { .try_init() .map_err(|e| format!("failed to initialize logging: {}", e)) .expect("failed to initalize ffi platform"); + } #[no_mangle] diff --git a/veilid-tools/src/log_thru.rs b/veilid-tools/src/log_thru.rs index 89ef8233..9988e7d5 100644 --- a/veilid-tools/src/log_thru.rs +++ b/veilid-tools/src/log_thru.rs @@ -177,6 +177,14 @@ macro_rules! log_pstore { (warn $fmt:literal, $($arg:expr),+) => { 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!( target: "pstore", "{}",