From 87821eb2c05cab546ce18bf2c221f379cfe98b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 9 Jan 2020 11:51:51 +0000 Subject: [PATCH] android: unmute microphone on the ConnectionService handler This shouldn't be needed, as ConnectionService should take care of it, but we suspect some devices don't do it since we got reports of people not hearing users, and the problem went away when CS was disabled. --- .../AudioDeviceHandlerConnectionService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioDeviceHandlerConnectionService.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioDeviceHandlerConnectionService.java index f1302d3cbc0ad..5cb4a294416eb 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioDeviceHandlerConnectionService.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioDeviceHandlerConnectionService.java @@ -17,6 +17,7 @@ package org.jitsi.meet.sdk; import android.content.Context; +import android.media.AudioManager; import android.os.Build; import android.telecom.CallAudioState; import androidx.annotation.RequiresApi; @@ -38,6 +39,11 @@ class AudioDeviceHandlerConnectionService implements private final static String TAG = AudioDeviceHandlerConnectionService.class.getSimpleName(); + /** + * {@link AudioManager} instance used to interact with the Android audio subsystem. + */ + private AudioManager audioManager; + /** * Reference to the main {@code AudioModeModule}. */ @@ -134,6 +140,8 @@ public void start(Context context, AudioModeModule audioModeModule) { JitsiMeetLogger.i("Using " + TAG + " as the audio device handler"); module = audioModeModule; + audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); + RNConnectionService rcs = ReactInstanceManagerHolder.getNativeModule(RNConnectionService.class); if (rcs != null) { rcs.setCallAudioStateListener(this); @@ -160,6 +168,16 @@ public void setAudioRoute(String audioDevice) { @Override public boolean setMode(int mode) { + if (mode != AudioModeModule.DEFAULT) { + // This shouldn't be needed when using ConnectionService, but some devices have been + // observed not doing it. + try { + audioManager.setMicrophoneMute(false); + } catch (Throwable tr) { + JitsiMeetLogger.w(tr, TAG + " Failed to unmute the microphone"); + } + } + return true; } }