Skip to content

Commit

Permalink
android: unmute microphone on the ConnectionService handler
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
saghul committed Jan 9, 2020
1 parent 8291f45 commit 87821eb
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
*/
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
}

0 comments on commit 87821eb

Please sign in to comment.