android fixes

This commit is contained in:
John Smith 2022-09-07 10:33:14 -04:00
parent a12d8da6d1
commit c36db533f2
12 changed files with 59 additions and 30 deletions

View File

@ -337,7 +337,7 @@ change_log_level - change the log level for a tracing layer
log.log_level,
log.message,
if let Some(bt) = log.backtrace {
format!("\nBacktrace:\n{}", bt);
format!("\nBacktrace:\n{}", bt)
} else {
"".to_owned()
}

View File

@ -15,8 +15,8 @@ rt-async-std = [ "async-std", "async-std-resolver", "async_executors/async_std",
rt-tokio = [ "tokio", "tokio-util", "tokio-stream", "trust-dns-resolver/tokio-runtime", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", "rtnetlink?/tokio_socket" ]
android_tests = []
ios_tests = [ "simplelog", "backtrace" ]
tracking = [ "backtrace" ]
ios_tests = [ "simplelog" ]
tracking = []
[dependencies]
tracing = { version = "^0", features = ["log", "attributes"] }
@ -44,7 +44,7 @@ json = "^0"
owning_ref = "^0"
flume = { version = "^0", features = ["async"] }
enumset = { version= "^1", features = ["serde"] }
backtrace = { version = "^0", optional = true }
backtrace = { version = "^0" }
owo-colors = "^3"
stop-token = { version = "^0", default-features = false }
ed25519-dalek = { version = "^1", default_features = false, features = ["alloc", "u64_backend"] }
@ -135,7 +135,6 @@ jni-sys = "^0"
ndk = { version = "^0", features = ["trace"] }
ndk-glue = { version = "^0", features = ["logger"] }
tracing-android = { version = "^0" }
backtrace = { version = "^0" }
# Dependenices for all Unix (Linux, Android, MacOS, iOS)
[target.'cfg(unix)'.dependencies]

View File

@ -97,12 +97,17 @@ impl<S: Subscriber + for<'a> registry::LookupSpan<'a>> Layer<S> for ApiTracingLa
let message = format!("{} {}", origin, recorder);
let backtrace = if log_level <= VeilidLogLevel::Error {
Some(std::backtrace::Backtrace)
let bt = backtrace::Backtrace::new();
Some(format!("{:?}", bt))
} else {
None
};
(inner.update_callback)(VeilidUpdate::Log(VeilidStateLog { log_level, message }))
(inner.update_callback)(VeilidUpdate::Log(VeilidStateLog {
log_level,
message,
backtrace,
}))
}
}
}

View File

@ -608,10 +608,12 @@ impl Network {
self.unlocked_inner
.interfaces
.with_interfaces(|interfaces| {
trace!("interfaces: {:#?}", interfaces);
for (_name, intf) in interfaces {
// Skip networks that we should never encounter
if intf.is_loopback() || !intf.is_running() {
return;
continue;
}
// Add network to local networks table
for addr in &intf.addrs {

View File

@ -303,7 +303,11 @@ impl RoutingTable {
class: DialInfoClass,
) -> EyreResult<()> {
if !self.ensure_dial_info_is_valid(domain, &dial_info) {
return Err(eyre!("dial info is not valid in this routing domain"));
return Err(eyre!(
"dial info '{}' is not valid in routing domain '{:?}'",
dial_info,
domain
));
}
let mut inner = self.inner.write();
@ -453,6 +457,8 @@ impl RoutingTable {
}
pub fn configure_local_network_routing_domain(&self, local_networks: Vec<(IpAddr, IpAddr)>) {
log_net!(debug "configure_local_network_routing_domain: {:#?}", local_networks);
let mut inner = self.inner.write();
let changed = inner
.local_network_routing_domain

View File

@ -41,6 +41,13 @@ android {
main.java.srcDirs += 'src/main/kotlin'
}
// xxx why does backtrace not work in android?
// tried this but it doesn't help
// packagingOptions {
// jniLibs.useLegacyPackaging = true
// }
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.veilid.veilid_example"

View File

@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

View File

@ -161,21 +161,30 @@ class _MyAppState extends State<MyApp> with UiLoggy {
}
Future<void> processUpdateLog(VeilidUpdateLog update) async {
StackTrace? stackTrace;
Object? error;
final backtrace = update.backtrace;
if (backtrace != null) {
stackTrace =
StackTrace.fromString("$backtrace\n${StackTrace.current.toString()}");
error = 'embedded stack trace for ${update.logLevel} ${update.message}';
}
switch (update.logLevel) {
case VeilidLogLevel.error:
loggy.error(update.message);
loggy.error(update.message, error, stackTrace);
break;
case VeilidLogLevel.warn:
loggy.warning(update.message);
loggy.warning(update.message, error, stackTrace);
break;
case VeilidLogLevel.info:
loggy.info(update.message);
loggy.info(update.message, error, stackTrace);
break;
case VeilidLogLevel.debug:
loggy.debug(update.message);
loggy.debug(update.message, error, stackTrace);
break;
case VeilidLogLevel.trace:
loggy.trace(update.message);
loggy.trace(update.message, error, stackTrace);
break;
}
}

View File

@ -1018,31 +1018,31 @@ class LatencyStats {
class TransferStats {
BigInt total;
BigInt fastest;
BigInt maximum;
BigInt average;
BigInt slowest;
BigInt minimum;
TransferStats({
required this.total,
required this.fastest,
required this.maximum,
required this.average,
required this.slowest,
required this.minimum,
});
Map<String, dynamic> get json {
return {
'total': total.toString(),
'fastest': fastest.toString(),
'maximum': maximum.toString(),
'average': average.toString(),
'slowest': slowest.toString(),
'minimum': minimum.toString(),
};
}
TransferStats.fromJson(Map<String, dynamic> json)
: total = BigInt.parse(json['fastest']),
fastest = BigInt.parse(json['fastest']),
: total = BigInt.parse(json['total']),
maximum = BigInt.parse(json['maximum']),
average = BigInt.parse(json['average']),
slowest = BigInt.parse(json['slowest']);
minimum = BigInt.parse(json['minimum']);
}
////////////
@ -1058,8 +1058,8 @@ class TransferStatsDownUp {
Map<String, dynamic> get json {
return {
'down': down.toString(),
'up': up.toString(),
'down': down.json,
'up': up.json,
};
}
@ -1341,7 +1341,8 @@ class VeilidStateNetwork {
: started = json['started'],
bpsDown = BigInt.parse(json['bps_down']),
bpsUp = BigInt.parse(json['bps_up']),
peers = json['peers'].map((j) => PeerTableData.fromJson(j)).toList();
peers = List<PeerTableData>.from(
json['peers'].map((j) => PeerTableData.fromJson(j)));
Map<String, dynamic> get json {
return {