fix(android): expose voice diagnostics safely

This commit is contained in:
Edison Jwa
2026-05-20 14:52:33 +09:00
parent d6763787aa
commit 26b06ce786
3 changed files with 16 additions and 20 deletions
+4 -8
View File
@@ -100,14 +100,9 @@ pub(crate) fn publish_permission_state(permission: String, state: PermissionStat
// 2. Fan out to Dart subscribers. Best-effort: a send error
// means no current subscriber (Dart side not yet attached
// or already torn down) which is fine.
let _ = permission_events().send(BridgeEvent::PermissionState {
permission,
state,
});
let _ = permission_events().send(BridgeEvent::PermissionState { permission, state });
}
/// Default tracing filter. Suppresses the chatty
/// `tsproto::resend` and `tsproto::packet_codec` paths that
/// flood the diagnostic export during transient packet loss;
@@ -768,8 +763,9 @@ pub fn export_diagnostics() -> String {
// diagnostics snapshot from the process-global slot published
// by AndroidVoiceUnit::open(). Returns None on non-Android and
// before any voice session has opened.
let android_audio_yaml = chanora_audio::mobile_voice_backend::current_android_audio_diagnostics()
.map(|d| d.to_yaml_fragment());
let android_audio_yaml =
chanora_audio::mobile_voice_backend::current_android_audio_diagnostics()
.map(|d| d.to_yaml_fragment());
match chanora_core::DiagnosticExport::from_sink(log_sink(), metadata) {
Ok(exp) => exp.with_android_audio(android_audio_yaml).to_text(),
Err(e) => format!("(diagnostic export failed: {e})"),
+6 -10
View File
@@ -907,12 +907,9 @@ mod tests {
let redactor = Redactor::with_secrets(secrets);
let sink = InMemoryLogSink::new(16, redactor);
let yaml = "achieved:\n performance_mode: LowLatency\n sample_rate_hz: 48000\n";
let exported = DiagnosticExport::from_sink(
&sink,
vec![("build".into(), "test".into())],
)
.unwrap()
.with_android_audio(Some(yaml.to_string()));
let exported = DiagnosticExport::from_sink(&sink, vec![("build".into(), "test".into())])
.unwrap()
.with_android_audio(Some(yaml.to_string()));
let text = exported.to_text();
let metadata_pos = text.find("[metadata]").expect("metadata section");
@@ -958,10 +955,9 @@ mod tests {
);
// Explicit None — idempotent with default.
let exported_explicit =
DiagnosticExport::from_sink(&sink, vec![("k".into(), "v".into())])
.unwrap()
.with_android_audio(None);
let exported_explicit = DiagnosticExport::from_sink(&sink, vec![("k".into(), "v".into())])
.unwrap()
.with_android_audio(None);
let text_explicit = exported_explicit.to_text();
assert!(
!text_explicit.contains("[audio.android]"),
+6 -2
View File
@@ -932,8 +932,12 @@ mod tests {
#[test]
fn query_client_type_maps_to_server_query_flag() {
assert!(!is_server_query_client_type(&ClientType::Normal));
assert!(is_server_query_client_type(&ClientType::Query { admin: false }));
assert!(is_server_query_client_type(&ClientType::Query { admin: true }));
assert!(is_server_query_client_type(&ClientType::Query {
admin: false
}));
assert!(is_server_query_client_type(&ClientType::Query {
admin: true
}));
}
#[test]