From 9433505064c201acb68eb438feba3dc06d622e65 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 3 Apr 2026 02:05:36 +0000 Subject: [PATCH] fix: move ringtone and audio mode setup off the main thread RingtoneManager.getRingtone() and audio mode switching do disk I/O, causing StrictMode DiskWriteViolation when called from the state collector on the main thread. Wrap startRinging() and switchToCallAudioMode() in withContext(Dispatchers.IO). https://claude.ai/code/session_01LR8NmFGdMoDTVcfKjL7HWR --- .../com/vitorpamplona/amethyst/service/call/CallController.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt index 1a9a54ddb..db8d4f106 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt @@ -117,7 +117,7 @@ class CallController( callManager.state.collect { state -> when (state) { is CallState.IncomingCall -> { - audioManager.startRinging() + withContext(Dispatchers.IO) { audioManager.startRinging() } showIncomingCallNotification(state.callerPubKey) } @@ -128,7 +128,7 @@ class CallController( is CallState.Connecting -> { audioManager.stopRinging() audioManager.stopRingbackTone() - audioManager.switchToCallAudioMode() + withContext(Dispatchers.IO) { audioManager.switchToCallAudioMode() } audioManager.acquireProximityWakeLock() NotificationUtils.cancelCallNotification(context) }