mirror of https://github.com/jitsi/jitsi-meet
* 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 commentspull/3853/head jitsi-meet_3518
parent
3ad99e24cf
commit
f8294fb312
@ -0,0 +1,435 @@ |
||||
package org.jitsi.meet.sdk; |
||||
|
||||
import android.content.ComponentName; |
||||
import android.content.Context; |
||||
import android.net.Uri; |
||||
import android.os.Build; |
||||
import android.os.Bundle; |
||||
import android.support.annotation.RequiresApi; |
||||
import android.telecom.CallAudioState; |
||||
import android.telecom.Connection; |
||||
import android.telecom.ConnectionRequest; |
||||
import android.telecom.DisconnectCause; |
||||
import android.telecom.PhoneAccount; |
||||
import android.telecom.PhoneAccountHandle; |
||||
import android.telecom.TelecomManager; |
||||
import android.telecom.VideoProfile; |
||||
import android.util.Log; |
||||
|
||||
import com.facebook.react.bridge.Promise; |
||||
import com.facebook.react.bridge.ReadableMap; |
||||
import com.facebook.react.bridge.WritableNativeMap; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* Jitsi Meet implementation of {@link ConnectionService}. At the time of this |
||||
* writing it implements only the outgoing call scenario. |
||||
* |
||||
* NOTE the class needs to be public, but is not part of the SDK API and should |
||||
* never be used directly. |
||||
* |
||||
* @author Pawel Domas |
||||
*/ |
||||
@RequiresApi(api = Build.VERSION_CODES.O) |
||||
public class ConnectionService extends android.telecom.ConnectionService { |
||||
|
||||
/** |
||||
* Tag used for logging. |
||||
*/ |
||||
static final String TAG = "JitsiConnectionService"; |
||||
|
||||
/** |
||||
* The extra added to the {@link ConnectionImpl} and |
||||
* {@link ConnectionRequest} which stores the {@link PhoneAccountHandle} |
||||
* created for the call. |
||||
*/ |
||||
static final String EXTRA_PHONE_ACCOUNT_HANDLE |
||||
= "org.jitsi.meet.sdk.connection_service.PHONE_ACCOUNT_HANDLE"; |
||||
|
||||
/** |
||||
* Connections mapped by call UUID. |
||||
*/ |
||||
static private final Map<String, ConnectionImpl> connections |
||||
= new HashMap<>(); |
||||
|
||||
/** |
||||
* The start call Promises mapped by call UUID. |
||||
*/ |
||||
static private final HashMap<String, Promise> startCallPromises |
||||
= new HashMap<>(); |
||||
|
||||
/** |
||||
* Adds {@link ConnectionImpl} to the list. |
||||
* |
||||
* @param connection - {@link ConnectionImpl} |
||||
*/ |
||||
static void addConnection(ConnectionImpl connection) { |
||||
connections.put(connection.getCallUUID(), connection); |
||||
} |
||||
|
||||
/** |
||||
* Returns all {@link ConnectionImpl} instances held in this list. |
||||
* |
||||
* @return a list of {@link ConnectionImpl}. |
||||
*/ |
||||
static List<ConnectionImpl> getConnections() { |
||||
return new ArrayList<>(connections.values()); |
||||
} |
||||
|
||||
/** |
||||
* Registers a start call promise. |
||||
* |
||||
* @param uuid - the call UUID to which the start call promise belongs to. |
||||
* @param promise - the Promise instance to be stored for later use. |
||||
*/ |
||||
static void registerStartCallPromise(String uuid, Promise promise) { |
||||
startCallPromises.put(uuid, promise); |
||||
} |
||||
|
||||
/** |
||||
* Removes {@link ConnectionImpl} from the list. |
||||
* |
||||
* @param connection - {@link ConnectionImpl} |
||||
*/ |
||||
static void removeConnection(ConnectionImpl connection) { |
||||
connections.remove(connection.getCallUUID()); |
||||
} |
||||
|
||||
/** |
||||
* Used to adjusts the connection's state to |
||||
* {@link android.telecom.Connection#STATE_ACTIVE}. |
||||
* |
||||
* @param callUUID the call UUID which identifies the connection. |
||||
*/ |
||||
static void setConnectionActive(String callUUID) { |
||||
ConnectionImpl connection = connections.get(callUUID); |
||||
|
||||
if (connection != null) { |
||||
connection.setActive(); |
||||
} else { |
||||
Log.e(TAG, String.format( |
||||
"setConnectionActive - no connection for UUID: %s", |
||||
callUUID)); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Used to adjusts the connection's state to |
||||
* {@link android.telecom.Connection#STATE_DISCONNECTED}. |
||||
* |
||||
* @param callUUID the call UUID which identifies the connection. |
||||
* @param cause disconnection reason. |
||||
*/ |
||||
static void setConnectionDisconnected(String callUUID, DisconnectCause cause) { |
||||
ConnectionImpl connection = connections.get(callUUID); |
||||
|
||||
if (connection != null) { |
||||
// Note that the connection is not removed from the list here, but
|
||||
// in ConnectionImpl's state changed callback. It's a safer
|
||||
// approach, because in case the app would crash on the JavaScript
|
||||
// side the calls would be cleaned up by the system they would still
|
||||
// be removed from the ConnectionList.
|
||||
connection.setDisconnected(cause); |
||||
connection.destroy(); |
||||
} else { |
||||
Log.e(TAG, "endCall no connection for UUID: " + callUUID); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Unregisters a start call promise. Must be called after the Promise is |
||||
* rejected or resolved. |
||||
* |
||||
* @param uuid the call UUID which identifies the call to which the promise |
||||
* belongs to. |
||||
* @return the unregistered Promise instance or <tt>null</tt> if there |
||||
* wasn't any for the given call UUID. |
||||
*/ |
||||
static Promise unregisterStartCallPromise(String uuid) { |
||||
return startCallPromises.remove(uuid); |
||||
} |
||||
|
||||
/** |
||||
* Used to adjusts the call's state. |
||||
* |
||||
* @param callUUID the call UUID which identifies the connection. |
||||
* @param callState a map which carries the properties to be modified. See |
||||
* "KEY_*" constants in {@link ConnectionImpl} for the list of keys. |
||||
*/ |
||||
static void updateCall(String callUUID, ReadableMap callState) { |
||||
ConnectionImpl connection = connections.get(callUUID); |
||||
|
||||
if (connection != null) { |
||||
if (callState.hasKey(ConnectionImpl.KEY_HAS_VIDEO)) { |
||||
boolean hasVideo |
||||
= callState.getBoolean(ConnectionImpl.KEY_HAS_VIDEO); |
||||
|
||||
Log.d(TAG, String.format( |
||||
"updateCall: %s hasVideo: %s", callUUID, hasVideo)); |
||||
connection.setVideoState( |
||||
hasVideo |
||||
? VideoProfile.STATE_BIDIRECTIONAL |
||||
: VideoProfile.STATE_AUDIO_ONLY); |
||||
} |
||||
} else { |
||||
Log.e(TAG, "updateCall no connection for UUID: " + callUUID); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Connection onCreateOutgoingConnection( |
||||
PhoneAccountHandle accountHandle, ConnectionRequest request) { |
||||
ConnectionImpl connection = new ConnectionImpl(); |
||||
|
||||
connection.setConnectionProperties(Connection.PROPERTY_SELF_MANAGED); |
||||
connection.setAddress( |
||||
request.getAddress(), |
||||
TelecomManager.PRESENTATION_ALLOWED); |
||||
connection.setExtras(request.getExtras()); |
||||
// NOTE there's a time gap between the placeCall and this callback when
|
||||
// things could get out of sync, but they are put back in sync once
|
||||
// the startCall Promise is resolved below. That's because on
|
||||
// the JavaScript side there's a logic to sync up in .then() callback.
|
||||
connection.setVideoState(request.getVideoState()); |
||||
|
||||
Bundle moreExtras = new Bundle(); |
||||
|
||||
moreExtras.putParcelable( |
||||
EXTRA_PHONE_ACCOUNT_HANDLE, |
||||
Objects.requireNonNull(request.getAccountHandle(), "accountHandle")); |
||||
connection.putExtras(moreExtras); |
||||
|
||||
addConnection(connection); |
||||
|
||||
Promise startCallPromise |
||||
= unregisterStartCallPromise(connection.getCallUUID()); |
||||
|
||||
if (startCallPromise != null) { |
||||
Log.d(TAG, |
||||
"onCreateOutgoingConnection " + connection.getCallUUID()); |
||||
startCallPromise.resolve(null); |
||||
} else { |
||||
Log.e(TAG, String.format( |
||||
"onCreateOutgoingConnection: no start call Promise for %s", |
||||
connection.getCallUUID())); |
||||
} |
||||
|
||||
return connection; |
||||
} |
||||
|
||||
@Override |
||||
public Connection onCreateIncomingConnection( |
||||
PhoneAccountHandle accountHandle, ConnectionRequest request) { |
||||
throw new RuntimeException("Not implemented"); |
||||
} |
||||
|
||||
@Override |
||||
public void onCreateIncomingConnectionFailed( |
||||
PhoneAccountHandle accountHandle, ConnectionRequest request) { |
||||
throw new RuntimeException("Not implemented"); |
||||
} |
||||
|
||||
@Override |
||||
public void onCreateOutgoingConnectionFailed( |
||||
PhoneAccountHandle accountHandle, ConnectionRequest request) { |
||||
PhoneAccountHandle theAccountHandle = request.getAccountHandle(); |
||||
String callUUID = theAccountHandle.getId(); |
||||
|
||||
Log.e(TAG, "onCreateOutgoingConnectionFailed " + callUUID); |
||||
|
||||
if (callUUID != null) { |
||||
Promise startCallPromise = unregisterStartCallPromise(callUUID); |
||||
|
||||
if (startCallPromise != null) { |
||||
startCallPromise.reject( |
||||
"CREATE_OUTGOING_CALL_FAILED", |
||||
"The request has been denied by the system"); |
||||
} else { |
||||
Log.e(TAG, String.format( |
||||
"startCallFailed - no start call Promise for UUID: %s", |
||||
callUUID)); |
||||
} |
||||
} else { |
||||
Log.e(TAG, "onCreateOutgoingConnectionFailed - no call UUID"); |
||||
} |
||||
|
||||
unregisterPhoneAccount(theAccountHandle); |
||||
} |
||||
|
||||
private void unregisterPhoneAccount(PhoneAccountHandle phoneAccountHandle) { |
||||
TelecomManager telecom = getSystemService(TelecomManager.class); |
||||
if (telecom != null) { |
||||
if (phoneAccountHandle != null) { |
||||
telecom.unregisterPhoneAccount(phoneAccountHandle); |
||||
} else { |
||||
Log.e(TAG, "unregisterPhoneAccount - account handle is null"); |
||||
} |
||||
} else { |
||||
Log.e(TAG, "unregisterPhoneAccount - telecom is null"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Registers new {@link PhoneAccountHandle}. |
||||
* |
||||
* @param context the current Android context. |
||||
* @param address the phone account's address. At the time of this writing |
||||
* it's the call handle passed from the Java Script side. |
||||
* @param callUUID the call's UUID for which the account is to be created. |
||||
* It will be used as the account's id. |
||||
* @return {@link PhoneAccountHandle} described by the given arguments. |
||||
*/ |
||||
static PhoneAccountHandle registerPhoneAccount( |
||||
Context context, Uri address, String callUUID) { |
||||
PhoneAccountHandle phoneAccountHandle |
||||
= new PhoneAccountHandle( |
||||
new ComponentName(context, ConnectionService.class), |
||||
callUUID); |
||||
|
||||
PhoneAccount.Builder builder |
||||
= PhoneAccount.builder(phoneAccountHandle, address.toString()) |
||||
.setAddress(address) |
||||
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED | |
||||
PhoneAccount.CAPABILITY_VIDEO_CALLING | |
||||
PhoneAccount.CAPABILITY_SUPPORTS_VIDEO_CALLING) |
||||
.addSupportedUriScheme(PhoneAccount.SCHEME_SIP); |
||||
|
||||
PhoneAccount account = builder.build(); |
||||
|
||||
TelecomManager telecomManager |
||||
= context.getSystemService(TelecomManager.class); |
||||
telecomManager.registerPhoneAccount(account); |
||||
|
||||
return phoneAccountHandle; |
||||
} |
||||
|
||||
/** |
||||
* Connection implementation for Jitsi Meet's {@link ConnectionService}. |
||||
* |
||||
* @author Pawel Domas |
||||
*/ |
||||
class ConnectionImpl extends Connection { |
||||
|
||||
/** |
||||
* The constant which defines the key for the "has video" property. |
||||
* The key is used in the map which carries the call's state passed as |
||||
* the argument of the {@link RNConnectionService#updateCall} method. |
||||
*/ |
||||
static final String KEY_HAS_VIDEO = "hasVideo"; |
||||
|
||||
/** |
||||
* Called when system wants to disconnect the call. |
||||
* |
||||
* {@inheritDoc} |
||||
*/ |
||||
@Override |
||||
public void onDisconnect() { |
||||
Log.d(TAG, "onDisconnect " + getCallUUID()); |
||||
WritableNativeMap data = new WritableNativeMap(); |
||||
data.putString("callUUID", getCallUUID()); |
||||
ReactContextUtils.emitEvent( |
||||
null, |
||||
"org.jitsi.meet:features/connection_service#disconnect", |
||||
data); |
||||
// The JavaScript side will not go back to the native with
|
||||
// 'endCall', so the Connection must be removed immediately.
|
||||
setConnectionDisconnected( |
||||
getCallUUID(), |
||||
new DisconnectCause(DisconnectCause.LOCAL)); |
||||
} |
||||
|
||||
/** |
||||
* Called when system wants to abort the call. |
||||
* |
||||
* {@inheritDoc} |
||||
*/ |
||||
@Override |
||||
public void onAbort() { |
||||
Log.d(TAG, "onAbort " + getCallUUID()); |
||||
WritableNativeMap data = new WritableNativeMap(); |
||||
data.putString("callUUID", getCallUUID()); |
||||
ReactContextUtils.emitEvent( |
||||
null, |
||||
"org.jitsi.meet:features/connection_service#abort", |
||||
data); |
||||
// The JavaScript side will not go back to the native with
|
||||
// 'endCall', so the Connection must be removed immediately.
|
||||
setConnectionDisconnected( |
||||
getCallUUID(), |
||||
new DisconnectCause(DisconnectCause.CANCELED)); |
||||
} |
||||
|
||||
@Override |
||||
public void onHold() { |
||||
// What ?! Android will still call this method even if we do not add
|
||||
// the HOLD capability, so do the same thing as on abort.
|
||||
// TODO implement HOLD
|
||||
Log.d(TAG, String.format( |
||||
"onHold %s - HOLD is not supported, aborting the call...", |
||||
getCallUUID())); |
||||
this.onAbort(); |
||||
} |
||||
|
||||
/** |
||||
* Called when there's change to the call audio state. Either by |
||||
* the system after the connection is initialized or in response to |
||||
* {@link #setAudioRoute(int)}. |
||||
* |
||||
* @param state the new {@link CallAudioState} |
||||
*/ |
||||
@Override |
||||
public void onCallAudioStateChanged(CallAudioState state) { |
||||
Log.d(TAG, "onCallAudioStateChanged: " + state); |
||||
AudioModeModule audioModeModule |
||||
= ReactInstanceManagerHolder |
||||
.getNativeModule(AudioModeModule.class); |
||||
if (audioModeModule != null) { |
||||
audioModeModule.onCallAudioStateChange(state); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Unregisters the account when the call is disconnected. |
||||
* |
||||
* @param state - the new connection's state. |
||||
*/ |
||||
@Override |
||||
public void onStateChanged(int state) { |
||||
Log.d(TAG, |
||||
String.format("onStateChanged: %s %s", |
||||
Connection.stateToString(state), |
||||
getCallUUID())); |
||||
|
||||
if (state == STATE_DISCONNECTED) { |
||||
removeConnection(this); |
||||
unregisterPhoneAccount(getPhoneAccountHandle()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Retrieves the UUID of the call associated with this connection. |
||||
* |
||||
* @return call UUID |
||||
*/ |
||||
String getCallUUID() { |
||||
return getPhoneAccountHandle().getId(); |
||||
} |
||||
|
||||
private PhoneAccountHandle getPhoneAccountHandle() { |
||||
return getExtras().getParcelable( |
||||
ConnectionService.EXTRA_PHONE_ACCOUNT_HANDLE); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return String.format( |
||||
"ConnectionImpl[adress=%s, uuid=%s]@%d", |
||||
getAddress(), getCallUUID(), hashCode()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,165 @@ |
||||
package org.jitsi.meet.sdk; |
||||
|
||||
import android.annotation.SuppressLint; |
||||
import android.content.Context; |
||||
import android.net.Uri; |
||||
import android.os.Build; |
||||
import android.os.Bundle; |
||||
import android.support.annotation.RequiresApi; |
||||
import android.telecom.DisconnectCause; |
||||
import android.telecom.PhoneAccount; |
||||
import android.telecom.PhoneAccountHandle; |
||||
import android.telecom.TelecomManager; |
||||
import android.telecom.VideoProfile; |
||||
import android.util.Log; |
||||
|
||||
import com.facebook.react.bridge.Promise; |
||||
import com.facebook.react.bridge.ReactApplicationContext; |
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule; |
||||
import com.facebook.react.bridge.ReactMethod; |
||||
import com.facebook.react.bridge.ReadableMap; |
||||
|
||||
/** |
||||
* The react-native side of Jitsi Meet's {@link ConnectionService}. Exposes |
||||
* the Java Script API. |
||||
* |
||||
* @author Pawel Domas |
||||
*/ |
||||
@RequiresApi(api = Build.VERSION_CODES.O) |
||||
class RNConnectionService |
||||
extends ReactContextBaseJavaModule { |
||||
|
||||
private final static String TAG = ConnectionService.TAG; |
||||
|
||||
/** |
||||
* Sets the audio route on all existing {@link android.telecom.Connection}s |
||||
* |
||||
* @param audioRoute the new audio route to be set. See |
||||
* {@link android.telecom.CallAudioState} constants prefixed with "ROUTE_". |
||||
*/ |
||||
@RequiresApi(api = Build.VERSION_CODES.O) |
||||
static void setAudioRoute(int audioRoute) { |
||||
for (ConnectionService.ConnectionImpl c |
||||
: ConnectionService.getConnections()) { |
||||
c.setAudioRoute(audioRoute); |
||||
} |
||||
} |
||||
|
||||
RNConnectionService(ReactApplicationContext reactContext) { |
||||
super(reactContext); |
||||
} |
||||
|
||||
/** |
||||
* Starts a new outgoing call. |
||||
* |
||||
* @param callUUID - unique call identifier assigned by Jitsi Meet to |
||||
* a conference call. |
||||
* @param handle - a call handle which by default is Jitsi Meet room's URL. |
||||
* @param hasVideo - whether or not user starts with the video turned on. |
||||
* @param promise - the Promise instance passed by the React-native bridge, |
||||
* so that this method returns a Promise on the JS side. |
||||
* |
||||
* NOTE regarding the "missingPermission" suppress - SecurityException will |
||||
* be handled as part of the Exception try catch block and the Promise will |
||||
* be rejected. |
||||
*/ |
||||
@SuppressLint("MissingPermission") |
||||
@ReactMethod |
||||
public void startCall( |
||||
String callUUID, |
||||
String handle, |
||||
boolean hasVideo, |
||||
Promise promise) { |
||||
Log.d(TAG, |
||||
String.format("startCall UUID=%s, h=%s, v=%s", |
||||
callUUID, |
||||
handle, |
||||
hasVideo)); |
||||
|
||||
ReactApplicationContext ctx = getReactApplicationContext(); |
||||
|
||||
Uri address = Uri.fromParts(PhoneAccount.SCHEME_SIP, handle, null); |
||||
PhoneAccountHandle accountHandle |
||||
= ConnectionService.registerPhoneAccount( |
||||
getReactApplicationContext(), address, callUUID); |
||||
|
||||
Bundle extras = new Bundle(); |
||||
extras.putParcelable( |
||||
TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, |
||||
accountHandle); |
||||
extras.putInt( |
||||
TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, |
||||
hasVideo |
||||
? VideoProfile.STATE_BIDIRECTIONAL |
||||
: VideoProfile.STATE_AUDIO_ONLY); |
||||
|
||||
ConnectionService.registerStartCallPromise(callUUID, promise); |
||||
|
||||
try { |
||||
TelecomManager tm |
||||
= (TelecomManager) ctx.getSystemService( |
||||
Context.TELECOM_SERVICE); |
||||
|
||||
tm.placeCall(address, extras); |
||||
} catch (Exception e) { |
||||
ConnectionService.unregisterStartCallPromise(callUUID); |
||||
promise.reject(e); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Called by the JS side of things to mark the call as failed. |
||||
* |
||||
* @param callUUID - the call's UUID. |
||||
*/ |
||||
@ReactMethod |
||||
public void reportCallFailed(String callUUID) { |
||||
Log.d(TAG, "reportCallFailed " + callUUID); |
||||
ConnectionService.setConnectionDisconnected( |
||||
callUUID, |
||||
new DisconnectCause(DisconnectCause.ERROR)); |
||||
} |
||||
|
||||
/** |
||||
* Called by the JS side of things to mark the call as disconnected. |
||||
* |
||||
* @param callUUID - the call's UUID. |
||||
*/ |
||||
@ReactMethod |
||||
public void endCall(String callUUID) { |
||||
Log.d(TAG, "endCall " + callUUID); |
||||
ConnectionService.setConnectionDisconnected( |
||||
callUUID, |
||||
new DisconnectCause(DisconnectCause.LOCAL)); |
||||
} |
||||
|
||||
/** |
||||
* Called by the JS side of things to mark the call as active. |
||||
* |
||||
* @param callUUID - the call's UUID. |
||||
*/ |
||||
@ReactMethod |
||||
public void reportConnectedOutgoingCall(String callUUID) { |
||||
Log.d(TAG, "reportConnectedOutgoingCall " + callUUID); |
||||
ConnectionService.setConnectionActive(callUUID); |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return "ConnectionService"; |
||||
} |
||||
|
||||
/** |
||||
* Called by the JS side to update the call's state. |
||||
* |
||||
* @param callUUID - the call's UUID. |
||||
* @param callState - the map which carries infor about the current call's |
||||
* state. See static fields in {@link ConnectionService.ConnectionImpl} |
||||
* prefixed with "KEY_" for the values supported by the Android |
||||
* implementation. |
||||
*/ |
||||
@ReactMethod |
||||
public void updateCall(String callUUID, ReadableMap callState) { |
||||
ConnectionService.updateCall(callUUID, callState); |
||||
} |
||||
} |
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
@ -0,0 +1,33 @@ |
||||
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; |
@ -0,0 +1,13 @@ |
||||
/** |
||||
* The type of redux action to set CallKit's and ConnectionService's event |
||||
* subscriptions. |
||||
* |
||||
* { |
||||
* type: _SET_CALL_INTEGRATION_SUBSCRIPTIONS, |
||||
* subscriptions: Array|undefined |
||||
* } |
||||
* |
||||
* @protected |
||||
*/ |
||||
export const _SET_CALL_INTEGRATION_SUBSCRIPTIONS |
||||
= Symbol('_SET_CALL_INTEGRATION_SUBSCRIPTIONS'); |
@ -1,13 +1,14 @@ |
||||
import { assign, ReducerRegistry } from '../../base/redux'; |
||||
|
||||
import { _SET_CALLKIT_SUBSCRIPTIONS } from './actionTypes'; |
||||
import { _SET_CALL_INTEGRATION_SUBSCRIPTIONS } from './actionTypes'; |
||||
import CallKit from './CallKit'; |
||||
import ConnectionService from './ConnectionService'; |
||||
|
||||
CallKit && ReducerRegistry.register( |
||||
'features/callkit', |
||||
(CallKit || ConnectionService) && ReducerRegistry.register( |
||||
'features/call-integration', |
||||
(state = {}, action) => { |
||||
switch (action.type) { |
||||
case _SET_CALLKIT_SUBSCRIPTIONS: |
||||
case _SET_CALL_INTEGRATION_SUBSCRIPTIONS: |
||||
return assign(state, 'subscriptions', action.subscriptions); |
||||
} |
||||
|
@ -1,11 +0,0 @@ |
||||
/** |
||||
* The type of redux action to set CallKit's event subscriptions. |
||||
* |
||||
* { |
||||
* type: _SET_CALLKIT_SUBSCRIPTIONS, |
||||
* subscriptions: Array|undefined |
||||
* } |
||||
* |
||||
* @protected |
||||
*/ |
||||
export const _SET_CALLKIT_SUBSCRIPTIONS = Symbol('_SET_CALLKIT_SUBSCRIPTIONS'); |
Loading…
Reference in new issue