From f4b38e7ff15bef49e333dfb5a0eb788d65abe1ae Mon Sep 17 00:00:00 2001 From: Ravi Paluri Date: Wed, 5 Feb 2020 12:35:41 +0530 Subject: IMS: Add support for IMS Explicit call transfer Test: Manual Bug: 62170207 Change-Id: I06a256adb0e1910d40809c91bcdd42c56a142842 --- telecomm/java/android/telecom/Call.java | 51 ++++++++++++++- telecomm/java/android/telecom/Connection.java | 46 +++++++++++++- .../java/android/telecom/ConnectionService.java | 72 ++++++++++++++++++++++ telecomm/java/android/telecom/InCallAdapter.java | 30 +++++++++ .../internal/telecom/IConnectionService.aidl | 5 ++ .../android/internal/telecom/IInCallAdapter.aidl | 4 ++ 6 files changed, 206 insertions(+), 2 deletions(-) mode change 100644 => 100755 telecomm/java/android/telecom/Call.java mode change 100644 => 100755 telecomm/java/android/telecom/Connection.java mode change 100644 => 100755 telecomm/java/android/telecom/ConnectionService.java mode change 100644 => 100755 telecomm/java/android/telecom/InCallAdapter.java mode change 100644 => 100755 telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl (limited to 'telecomm/java') diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java old mode 100644 new mode 100755 index 52213d8c4fae..c5fcf67c9be9 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -465,8 +465,27 @@ public final class Call { * @hide */ public static final int CAPABILITY_ADD_PARTICIPANT = 0x02000000; + + /** + * When set for a call, indicates that this {@code Call} can be transferred to another + * number. + * Call supports the blind and assured call transfer feature. + * + * @hide + */ + public static final int CAPABILITY_TRANSFER = 0x04000000; + + /** + * When set for a call, indicates that this {@code Call} can be transferred to another + * ongoing call. + * Call supports the consultative call transfer feature. + * + * @hide + */ + public static final int CAPABILITY_TRANSFER_CONSULTATIVE = 0x08000000; + //****************************************************************************************** - // Next CAPABILITY value: 0x04000000 + // Next CAPABILITY value: 0x10000000 //****************************************************************************************** /** @@ -699,6 +718,12 @@ public final class Call { if (can(capabilities, CAPABILITY_ADD_PARTICIPANT)) { builder.append(" CAPABILITY_ADD_PARTICIPANT"); } + if (can(capabilities, CAPABILITY_TRANSFER)) { + builder.append(" CAPABILITY_TRANSFER"); + } + if (can(capabilities, CAPABILITY_TRANSFER_CONSULTATIVE)) { + builder.append(" CAPABILITY_TRANSFER_CONSULTATIVE"); + } builder.append("]"); return builder.toString(); } @@ -1563,6 +1588,30 @@ public final class Call { mInCallAdapter.rejectCall(mTelecomCallId, rejectReason); } + /** + * Instructs this {@code Call} to be transferred to another number. + * + * @param targetNumber The address to which the call will be transferred. + * @param isConfirmationRequired if {@code true} it will initiate ASSURED transfer, + * if {@code false}, it will initiate BLIND transfer. + * + * @hide + */ + public void transfer(@NonNull Uri targetNumber, boolean isConfirmationRequired) { + mInCallAdapter.transferCall(mTelecomCallId, targetNumber, isConfirmationRequired); + } + + /** + * Instructs this {@code Call} to be transferred to another ongoing call. + * This will initiate CONSULTATIVE transfer. + * @param toCall The other ongoing {@code Call} to which this call will be transferred. + * + * @hide + */ + public void transfer(@NonNull android.telecom.Call toCall) { + mInCallAdapter.transferCall(mTelecomCallId, toCall.mTelecomCallId); + } + /** * Instructs this {@code Call} to disconnect. */ diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java old mode 100644 new mode 100755 index 3b0ba2548660..3564add65113 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -387,8 +387,25 @@ public abstract class Connection extends Conferenceable { * @hide */ public static final int CAPABILITY_ADD_PARTICIPANT = 0x04000000; + + /** + * Indicates that this {@code Connection} can be transferred to another + * number. + * Connection supports the blind and assured call transfer feature. + * @hide + */ + public static final int CAPABILITY_TRANSFER = 0x08000000; + + /** + * Indicates that this {@code Connection} can be transferred to another + * ongoing {@code Connection}. + * Connection supports the consultative call transfer feature. + * @hide + */ + public static final int CAPABILITY_TRANSFER_CONSULTATIVE = 0x10000000; + //********************************************************************************************** - // Next CAPABILITY value: 0x08000000 + // Next CAPABILITY value: 0x20000000 //********************************************************************************************** /** @@ -967,6 +984,13 @@ public abstract class Connection extends Conferenceable { if ((capabilities & CAPABILITY_ADD_PARTICIPANT) == CAPABILITY_ADD_PARTICIPANT) { builder.append(isLong ? " CAPABILITY_ADD_PARTICIPANT" : " add_participant"); } + if ((capabilities & CAPABILITY_TRANSFER) == CAPABILITY_TRANSFER) { + builder.append(isLong ? " CAPABILITY_TRANSFER" : " sup_trans"); + } + if ((capabilities & CAPABILITY_TRANSFER_CONSULTATIVE) + == CAPABILITY_TRANSFER_CONSULTATIVE) { + builder.append(isLong ? " CAPABILITY_TRANSFER_CONSULTATIVE" : " sup_cTrans"); + } builder.append("]"); return builder.toString(); } @@ -3091,6 +3115,26 @@ public abstract class Connection extends Conferenceable { */ public void onReject(String replyMessage) {} + /** + * Notifies this Connection, a request to transfer to a target number. + * @param number the number to transfer this {@link Connection} to. + * @param isConfirmationRequired when {@code true}, the {@link ConnectionService} + * should wait until the transfer has successfully completed before disconnecting + * the current {@link Connection}. + * When {@code false}, the {@link ConnectionService} should signal the network to + * perform the transfer, but should immediately disconnect the call regardless of + * the outcome of the transfer. + * @hide + */ + public void onTransfer(@NonNull Uri number, boolean isConfirmationRequired) {} + + /** + * Notifies this Connection, a request to transfer to another Connection. + * @param otherConnection the {@link Connection} to transfer this call to. + * @hide + */ + public void onTransfer(@NonNull Connection otherConnection) {} + /** * Notifies this Connection of a request to silence the ringer. *

diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java old mode 100644 new mode 100755 index 2aea723cf418..0dca006f37c0 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -128,6 +128,8 @@ public abstract class ConnectionService extends Service { private static final String SESSION_ANSWER = "CS.an"; private static final String SESSION_ANSWER_VIDEO = "CS.anV"; private static final String SESSION_DEFLECT = "CS.def"; + private static final String SESSION_TRANSFER = "CS.trans"; + private static final String SESSION_CONSULTATIVE_TRANSFER = "CS.cTrans"; private static final String SESSION_REJECT = "CS.r"; private static final String SESSION_REJECT_MESSAGE = "CS.rWM"; private static final String SESSION_SILENCE = "CS.s"; @@ -196,6 +198,8 @@ public abstract class ConnectionService extends Service { private static final int MSG_CREATE_CONFERENCE_FAILED = 37; private static final int MSG_REJECT_WITH_REASON = 38; private static final int MSG_ADD_PARTICIPANT = 39; + private static final int MSG_EXPLICIT_CALL_TRANSFER = 40; + private static final int MSG_EXPLICIT_CALL_TRANSFER_CONSULTATIVE = 41; private static Connection sNullConnection; @@ -480,6 +484,38 @@ public abstract class ConnectionService extends Service { } } + @Override + public void transfer(@NonNull String callId, @NonNull Uri number, + boolean isConfirmationRequired, Session.Info sessionInfo) { + Log.startSession(sessionInfo, SESSION_TRANSFER); + try { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = number; + args.argi1 = isConfirmationRequired ? 1 : 0; + args.arg3 = Log.createSubsession(); + mHandler.obtainMessage(MSG_EXPLICIT_CALL_TRANSFER, args).sendToTarget(); + } finally { + Log.endSession(); + } + } + + @Override + public void consultativeTransfer(@NonNull String callId, @NonNull String otherCallId, + Session.Info sessionInfo) { + Log.startSession(sessionInfo, SESSION_CONSULTATIVE_TRANSFER); + try { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = otherCallId; + args.arg3 = Log.createSubsession(); + mHandler.obtainMessage( + MSG_EXPLICIT_CALL_TRANSFER_CONSULTATIVE, args).sendToTarget(); + } finally { + Log.endSession(); + } + } + @Override public void silence(String callId, Session.Info sessionInfo) { Log.startSession(sessionInfo, SESSION_SILENCE); @@ -1108,6 +1144,30 @@ public abstract class ConnectionService extends Service { } break; } + case MSG_EXPLICIT_CALL_TRANSFER: { + SomeArgs args = (SomeArgs) msg.obj; + Log.continueSession((Session) args.arg3, SESSION_HANDLER + SESSION_TRANSFER); + try { + final boolean isConfirmationRequired = args.argi1 == 1; + transfer((String) args.arg1, (Uri) args.arg2, isConfirmationRequired); + } finally { + args.recycle(); + Log.endSession(); + } + break; + } + case MSG_EXPLICIT_CALL_TRANSFER_CONSULTATIVE: { + SomeArgs args = (SomeArgs) msg.obj; + Log.continueSession( + (Session) args.arg3, SESSION_HANDLER + SESSION_CONSULTATIVE_TRANSFER); + try { + consultativeTransfer((String) args.arg1, (String) args.arg2); + } finally { + args.recycle(); + Log.endSession(); + } + break; + } case MSG_DISCONNECT: { SomeArgs args = (SomeArgs) msg.obj; Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_DISCONNECT); @@ -2042,6 +2102,18 @@ public abstract class ConnectionService extends Service { findConnectionForAction(callId, "reject").onReject(rejectReason); } + private void transfer(String callId, Uri number, boolean isConfirmationRequired) { + Log.d(this, "transfer %s", callId); + findConnectionForAction(callId, "transfer").onTransfer(number, isConfirmationRequired); + } + + private void consultativeTransfer(String callId, String otherCallId) { + Log.d(this, "consultativeTransfer %s", callId); + Connection connection1 = findConnectionForAction(callId, "consultativeTransfer"); + Connection connection2 = findConnectionForAction(otherCallId, " consultativeTransfer"); + connection1.onTransfer(connection2); + } + private void silence(String callId) { Log.d(this, "silence %s", callId); findConnectionForAction(callId, "silence").onSilence(); diff --git a/telecomm/java/android/telecom/InCallAdapter.java b/telecomm/java/android/telecom/InCallAdapter.java old mode 100644 new mode 100755 index 9d29174059ad..dd6c15311651 --- a/telecomm/java/android/telecom/InCallAdapter.java +++ b/telecomm/java/android/telecom/InCallAdapter.java @@ -16,6 +16,7 @@ package android.telecom; +import android.annotation.NonNull; import android.bluetooth.BluetoothDevice; import android.net.Uri; import android.os.Bundle; @@ -101,6 +102,35 @@ public final class InCallAdapter { } } + /** + * Instructs Telecom to transfer the specified call. + * + * @param callId The identifier of the call to transfer. + * @param targetNumber The address to transfer to. + * @param isConfirmationRequired if {@code true} it will initiate ASSURED transfer, + * if {@code false}, it will initiate BLIND transfer. + */ + public void transferCall(@NonNull String callId, @NonNull Uri targetNumber, + boolean isConfirmationRequired) { + try { + mAdapter.transferCall(callId, targetNumber, isConfirmationRequired); + } catch (RemoteException e) { + } + } + + /** + * Instructs Telecom to transfer the specified call to another ongoing call. + * + * @param callId The identifier of the call to transfer. + * @param otherCallId The identifier of the other call to which this will be transferred. + */ + public void transferCall(@NonNull String callId, @NonNull String otherCallId) { + try { + mAdapter.consultativeTransfer(callId, otherCallId); + } catch (RemoteException e) { + } + } + /** * Instructs Telecom to disconnect the specified call. * diff --git a/telecomm/java/com/android/internal/telecom/IConnectionService.aidl b/telecomm/java/com/android/internal/telecom/IConnectionService.aidl index a397d77db2f6..fb5417994b57 100644 --- a/telecomm/java/com/android/internal/telecom/IConnectionService.aidl +++ b/telecomm/java/com/android/internal/telecom/IConnectionService.aidl @@ -81,6 +81,11 @@ oneway interface IConnectionService { void rejectWithMessage(String callId, String message, in Session.Info sessionInfo); + void transfer(String callId, in Uri number, boolean isConfirmationRequired, + in Session.Info sessionInfo); + + void consultativeTransfer(String callId, String otherCallId, in Session.Info sessionInfo); + void disconnect(String callId, in Session.Info sessionInfo); void silence(String callId, in Session.Info sessionInfo); diff --git a/telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl b/telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl old mode 100644 new mode 100755 index 9beff22ce52e..edf1cf4cdb18 --- a/telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl +++ b/telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl @@ -36,6 +36,10 @@ oneway interface IInCallAdapter { void rejectCallWithReason(String callId, int rejectReason); + void transferCall(String callId, in Uri targetNumber, boolean isConfirmationRequired); + + void consultativeTransfer(String callId, String otherCallId); + void disconnectCall(String callId); void holdCall(String callId); -- cgit v1.2.3-59-g8ed1b