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 Merged-In: Ia80604b7dff8586ff222dbccdbe55e91aab02178 Change-Id: Ia80604b7dff8586ff222dbccdbe55e91aab02178
This commit is contained in:
@ -871,6 +871,16 @@ public final class Call {
|
||||
* @param id The ID of the request.
|
||||
*/
|
||||
public void onRttRequest(Call call, int id) {}
|
||||
|
||||
/**
|
||||
* Invoked when the RTT session failed to initiate for some reason, including rejection
|
||||
* by the remote party.
|
||||
* @param call The call which the RTT initiation failure occurred on.
|
||||
* @param reason One of the status codes defined in
|
||||
* {@link android.telecom.Connection.RttModifyStatus}, with the exception of
|
||||
* {@link android.telecom.Connection.RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
|
||||
*/
|
||||
public void onRttInitiationFailure(Call call, int reason) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -913,13 +923,15 @@ public final class Call {
|
||||
private OutputStreamWriter mTransmitStream;
|
||||
private int mRttMode;
|
||||
private final InCallAdapter mInCallAdapter;
|
||||
private final String mTelecomCallId;
|
||||
private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public RttCall(InputStreamReader receiveStream, OutputStreamWriter transmitStream,
|
||||
int mode, InCallAdapter inCallAdapter) {
|
||||
public RttCall(String telecomCallId, InputStreamReader receiveStream,
|
||||
OutputStreamWriter transmitStream, int mode, InCallAdapter inCallAdapter) {
|
||||
mTelecomCallId = telecomCallId;
|
||||
mReceiveStream = receiveStream;
|
||||
mTransmitStream = transmitStream;
|
||||
mRttMode = mode;
|
||||
@ -942,7 +954,7 @@ public final class Call {
|
||||
* {@link #RTT_MODE_VCO}, or {@link #RTT_MODE_HCO}.
|
||||
*/
|
||||
public void setRttMode(@RttAudioMode int mode) {
|
||||
mInCallAdapter.setRttMode(mode);
|
||||
mInCallAdapter.setRttMode(mTelecomCallId, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1213,7 +1225,7 @@ public final class Call {
|
||||
* {@link Callback#onRttStatusChanged(Call, boolean, RttCall)} callback.
|
||||
*/
|
||||
public void sendRttRequest() {
|
||||
mInCallAdapter.sendRttRequest();
|
||||
mInCallAdapter.sendRttRequest(mTelecomCallId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1224,7 +1236,7 @@ public final class Call {
|
||||
* @param accept {@code true} if the RTT request should be accepted, {@code false} otherwise.
|
||||
*/
|
||||
public void respondToRttRequest(int id, boolean accept) {
|
||||
mInCallAdapter.respondToRttRequest(id, accept);
|
||||
mInCallAdapter.respondToRttRequest(mTelecomCallId, id, accept);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1232,7 +1244,7 @@ public final class Call {
|
||||
* the {@link Callback#onRttStatusChanged(Call, boolean, RttCall)} callback.
|
||||
*/
|
||||
public void stopRtt() {
|
||||
mInCallAdapter.stopRtt();
|
||||
mInCallAdapter.stopRtt(mTelecomCallId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1637,7 +1649,7 @@ public final class Call {
|
||||
new ParcelFileDescriptor.AutoCloseOutputStream(
|
||||
parcelableRttCall.getTransmitStream()),
|
||||
StandardCharsets.UTF_8);
|
||||
RttCall newRttCall = new Call.RttCall(
|
||||
RttCall newRttCall = new Call.RttCall(mTelecomCallId,
|
||||
receiveStream, transmitStream, parcelableRttCall.getRttMode(), mInCallAdapter);
|
||||
if (mRttCall == null) {
|
||||
isRttChanged = true;
|
||||
@ -1717,6 +1729,15 @@ public final class Call {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
final void internalOnRttInitiationFailure(int reason) {
|
||||
for (CallbackRecord<Callback> record : mCallbackRecords) {
|
||||
final Call call = this;
|
||||
final Callback callback = record.getCallback();
|
||||
record.getHandler().post(() -> callback.onRttInitiationFailure(call, reason));
|
||||
}
|
||||
}
|
||||
|
||||
private void fireStateChanged(final int newState) {
|
||||
for (CallbackRecord<Callback> record : mCallbackRecords) {
|
||||
final Call call = this;
|
||||
|
Reference in New Issue
Block a user