From 73897f8db3ded32445b527ebb53a52b7ee81c60d Mon Sep 17 00:00:00 2001 From: p42ity Date: Tue, 23 Apr 2024 16:53:14 +0200 Subject: [PATCH] Voice Recordings: Add privacy option, deactivate workaround for AAC sensitive devices for Android 14+ and change default sampling frequency --- .../eu/siacs/conversations/ui/RecordingActivity.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java b/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java index 7c13b54fa..64446e930 100644 --- a/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java @@ -106,6 +106,9 @@ public class RecordingActivity extends BaseActivity implements View.OnClickListe private boolean startRecording() { mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + mRecorder.setPrivacySensitive(true); + } final int outputFormat; if (Config.USE_OPUS_VOICE_MESSAGES && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { outputFormat = MediaRecorder.OutputFormat.OGG; @@ -115,14 +118,14 @@ public class RecordingActivity extends BaseActivity implements View.OnClickListe } else { outputFormat = MediaRecorder.OutputFormat.MPEG_4; mRecorder.setOutputFormat(outputFormat); - if (AAC_SENSITIVE_DEVICES.contains(Build.MODEL)) { - // Changing these three settings for AAC sensitive devices might lead to sporadically truncated (cut-off) voice messages. + if (AAC_SENSITIVE_DEVICES.contains(Build.MODEL) && Build.VERSION.SDK_INT <= Build.VERSION_CODES.TIRAMISU) { + // Changing these three settings for AAC sensitive devices for Android<=13 might lead to sporadically truncated (cut-off) voice messages. mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC); mRecorder.setAudioSamplingRate(24_000); mRecorder.setAudioEncodingBitRate(28_000); } else { mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); - mRecorder.setAudioSamplingRate(22_050); + mRecorder.setAudioSamplingRate(44_100); mRecorder.setAudioEncodingBitRate(64_000); } }