fix(android): call-debug instrumentation for audio startup path
Add emit_call_debug events at every step of the Android connect/audio path so failures are visible in the Settings debug log without needing adb logcat: - connect:handshake_start/done/failed (with timing) - connect:android_audio_preflight (wzp_native loaded + RECORD_AUDIO permission check via new has_record_audio_permission() JNI helper) - connect:audio_stop_start/done - connect:audio_mode_start/done/failed - connect:audio_start_start/failed/panic/done (with oboe error code) - connect:reuse_endpoint (endpoint reuse diagnostic) Also adds has_record_audio_permission() to android_audio.rs — used in the preflight event to confirm the OS has granted mic access before wzp_oboe_start is called. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,30 @@ fn audio_manager<'local>(
|
||||
Ok(am)
|
||||
}
|
||||
|
||||
fn has_permission(permission: &str) -> Result<bool, String> {
|
||||
let (vm, activity) = jvm_and_activity()?;
|
||||
let mut env = vm
|
||||
.attach_current_thread()
|
||||
.map_err(|e| format!("attach_current_thread: {e}"))?;
|
||||
let permission = env
|
||||
.new_string(permission)
|
||||
.map_err(|e| format!("new_string(permission): {e}"))?;
|
||||
let result = env
|
||||
.call_method(
|
||||
&activity,
|
||||
"checkSelfPermission",
|
||||
"(Ljava/lang/String;)I",
|
||||
&[JValue::Object(&permission)],
|
||||
)
|
||||
.and_then(|v| v.i())
|
||||
.map_err(|e| format!("checkSelfPermission: {e}"))?;
|
||||
Ok(result == 0)
|
||||
}
|
||||
|
||||
pub fn has_record_audio_permission() -> Result<bool, String> {
|
||||
has_permission("android.permission.RECORD_AUDIO")
|
||||
}
|
||||
|
||||
/// Set `AudioManager.MODE_IN_COMMUNICATION`. Call when a VoIP call starts.
|
||||
/// This tells the audio policy to route through the communication device
|
||||
/// path (earpiece/BT SCO) instead of the media path (speaker/BT A2DP).
|
||||
|
||||
Reference in New Issue
Block a user