Fix StrictMode violations in AudioRecordingController
#6036
+741
−41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


🎯 Goal
Fixes several
StrictModeviolations from theAudioRecordingControllerrelated to accessing the disk on main thread.🛠 Implementation details
AudioRecordingControllerstartRecording,stopRecordingandcompleteRecordingsuspendstartRecording: wrapmediaRecorder.startAudioRecordingwithwithContext(DispatcherProvider.IO)to ensure it is run on IOstopRecording: wrapmediaRecorder.stopRecording()withwithContext(DispatcherProvider.IO)to ensure it is run on IOcompleteRecording: wrapmediaRecorder.stopRecording()withwithContext(DispatcherProvider.IO)to ensure it is run on IO and post state updates onMainto ensure they are processed in ordercompleteRecordingSync: Introduce a new method which returns theResultof the recording instead of updating the internal state. This was required to ensure theMessageComposerController.sendRecording()works properly, because it previously relied on the sequential execution ofcompleteRecording(which is no longer the case)MessageComposerControllerNote: The corresponding methods from
StreamMediaRecorderwere not changed tosuspendbecause it is public API.🎨 UI Changes
Run the following tests, ensuring that nothing is broken + there are no related
StrictModeviolations in the LogCat (bothcomposeandxml)Stop, thenSend-> sends the recording in chatSend-> sends the recording in chatChatTheme.messageComposerTheme.audioRecording.sendOnCompletetofalse- re-run the same tests: For cases 2 and 3, the recording should first be added to the composer, and sent only when tapping theSendbutton.