Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 129308a6 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "IMS: Explicit Call transfer APIS." am: 9f28d84c

Change-Id: Iacf9706643fc2bd0183bcca12f4bff17551ba034
parents 1b2f0987 9f28d84c
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -2305,6 +2305,45 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        }
    }

    /**
     * Transfers the call if it is active or held.
     *
     * @param number number to be transferred to.
     * @param isConfirmationRequired whether for blind or assured transfer.
     */
    @VisibleForTesting
    public void transfer(Uri number, boolean isConfirmationRequired) {
        if (mState == CallState.ACTIVE || mState == CallState.ON_HOLD) {
            if (mConnectionService != null) {
                mConnectionService.transfer(this, number, isConfirmationRequired);
            } else {
                Log.e(this, new NullPointerException(),
                        "transfer call failed due to null CS callId=%s", getId());
            }
            Log.addEvent(this, LogUtils.Events.REQUEST_TRANSFER, Log.pii(number));
        }
    }

    /**
     * Transfers the call when this call is active and the other call is held.
     * This is for Consultative call transfer.
     *
     * @param otherCall The other {@link Call} to which this call will be transferred.
     */
    @VisibleForTesting
    public void transfer(Call otherCall) {
        if (mState == CallState.ACTIVE &&
                (otherCall != null && otherCall.getState() == CallState.ON_HOLD)) {
            if (mConnectionService != null) {
                mConnectionService.transfer(this, otherCall);
            } else {
                Log.e(this, new NullPointerException(),
                        "transfer call failed due to null CS callId=%s", getId());
            }
            Log.addEvent(this, LogUtils.Events.REQUEST_CONSULTATIVE_TRANSFER, otherCall);
        }
    }

    /**
     * Puts the call on hold if it is currently active.
     */
+26 −0
Original line number Diff line number Diff line
@@ -2381,6 +2381,32 @@ public class CallsManager extends Call.ListenerBase
        }
    }

    /**
     * Instructs Telecom to transfer the specified call. Intended to be invoked by the in-call
     * app through {@link InCallAdapter} after the user opts to transfer the said call.
     */
    @VisibleForTesting
    public void transferCall(Call call, Uri number, boolean isConfirmationRequired) {
        if (!mCalls.contains(call)) {
            Log.i(this, "transferCall - Request to transfer a non-existent call %s", call);
        } else {
            call.transfer(number, isConfirmationRequired);
        }
    }

    /**
     * Instructs Telecom to transfer the specified call to another ongoing call.
     * Intended to be invoked by the in-call app through {@link InCallAdapter} after the user opts
     * to transfer the said call (consultative transfer).
     */
    @VisibleForTesting
    public void transferCall(Call call, Call otherCall) {
        if (!mCalls.contains(call) || !mCalls.contains(otherCall)) {
            Log.i(this, "transferCall - Non-existent call %s or %s", call, otherCall);
        } else {
            call.transfer(otherCall);
        }
    }

    /**
     * Instructs Telecom to play the specified DTMF tone within the specified call.
+27 −0
Original line number Diff line number Diff line
@@ -1614,6 +1614,33 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        }
    }

    /** @see IConnectionService#transfer(String, Uri , boolean, Session.Info) */
    void transfer(Call call, Uri number, boolean isConfirmationRequired) {
        final String callId = mCallIdMapper.getCallId(call);
        if (callId != null && isServiceValid("transfer")) {
            try {
                logOutgoing("transfer %s", callId);
                mServiceInterface.transfer(callId, number, isConfirmationRequired,
                        Log.getExternalSession());
            } catch (RemoteException e) {
            }
        }
    }

    /** @see IConnectionService#consultativeTransfer(String, String, Session.Info) */
    void transfer(Call call, Call otherCall) {
        final String callId = mCallIdMapper.getCallId(call);
        final String otherCallId = mCallIdMapper.getCallId(otherCall);
        if (callId != null && otherCallId != null && isServiceValid("consultativeTransfer")) {
            try {
                logOutgoing("consultativeTransfer %s", callId);
                mServiceInterface.consultativeTransfer(callId, otherCallId,
                        Log.getExternalSession());
            } catch (RemoteException e) {
            }
        }
    }

    /** @see IConnectionService#playDtmfTone(String, char, Session.Info) */
    void playDtmfTone(Call call, char digit) {
        final String callId = mCallIdMapper.getCallId(call);
+48 −0
Original line number Diff line number Diff line
@@ -151,6 +151,54 @@ class InCallAdapter extends IInCallAdapter.Stub {
        }
    }

    public void transferCall(String callId, Uri targetNumber, boolean isConfirmationRequired) {
        try {
            Log.startSession(LogUtils.Sessions.ICA_TRANSFER_CALL, mOwnerPackageName);
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    Log.i(this, "transferCall - %s, %s, %b", callId, Log.pii(targetNumber),
                            isConfirmationRequired);
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        mCallsManager.transferCall(call, targetNumber, isConfirmationRequired);
                    } else {
                        Log.w(this, "transferCall, unknown call id: %s", callId);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        } finally {
            Log.endSession();
        }
    }

    @Override
    public void consultativeTransfer(String callId, String otherCallId) {
        try {
            Log.startSession(LogUtils.Sessions.ICA_CONSULTATIVE_TRANSFER, mOwnerPackageName);
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    Log.i(this, "consultativeTransfer - %s, %s", callId, otherCallId);
                    Call call = mCallIdMapper.getCall(callId);
                    Call otherCall = mCallIdMapper.getCall(otherCallId);
                    if (call != null && otherCall != null) {
                        mCallsManager.transferCall(call, otherCall);
                    } else {
                        Log.w(this, "consultativeTransfer, unknown call id: %s or %s",
                                callId, otherCallId);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        } finally {
            Log.endSession();
        }
    }

    @Override
    public void playDtmfTone(String callId, char digit) {
        try {
+4 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ public class LogUtils {
        public static final String ICA_ANSWER_CALL = "ICA.aC";
        public static final String ICA_DEFLECT_CALL = "ICA.defC";
        public static final String ICA_REJECT_CALL = "ICA.rC";
        public static final String ICA_TRANSFER_CALL = "ICA.tC";
        public static final String ICA_CONSULTATIVE_TRANSFER = "ICA.cT";
        public static final String ICA_DISCONNECT_CALL = "ICA.dC";
        public static final String ICA_HOLD_CALL = "ICA.hC";
        public static final String ICA_UNHOLD_CALL = "ICA.uC";
@@ -108,6 +110,8 @@ public class LogUtils {
                "REQUEST_PICKUP_FOR_AUDIO_PROCESSING";
        public static final String REQUEST_DEFLECT = "REQUEST_DEFLECT";
        public static final String REQUEST_REJECT = "REQUEST_REJECT";
        public static final String REQUEST_TRANSFER = "REQUEST_TRANSFER";
        public static final String REQUEST_CONSULTATIVE_TRANSFER = "REQUEST_CONSULTATIVE_TRANSFER";
        public static final String START_DTMF = "START_DTMF";
        public static final String STOP_DTMF = "STOP_DTMF";
        public static final String START_RINGER = "START_RINGER";
Loading