ref(remove ReactInstanceHolder from AudioModule
This commit is contained in:
parent
7a8350356a
commit
c9f9708166
|
@ -22,6 +22,8 @@ import android.os.Build;
|
||||||
import android.telecom.CallAudioState;
|
import android.telecom.CallAudioState;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
|
import com.facebook.react.bridge.ReactContext;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -49,6 +51,8 @@ class AudioDeviceHandlerConnectionService implements
|
||||||
*/
|
*/
|
||||||
private AudioModeModule module;
|
private AudioModeModule module;
|
||||||
|
|
||||||
|
private RNConnectionService rcs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts any of the "DEVICE_" constants into the corresponding
|
* Converts any of the "DEVICE_" constants into the corresponding
|
||||||
* {@link android.telecom.CallAudioState} "ROUTE_" number.
|
* {@link android.telecom.CallAudioState} "ROUTE_" number.
|
||||||
|
@ -141,8 +145,8 @@ class AudioDeviceHandlerConnectionService implements
|
||||||
JitsiMeetLogger.i("Using " + TAG + " as the audio device handler");
|
JitsiMeetLogger.i("Using " + TAG + " as the audio device handler");
|
||||||
|
|
||||||
module = audioModeModule;
|
module = audioModeModule;
|
||||||
|
rcs = module.getContext().getNativeModule(RNConnectionService.class);
|
||||||
|
|
||||||
RNConnectionService rcs = ReactInstanceManagerHolder.getNativeModule(RNConnectionService.class);
|
|
||||||
if (rcs != null) {
|
if (rcs != null) {
|
||||||
rcs.setCallAudioStateListener(this);
|
rcs.setCallAudioStateListener(this);
|
||||||
} else {
|
} else {
|
||||||
|
@ -152,9 +156,9 @@ class AudioDeviceHandlerConnectionService implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
RNConnectionService rcs = ReactInstanceManagerHolder.getNativeModule(RNConnectionService.class);
|
|
||||||
if (rcs != null) {
|
if (rcs != null) {
|
||||||
rcs.setCallAudioStateListener(null);
|
rcs.setCallAudioStateListener(null);
|
||||||
|
rcs = null;
|
||||||
} else {
|
} else {
|
||||||
JitsiMeetLogger.w(TAG + " Couldn't set call audio state listener, module is null");
|
JitsiMeetLogger.w(TAG + " Couldn't set call audio state listener, module is null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,13 @@ import com.facebook.react.bridge.Arguments;
|
||||||
import com.facebook.react.bridge.Promise;
|
import com.facebook.react.bridge.Promise;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||||
|
import com.facebook.react.bridge.ReactContext;
|
||||||
import com.facebook.react.bridge.ReactMethod;
|
import com.facebook.react.bridge.ReactMethod;
|
||||||
import com.facebook.react.bridge.WritableArray;
|
import com.facebook.react.bridge.WritableArray;
|
||||||
import com.facebook.react.bridge.WritableMap;
|
import com.facebook.react.bridge.WritableMap;
|
||||||
import com.facebook.react.module.annotations.ReactModule;
|
import com.facebook.react.module.annotations.ReactModule;
|
||||||
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||||
|
|
||||||
|
|
||||||
import org.jitsi.meet.sdk.log.JitsiMeetLogger;
|
import org.jitsi.meet.sdk.log.JitsiMeetLogger;
|
||||||
|
|
||||||
|
@ -196,7 +199,7 @@ class AudioModeModule extends ReactContextBaseJavaModule {
|
||||||
deviceInfo.putBoolean("selected", device.equals(selectedDevice));
|
deviceInfo.putBoolean("selected", device.equals(selectedDevice));
|
||||||
data.pushMap(deviceInfo);
|
data.pushMap(deviceInfo);
|
||||||
}
|
}
|
||||||
ReactInstanceManagerHolder.emitEvent(DEVICE_CHANGE_EVENT, data);
|
getContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(DEVICE_CHANGE_EVENT, data);
|
||||||
JitsiMeetLogger.i(TAG + " Updating audio device list");
|
JitsiMeetLogger.i(TAG + " Updating audio device list");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -212,6 +215,10 @@ class AudioModeModule extends ReactContextBaseJavaModule {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReactContext getContext(){
|
||||||
|
return this.getReactApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the audio device handler module. This function is called *after* all Catalyst
|
* 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}
|
* modules have been created, and that's why we use it, because {@link AudioDeviceHandlerConnectionService}
|
||||||
|
|
Loading…
Reference in New Issue