From 6b716f8f56d11dab47232be6cb350cc5d7628dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 8 Nov 2019 11:00:48 +0100 Subject: [PATCH] android: fix initializing audio device handler modules too early When ConnectionService is used (the default) we were attaching the handlers too early, and since attaching them requires that the RNConnectionService module is loaded, it silently failed. Instead, use the initialize() method, which gets called after all the Catalyst (aka native) modules have been loaded. --- .../java/org/jitsi/meet/sdk/AudioModeModule.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java index 88146cef7..b579d86d8 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java @@ -136,8 +136,6 @@ class AudioModeModule extends ReactContextBaseJavaModule { */ public AudioModeModule(ReactApplicationContext reactContext) { super(reactContext); - - setAudioDeviceHandler(); } /** @@ -193,6 +191,16 @@ class AudioModeModule extends ReactContextBaseJavaModule { return NAME; } + /** + * Initializes the audio device handler module. This function is called *after* all Catalyst + * modules have been created, and that's why we use it, because {@link AudioDeviceHandlerConnectionService} + * needs access to another Catalyst module, so doing this in the constructor would be too early. + */ + @Override + public void initialize() { + setAudioDeviceHandler(); + } + private void setAudioDeviceHandler() { if (audioDeviceHandler != null) { audioDeviceHandler.stop();