Add further Connection-side APIs for RTT (part 2)
Add methods and callbacks to facilitate local and remote RTT initiation and termination in the middle of a call. Adds @hide Connection-side APIs to communicate with the ConnectionService, as well as plumbing for RemoteConnections. Test: manual, through telecom testapps Change-Id: Ia80604b7dff8586ff222dbccdbe55e91aab02178
This commit is contained in:
@@ -20,6 +20,7 @@ import com.android.internal.telecom.IConnectionService;
|
||||
import com.android.internal.telecom.IVideoCallback;
|
||||
import com.android.internal.telecom.IVideoProvider;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
@@ -231,6 +232,41 @@ public final class RemoteConnection {
|
||||
* @param extras Extras associated with the event.
|
||||
*/
|
||||
public void onConnectionEvent(RemoteConnection connection, String event, Bundle extras) {}
|
||||
|
||||
/**
|
||||
* Indicates that a RTT session was successfully established on this
|
||||
* {@link RemoteConnection}. See {@link Connection#sendRttInitiationSuccess()}.
|
||||
* @hide
|
||||
* @param connection The {@code RemoteConnection} invoking this method.
|
||||
*/
|
||||
public void onRttInitiationSuccess(RemoteConnection connection) {}
|
||||
|
||||
/**
|
||||
* Indicates that a RTT session failed to be established on this
|
||||
* {@link RemoteConnection}. See {@link Connection#sendRttInitiationFailure()}.
|
||||
* @hide
|
||||
* @param connection The {@code RemoteConnection} invoking this method.
|
||||
* @param reason One of the reason codes defined in {@link Connection.RttModifyStatus},
|
||||
* with the exception of
|
||||
* {@link Connection.RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
|
||||
*/
|
||||
public void onRttInitiationFailure(RemoteConnection connection, int reason) {}
|
||||
|
||||
/**
|
||||
* Indicates that an established RTT session was terminated remotely on this
|
||||
* {@link RemoteConnection}. See {@link Connection#sendRttSessionRemotelyTerminated()}
|
||||
* @hide
|
||||
* @param connection The {@code RemoteConnection} invoking this method.
|
||||
*/
|
||||
public void onRttSessionRemotelyTerminated(RemoteConnection connection) {}
|
||||
|
||||
/**
|
||||
* Indicates that the remote user on this {@link RemoteConnection} has requested an upgrade
|
||||
* to an RTT session. See {@link Connection#sendRemoteRttRequest()}
|
||||
* @hide
|
||||
* @param connection The {@code RemoteConnection} invoking this method.
|
||||
*/
|
||||
public void onRemoteRttRequest(RemoteConnection connection) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1045,6 +1081,61 @@ public final class RemoteConnection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies this {@link RemoteConnection} that the user has requested an RTT session.
|
||||
* @param rttTextStream The object that should be used to send text to or receive text from
|
||||
* the in-call app.
|
||||
* @hide
|
||||
*/
|
||||
public void startRtt(@NonNull Connection.RttTextStream rttTextStream) {
|
||||
try {
|
||||
if (mConnected) {
|
||||
mConnectionService.startRtt(mConnectionId, rttTextStream.getFdFromInCall(),
|
||||
rttTextStream.getFdToInCall(), null /*Session.Info*/);
|
||||
}
|
||||
} catch (RemoteException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies this {@link RemoteConnection} that it should terminate any existing RTT
|
||||
* session. No response to Telecom is needed for this method.
|
||||
* @hide
|
||||
*/
|
||||
public void stopRtt() {
|
||||
try {
|
||||
if (mConnected) {
|
||||
mConnectionService.stopRtt(mConnectionId, null /*Session.Info*/);
|
||||
}
|
||||
} catch (RemoteException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies this {@link RemoteConnection} of a response to a previous remotely-initiated RTT
|
||||
* upgrade request sent via {@link Connection#sendRemoteRttRequest}.
|
||||
* Acceptance of the request is indicated by the supplied {@link RttTextStream} being non-null,
|
||||
* and rejection is indicated by {@code rttTextStream} being {@code null}
|
||||
* @hide
|
||||
* @param rttTextStream The object that should be used to send text to or receive text from
|
||||
* the in-call app.
|
||||
*/
|
||||
public void sendRttUpgradeResponse(@Nullable Connection.RttTextStream rttTextStream) {
|
||||
try {
|
||||
if (mConnected) {
|
||||
if (rttTextStream == null) {
|
||||
mConnectionService.respondToRttUpgradeRequest(mConnectionId,
|
||||
null, null, null /*Session.Info*/);
|
||||
} else {
|
||||
mConnectionService.respondToRttUpgradeRequest(mConnectionId,
|
||||
rttTextStream.getFdFromInCall(), rttTextStream.getFdToInCall(),
|
||||
null /*Session.Info*/);
|
||||
}
|
||||
}
|
||||
} catch (RemoteException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be
|
||||
* successfully asked to create a conference with.
|
||||
@@ -1411,6 +1502,47 @@ public final class RemoteConnection {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
void onRttInitiationSuccess() {
|
||||
for (CallbackRecord record : mCallbackRecords) {
|
||||
final RemoteConnection connection = this;
|
||||
final Callback callback = record.getCallback();
|
||||
record.getHandler().post(
|
||||
() -> callback.onRttInitiationSuccess(connection));
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
void onRttInitiationFailure(int reason) {
|
||||
for (CallbackRecord record : mCallbackRecords) {
|
||||
final RemoteConnection connection = this;
|
||||
final Callback callback = record.getCallback();
|
||||
record.getHandler().post(
|
||||
() -> callback.onRttInitiationFailure(connection, reason));
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
void onRttSessionRemotelyTerminated() {
|
||||
for (CallbackRecord record : mCallbackRecords) {
|
||||
final RemoteConnection connection = this;
|
||||
final Callback callback = record.getCallback();
|
||||
record.getHandler().post(
|
||||
() -> callback.onRttSessionRemotelyTerminated(connection));
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
void onRemoteRttRequest() {
|
||||
for (CallbackRecord record : mCallbackRecords) {
|
||||
final RemoteConnection connection = this;
|
||||
final Callback callback = record.getCallback();
|
||||
record.getHandler().post(
|
||||
() -> callback.onRemoteRttRequest(connection));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Create a RemoteConnection represents a failure, and which will be in
|
||||
* {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
|
||||
|
||||
Reference in New Issue
Block a user