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
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user