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-otlp",
"opentelemetry-semantic-conventions",
"paranoid-android",
"parking_lot 0.12.1",
"serde",
"serde_json",

View File

@ -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

View File

@ -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';
//////////////////////////////////////////////////////////

View File

@ -63,3 +63,4 @@ hostname = "^0"
# Dependencies for Android builds only
[target.'cfg(target_os = "android")'.dependencies]
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
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]

View File

@ -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",
"{}",