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