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

Commit 93da8529 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Wire up IMS framework APIs and call pull.

1. Wired up the IMS framework APIs so that the modem can inform us of new
dialog event package changes.
2. Wired up the call pull API so that calls to it make it down to an
ImsExternalConnection.
3. In ImsExternalCallTracker, listen to the call pull requests on the
external connections, and use this to trigger the actual pull of the call,
which is essentially a dial with an extra specified (per QCOM).
I abstracted away the idea of pulling the call using the ImsPullCall
interface, which ImsPhoneCallTracker implements.

Bug: 27458894
Change-Id: Idd20a95c2993b29dcd0a7e6c71fb6232cff88736
parent b3a89f53
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -849,6 +849,13 @@ public abstract class Connection {
    public void onDisconnectConferenceParticipant(Uri endpoint) {
    }

    /**
     * Called by a {@link android.telecom.Connection} to indicate that this call should be pulled
     * to the local device.
     */
    public void pullExternalCall() {
    }

    /**
     *
     */
+5 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.imsphone.ImsPullCall;
import com.android.internal.telephony.uicc.IccCardProxy;

/**
@@ -117,8 +118,10 @@ public class TelephonyComponentFactory {
        return new ImsPhoneCallTracker(imsPhone);
    }

    public ImsExternalCallTracker makeImsExternalCallTracker(ImsPhone imsPhone) {
        return new ImsExternalCallTracker(imsPhone);
    public ImsExternalCallTracker makeImsExternalCallTracker(ImsPhone imsPhone,
            ImsPullCall callPuller) {

        return new ImsExternalCallTracker(imsPhone, callPuller);
    }

    public CdmaSubscriptionSourceManager
+47 −5
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package com.android.internal.telephony.imsphone;

import com.android.ims.ImsCallProfile;
import com.android.ims.ImsExternalCallState;
import com.android.ims.ImsExternalCallStateListener;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.Phone;
@@ -36,6 +38,28 @@ import java.util.Map;
 */
public class ImsExternalCallTracker {

    /**
     * Implements the {@link ImsExternalCallStateListener}, which is responsible for receiving
     * external call state updates from the IMS framework.
     */
    public class ExternalCallStateListener extends ImsExternalCallStateListener {
        @Override
        public void onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallState) {
            refreshExternalCallState(externalCallState);
        }
    }

    /**
     * Receives callbacks from {@link ImsExternalConnection}s when a call pull has been initiated.
     */
    public class ExternalConnectionListener implements ImsExternalConnection.Listener {
        @Override
        public void onPullExternalCall(ImsExternalConnection connection) {
            Log.d(TAG, "onPullExternalCall: connection = " + connection);
            mCallPuller.pullExternalCall(connection.getAddress(), connection.getVideoState());
        }
    }

    public final static String TAG = "ImsExternalCallTracker";

    /**
@@ -54,12 +78,21 @@ public class ImsExternalCallTracker {
     * Used in multi-endpoint (VoLTE for internet connected endpoints) scenarios.
     */
    private Map<Integer, ImsExternalConnection> mExternalConnections =
            new ArrayMap<Integer, ImsExternalConnection>();

    private ImsPhone mPhone;

    public ImsExternalCallTracker(ImsPhone phone) {
            new ArrayMap<>();
    private final ImsPhone mPhone;
    private final ExternalCallStateListener mExternalCallStateListener;
    private final ExternalConnectionListener mExternalConnectionListener =
            new ExternalConnectionListener();
    private final ImsPullCall mCallPuller;

    public ImsExternalCallTracker(ImsPhone phone, ImsPullCall callPuller) {
        mPhone = phone;
        mExternalCallStateListener = new ExternalCallStateListener();
        mCallPuller = callPuller;
    }

    public ExternalCallStateListener getExternalCallStateListener() {
        return mExternalCallStateListener;
    }

    /**
@@ -85,6 +118,7 @@ public class ImsExternalCallTracker {
            if (!containsCallId(externalCallStates, callId)) {
                ImsExternalConnection externalConnection = entry.getValue();
                externalConnection.setTerminated();
                externalConnection.removeListener(mExternalConnectionListener);
                connectionIterator.remove();
                wasCallRemoved = true;
            }
@@ -136,6 +170,8 @@ public class ImsExternalCallTracker {
                state.getCallId(), /* Dialog event package call id */
                state.getAddress().getSchemeSpecificPart() /* phone number */,
                state.isCallPullable());
        connection.setVideoState(ImsCallProfile.getVideoStateFromCallType(state.getCallType()));
        connection.addListener(mExternalConnectionListener);

        // Add to list of tracked connections.
        mExternalConnections.put(connection.getCallId(), connection);
@@ -165,12 +201,18 @@ public class ImsExternalCallTracker {
                connection.setActive();
            } else {
                connection.setTerminated();
                connection.removeListener(mExternalConnectionListener);
                mExternalConnections.remove(connection);
                mPhone.notifyPreciseCallStateChanged();
            }
        }

        connection.setIsPullable(state.isCallPullable());

        int newVideoState = ImsCallProfile.getVideoStateFromCallType(state.getCallType());
        if (newVideoState != connection.getVideoState()) {
            connection.setVideoState(newVideoState);
        }
    }

    /**
+41 −0
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ import com.android.internal.telephony.UUSInfo;
import android.telephony.Rlog;
import android.util.Log;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Represents an IMS call external to the device.  This class is used to represent a call which
 * takes places on a secondary device associated with this one.  Originates from a Dialog Event
@@ -33,9 +38,23 @@ import android.util.Log;
 *
 * Dialog event package information is received from the IMS framework via
 * {@link com.android.ims.ImsExternalCallState} instances.
 *
 * @hide
 */
public class ImsExternalConnection extends Connection {

    public interface Listener {
        void onPullExternalCall(ImsExternalConnection connection);
    }

    /**
     * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
     * load factor before resizing, 1 means we only expect a single thread to
     * access the map so make only a single shard
     */
    private final Set<Listener> mListeners = Collections.newSetFromMap(
            new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));

    /**
     * The unqiue dialog event package specified ID associated with this external connection.
     */
@@ -135,6 +154,20 @@ public class ImsExternalConnection extends Connection {
        return false;
    }

    /**
     * Called by a {@link android.telecom.Connection} to indicate that this call should be pulled
     * to the local device.
     *
     * Informs all listeners, in this case {@link ImsExternalCallTracker}, of the request to pull
     * the call.
     */
    @Override
    public void pullExternalCall() {
        for (Listener listener : mListeners) {
            listener.onPullExternalCall(this);
        }
    }

    /**
     * Sets this external call as active.
     */
@@ -166,6 +199,14 @@ public class ImsExternalConnection extends Connection {
        rebuildCapabilities();
    }

    public void addListener(Listener listener) {
        mListeners.add(listener);
    }

    public void removeListener(Listener listener) {
        mListeners.remove(listener);
    }

    /**
     * Build a human representation of a connection instance, suitable for debugging.
     * Don't log personal stuff unless in debug mode.
+11 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.ims.ImsEcbm;
import com.android.ims.ImsEcbmStateListener;
import com.android.ims.ImsException;
import com.android.ims.ImsManager;
import com.android.ims.ImsMultiEndpoint;
import com.android.ims.ImsReasonInfo;
import com.android.ims.ImsSsInfo;
import com.android.ims.ImsUtInterface;
@@ -125,6 +126,7 @@ public class ImsPhone extends ImsPhoneBase {
    // Instance Variables
    Phone mDefaultPhone;
    ImsPhoneCallTracker mCT;
    ImsMultiEndpoint mImsMultiEndpoint;
    ImsExternalCallTracker mExternalCallTracker;
    private ArrayList <ImsPhoneMmiCode> mPendingMMIs = new ArrayList<ImsPhoneMmiCode>();

@@ -184,7 +186,15 @@ public class ImsPhone extends ImsPhoneBase {
        mDefaultPhone = defaultPhone;
        mCT = TelephonyComponentFactory.getInstance().makeImsPhoneCallTracker(this);
        mExternalCallTracker =
                TelephonyComponentFactory.getInstance().makeImsExternalCallTracker(this);
                TelephonyComponentFactory.getInstance().makeImsExternalCallTracker(this, mCT);
        try {
            mImsMultiEndpoint = mCT.getMultiEndpointInterface();
            mImsMultiEndpoint.setExternalCallStateListener(
                    mExternalCallTracker.getExternalCallStateListener());
        } catch (ImsException e) {
            Rlog.i(LOG_TAG, "ImsMultiEndpointInterface is not available.");
        }

        mSS.setStateOff();

        mPhoneId = mDefaultPhone.getPhoneId();
Loading