public final class CallServiceAdapter implements android.os.IBinder.DeathRecipient {
method public void addConferenceCall(java.lang.String);
method public void binderDied();
+ method public void cancelOutgoingCall(java.lang.String);
method public void handleFailedOutgoingCall(android.telecomm.ConnectionRequest, int, java.lang.String);
method public void handleSuccessfulOutgoingCall(java.lang.String);
method public void handoffCall(java.lang.String);
method public final void abort(java.lang.String);
method public final void answer(java.lang.String);
method public final void call(android.telecomm.CallInfo);
- method public void createRemoteOutgoingConnection(android.telecomm.ConnectionRequest, android.telecomm.SimpleResponse<android.telecomm.ConnectionRequest, android.telecomm.RemoteConnection>);
+ method public void createRemoteOutgoingConnection(android.telecomm.ConnectionRequest, android.telecomm.ConnectionService.OutgoingCallResponse<android.telecomm.RemoteConnection>);
method public final void disconnect(java.lang.String);
method public java.util.Collection<android.telecomm.Connection> getAllConnections();
method public final void hold(java.lang.String);
method public void onConnectionAdded(android.telecomm.Connection);
method public void onConnectionRemoved(android.telecomm.Connection);
method public void onCreateConferenceConnection(java.lang.String, android.telecomm.Connection, android.telecomm.Response<java.lang.String, android.telecomm.Connection>);
- method public void onCreateConnections(android.telecomm.ConnectionRequest, android.telecomm.Response<android.telecomm.ConnectionRequest, android.telecomm.Connection>);
+ method public void onCreateConnections(android.telecomm.ConnectionRequest, android.telecomm.ConnectionService.OutgoingCallResponse<android.telecomm.Connection>);
method public void onCreateIncomingConnection(android.telecomm.ConnectionRequest, android.telecomm.Response<android.telecomm.ConnectionRequest, android.telecomm.Connection>);
method public final void onPostDialContinue(java.lang.String, boolean);
method public final void onPostDialWait(android.telecomm.Connection, java.lang.String);
method public final void unhold(java.lang.String);
}
+ public static abstract interface ConnectionService.OutgoingCallResponse {
+ method public abstract void onCancel(android.telecomm.ConnectionRequest);
+ method public abstract void onFailure(android.telecomm.ConnectionRequest, int, java.lang.String);
+ method public abstract void onSuccess(android.telecomm.ConnectionRequest, CONNECTION);
+ }
+
public class GatewayInfo implements android.os.Parcelable {
method public int describeContents();
method public android.net.Uri getGatewayHandle();
public class RemoteConnectionService implements android.os.IBinder.DeathRecipient {
method public void binderDied();
- method public void createOutgoingConnection(android.telecomm.ConnectionRequest, android.telecomm.SimpleResponse<android.telecomm.ConnectionRequest, android.telecomm.RemoteConnection>);
+ method public void createOutgoingConnection(android.telecomm.ConnectionRequest, android.telecomm.ConnectionService.OutgoingCallResponse<android.telecomm.RemoteConnection>);
method public java.util.List<android.telecomm.Subscription> lookupSubscriptions(android.net.Uri);
}
}
/**
+ * Tells Telecomm to cancel the call.
+ *
+ * @param callId The ID of the outgoing call.
+ */
+ public void cancelOutgoingCall(String callId) {
+ for (ICallServiceAdapter adapter : mAdapters) {
+ try {
+ adapter.cancelOutgoingCall(callId);
+ } catch (RemoteException e) {
+ }
+ }
+ }
+
+ /**
* Sets a call's state to active (e.g., an ongoing call where two parties can actively
* communicate).
*
private Uri mSubscriptionLookupHandle;
private boolean mAreSubscriptionsInitialized = false;
+ /**
+ * A callback for providing the resuilt of creating a connection.
+ */
+ public interface OutgoingCallResponse<CONNECTION> {
+ /**
+ * Tells Telecomm that an attempt to place the specified outgoing call succeeded.
+ *
+ * @param request The original request.
+ * @param connection The connection.
+ */
+ void onSuccess(ConnectionRequest request, CONNECTION connection);
+
+ /**
+ * Tells Telecomm that an attempt to place the specified outgoing call failed.
+ *
+ * @param request The original request.
+ * @param code An integer code indicating the reason for failure.
+ * @param msg A message explaining the reason for failure.
+ */
+ void onFailure(ConnectionRequest request, int code, String msg);
+
+ /**
+ * Tells Telecomm to cancel the call.
+ *
+ * @param request The original request.
+ */
+ void onCancel(ConnectionRequest request);
+ }
+
private final Connection.Listener mConnectionListener = new Connection.Listener() {
@Override
public void onStateChanged(Connection c, int state) {
callInfo.getId(),
callInfo.getHandle(),
callInfo.getExtras()),
- new Response<ConnectionRequest, Connection>() {
+ new OutgoingCallResponse<Connection>() {
@Override
- public void onResult(ConnectionRequest request, Connection... result) {
- if (result != null && result.length != 1) {
- Log.d(this, "adapter handleFailedOutgoingCall %s", callInfo);
- getAdapter().handleFailedOutgoingCall(
- request,
- DisconnectCause.ERROR_UNSPECIFIED,
- "Created " + result.length + " Connections, expected 1");
- for (Connection c : result) {
- c.abort();
- }
- } else {
- Log.d(this, "adapter handleSuccessfulOutgoingCall %s",
- callInfo.getId());
- getAdapter().handleSuccessfulOutgoingCall(callInfo.getId());
- addConnection(callInfo.getId(), result[0]);
- }
+ public void onSuccess(ConnectionRequest request, Connection connection) {
+ Log.d(this, "adapter handleSuccessfulOutgoingCall %s",
+ callInfo.getId());
+ getAdapter().handleSuccessfulOutgoingCall(callInfo.getId());
+ addConnection(callInfo.getId(), connection);
}
@Override
- public void onError(ConnectionRequest request, int code, String msg) {
+ public void onFailure(ConnectionRequest request, int code, String msg) {
getAdapter().handleFailedOutgoingCall(request, code, msg);
}
+
+ @Override
+ public void onCancel(ConnectionRequest request) {
+ getAdapter().cancelOutgoingCall(callInfo.getId());
+ }
}
);
}
public void createRemoteOutgoingConnection(
ConnectionRequest request,
- SimpleResponse<ConnectionRequest, RemoteConnection> response) {
+ OutgoingCallResponse<RemoteConnection> response) {
mRemoteConnectionManager.createOutgoingConnection(request, response);
}
*/
public void onCreateConnections(
ConnectionRequest request,
- Response<ConnectionRequest, Connection> callback) {}
+ OutgoingCallResponse<Connection> callback) {}
/**
* Returns a new or existing conference connection when the the user elects to convert the
public void createOutgoingConnection(
ConnectionRequest request,
- final SimpleResponse<ConnectionRequest, RemoteConnection> response) {
+ final ConnectionService.OutgoingCallResponse response) {
Subscription subscription = request.getSubscription();
if (subscription == null) {
throw new IllegalArgumentException("subscription must be specified.");
private String mConnectionId;
private ConnectionRequest mPendingRequest;
- private SimpleResponse<ConnectionRequest, RemoteConnection> mPendingResponse;
+ private ConnectionService.OutgoingCallResponse<RemoteConnection> mPendingOutgoingCallResponse;
// Remote connection services only support a single connection.
private RemoteConnection mConnection;
public void handleSuccessfulOutgoingCall(String connectionId) {
if (isPendingConnection(connectionId)) {
mConnection = new RemoteConnection(mCallService, connectionId);
- mPendingResponse.onResult(mPendingRequest, mConnection);
+ mPendingOutgoingCallResponse.onSuccess(mPendingRequest, mConnection);
clearPendingInformation();
}
}
if (isPendingConnection(request.getCallId())) {
// Use mPendingRequest instead of request so that we use the same object that was
// passed in to us.
- mPendingResponse.onError(request);
+ mPendingOutgoingCallResponse.onFailure(mPendingRequest, errorCode, errorMessage);
+ mConnectionId = null;
+ clearPendingInformation();
+ }
+ }
+
+ /** ${inheritDoc} */
+ @Override
+ public void cancelOutgoingCall(String connectionId) {
+ if (isPendingConnection(connectionId)) {
+ mPendingOutgoingCallResponse.onCancel(mPendingRequest);
mConnectionId = null;
clearPendingInformation();
}
*/
public void createOutgoingConnection(
ConnectionRequest request,
- SimpleResponse<ConnectionRequest, RemoteConnection> response) {
+ ConnectionService.OutgoingCallResponse<RemoteConnection> response) {
if (mConnectionId == null) {
String id = UUID.randomUUID().toString();
try {
mCallService.call(callInfo);
mConnectionId = id;
- mPendingResponse = response;
+ mPendingOutgoingCallResponse = response;
mPendingRequest = request;
} catch (RemoteException e) {
- response.onError(request);
+ response.onFailure(request, DisconnectCause.ERROR_UNSPECIFIED, e.toString());
}
} else {
- response.onError(request);
+ response.onFailure(request, DisconnectCause.ERROR_UNSPECIFIED, null);
}
}
}
private boolean isPendingConnection(String id) {
- return TextUtils.equals(mConnectionId, id) && mPendingResponse != null;
+ return TextUtils.equals(mConnectionId, id) && mPendingOutgoingCallResponse != null;
}
private boolean isCurrentConnection(String id) {
private void clearPendingInformation() {
mPendingRequest = null;
- mPendingResponse = null;
+ mPendingOutgoingCallResponse = null;
}
private void destroyConnection() {
void handleFailedOutgoingCall(in ConnectionRequest request, int errorCode, String errorMessage);
+ void cancelOutgoingCall(String callId);
+
void setActive(String callId);
void setRinging(String callId);