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

Commit f095fd81 authored by Pooja Jain's avatar Pooja Jain Committed by android-build-merger
Browse files

IMS: Add support for call deflection feature am: ad4ebc02

am: 6744e120

Change-Id: I5178d9c9a125119a514bf7c4097af4a04530eb76
parents 585847cc 6744e120
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -1755,6 +1755,31 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        }
    }

    /**
     * Deflects the call if it is ringing.
     *
     * @param address address to be deflected to.
     */
    @VisibleForTesting
    public void deflect(Uri address) {
        // Check to verify that the call is still in the ringing state. A call can change states
        // between the time the user hits 'deflect' and Telecomm receives the command.
        if (isRinging("deflect")) {
            // At this point, we are asking the connection service to deflect but we don't assume
            // that it will work. Instead, we wait until confirmation from the connection service
            // that the call is in a non-STATE_RINGING state before changing the UI. See
            // {@link ConnectionServiceAdapter#setActive} and other set* methods.
            mVideoStateHistory |= mVideoState;
            if (mConnectionService != null) {
                mConnectionService.deflect(this, address);
            } else {
                Log.e(this, new NullPointerException(),
                        "deflect call failed due to null CS callId=%s", getId());
            }
            Log.addEvent(this, LogUtils.Events.REQUEST_DEFLECT, Log.pii(address));
        }
    }

    /**
     * Rejects the call if it is ringing.
     *
+14 −0
Original line number Diff line number Diff line
@@ -1439,6 +1439,20 @@ public class CallsManager extends Call.ListenerBase
        }
    }

    /**
     * Instructs Telecom to deflect the specified call. Intended to be invoked by the in-call
     * app through {@link InCallAdapter} after Telecom notifies it of an incoming call followed by
     * the user opting to deflect said call.
     */
    @VisibleForTesting
    public void deflectCall(Call call, Uri address) {
        if (!mCalls.contains(call)) {
            Log.i(this, "Request to deflect a non-existent call %s", call);
        } else {
            call.deflect(address);
        }
    }

    /**
     * Determines if the speakerphone should be automatically enabled for the call.  Speakerphone
     * should be enabled if the call is a video call and bluetooth or the wired headset are not in
+12 −0
Original line number Diff line number Diff line
@@ -1229,6 +1229,18 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        }
    }

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

    /** @see IConnectionService#reject(String, Session.Info) */
    void reject(Call call, boolean rejectWithMessage, String message) {
        final String callId = mCallIdMapper.getCallId(call);
+24 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.telecom;

import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.telecom.Log;
@@ -68,6 +69,29 @@ class InCallAdapter extends IInCallAdapter.Stub {
        }
    }

    @Override
    public void deflectCall(String callId, Uri address) {
        try {
            Log.startSession(LogUtils.Sessions.ICA_DEFLECT_CALL, mOwnerComponentName);
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    Log.i(this, "deflectCall - %s, %s ", callId, Log.pii(address));
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        mCallsManager.deflectCall(call, address);
                    } else {
                        Log.w(this, "deflectCall, unknown call id: %s", callId);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        } finally {
            Log.endSession();
        }
    }

    @Override
    public void rejectCall(String callId, boolean rejectWithMessage, String textMessage) {
        try {
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ public class LogUtils {

    public static final class Sessions {
        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_DISCONNECT_CALL = "ICA.dC";
        public static final String ICA_HOLD_CALL = "ICA.hC";
@@ -71,6 +72,7 @@ public class LogUtils {
        public static final String REQUEST_UNHOLD = "REQUEST_UNHOLD";
        public static final String REQUEST_DISCONNECT = "REQUEST_DISCONNECT";
        public static final String REQUEST_ACCEPT = "REQUEST_ACCEPT";
        public static final String REQUEST_DEFLECT = "REQUEST_DEFLECT";
        public static final String REQUEST_REJECT = "REQUEST_REJECT";
        public static final String START_DTMF = "START_DTMF";
        public static final String STOP_DTMF = "STOP_DTMF";
Loading