jiti-meet/react/features/mobile/call-integration/ConnectionService.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

android: add ConnectionService * feat(Android): implement ConnectionService Adds basic integration with Android's ConnectionService by implementing the outgoing call scenario. * ref(callkit): rename _SET_CALLKIT_SUBSCRIPTIONS * ref(callkit): move feature to call-integration directory * feat(ConnectionService): synchronize video state * ref(AudioMode): use ConnectionService on API >= 26 Not ready yet - few details left mentioned in the FIXMEs * feat(ConnectionService): add debug logs Adds logs to trace the calls. * fix(ConnectionService): leaking ConnectionImpl instances Turns out there is no callback fired back from the JavaScript side after the disconnect or abort event is sent from the native. The connection must be marked as disconnected and removed immediately. * feat(ConnectionService): handle onCreateOutgoingConnectionFailed * ref(ConnectionService): merge classes and move to the sdk package * feat(CallIntegration): show Alert if outgoing call fails * fix(ConnectionService): alternatively get call UUID from the account Some Android flavours (or versions ?) do copy over extras to the onCreateOutgoingConnectionFailed callback. But the call UUID is also set as the PhoneAccount's label, so eventually it should be available there. * ref(ConnectionService): use call UUID as PhoneAccount ID. The extra is not reliable on some custom Android flavours. It also makes sense to use unique id for the account instead of the URL given that it's created on the per call basis. * fix(ConnectionService): abort the call when hold is requested Turns out Android P can sometimes request HOLD even though there's no HOLD capability added to the connection (what!?), so just abort the call in that case. * fix(ConnectionService): unregister account on call failure Unregister the PhoneAccount onCreateOutgoingConnectionFailed. That's before the ConnectionImpl instance is created which is normally responsible for doing that. * fix(AudioModeModule): make package private and run on the audio thread * address other review comments
2019-01-31 16:20:54 +00:00
import { NativeEventEmitter, NativeModules } from 'react-native';
let ConnectionService = NativeModules.ConnectionService;
// XXX Rather than wrapping ConnectionService in a new class and forwarding
// the many methods of the latter to the former, add the one additional
// method that we need to ConnectionService.
if (ConnectionService) {
const eventEmitter = new NativeEventEmitter(ConnectionService);
ConnectionService = {
...ConnectionService,
addListener: eventEmitter.addListener.bind(eventEmitter),
registerSubscriptions(context, delegate) {
return [
ConnectionService.addListener(
'org.jitsi.meet:features/connection_service#disconnect',
delegate._onPerformEndCallAction,
context),
ConnectionService.addListener(
'org.jitsi.meet:features/connection_service#abort',
delegate._onPerformEndCallAction,
context)
];
},
setMuted() {
// Currently no-op, but remember to remove when implemented on
// the native side
}
};
}
export default ConnectionService;