Search in sources :

Example 1 with ImsExternalCallState

use of android.telephony.ims.ImsExternalCallState in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyTester method handleTestDialogEventPackageIntent.

/**
 * Handles intents containing test dialog event package data.
 *
 * @param intent
 */
private void handleTestDialogEventPackageIntent(Intent intent) {
    ImsPhone imsPhone = (ImsPhone) mPhone;
    if (imsPhone == null) {
        return;
    }
    ImsExternalCallTracker externalCallTracker = imsPhone.getExternalCallTracker();
    if (externalCallTracker == null) {
        return;
    }
    if (intent.hasExtra(EXTRA_STARTPACKAGE)) {
        mImsExternalCallStates.clear();
    } else if (intent.hasExtra(EXTRA_SENDPACKAGE)) {
        externalCallTracker.refreshExternalCallState(mImsExternalCallStates);
        mImsExternalCallStates.clear();
    } else if (intent.hasExtra(EXTRA_DIALOGID)) {
        ImsExternalCallState state = new ImsExternalCallState(intent.getIntExtra(EXTRA_DIALOGID, 0), Uri.parse(intent.getStringExtra(EXTRA_NUMBER)), intent.getBooleanExtra(EXTRA_CANPULL, true), intent.getIntExtra(EXTRA_STATE, ImsExternalCallState.CALL_STATE_CONFIRMED), ImsCallProfile.CALL_TYPE_VOICE, false);
        mImsExternalCallStates.add(state);
    }
}
Also used : ImsExternalCallTracker(com.android.internal.telephony.imsphone.ImsExternalCallTracker) ImsExternalCallState(android.telephony.ims.ImsExternalCallState) ImsPhone(com.android.internal.telephony.imsphone.ImsPhone)

Example 2 with ImsExternalCallState

use of android.telephony.ims.ImsExternalCallState in project android_frameworks_opt_telephony by LineageOS.

the class ImsExternalCallTracker method refreshExternalCallState.

/**
 * Called when the IMS stack receives a new dialog event package.  Triggers the creation and
 * update of {@link ImsExternalConnection}s to represent the dialogs in the dialog event
 * package data.
 *
 * @param externalCallStates the {@link ImsExternalCallState} information for the dialog event
 *                           package.
 */
public void refreshExternalCallState(List<ImsExternalCallState> externalCallStates) {
    Log.d(TAG, "refreshExternalCallState");
    // Check to see if any call Ids are no longer present in the external call state.  If they
    // are, the calls are terminated and should be removed.
    Iterator<Map.Entry<Integer, ImsExternalConnection>> connectionIterator = mExternalConnections.entrySet().iterator();
    boolean wasCallRemoved = false;
    while (connectionIterator.hasNext()) {
        Map.Entry<Integer, ImsExternalConnection> entry = connectionIterator.next();
        int callId = entry.getKey().intValue();
        if (!containsCallId(externalCallStates, callId)) {
            ImsExternalConnection externalConnection = entry.getValue();
            externalConnection.setTerminated();
            externalConnection.removeListener(mExternalConnectionListener);
            connectionIterator.remove();
            wasCallRemoved = true;
        }
    }
    // TelephonyConnection instancse to refresh their state with Telecom.
    if (wasCallRemoved) {
        mCallStateNotifier.notifyPreciseCallStateChanged();
    }
    // Check for new calls, and updates to existing ones.
    if (externalCallStates != null && !externalCallStates.isEmpty()) {
        for (ImsExternalCallState callState : externalCallStates) {
            if (!mExternalConnections.containsKey(callState.getCallId())) {
                Log.d(TAG, "refreshExternalCallState: got = " + callState);
                // telecom.
                if (callState.getCallState() != ImsExternalCallState.CALL_STATE_CONFIRMED) {
                    continue;
                }
                createExternalConnection(callState);
            } else {
                updateExistingConnection(mExternalConnections.get(callState.getCallId()), callState);
            }
        }
    }
}
Also used : ImsExternalCallState(android.telephony.ims.ImsExternalCallState) Map(java.util.Map) ArrayMap(android.util.ArrayMap)

Example 3 with ImsExternalCallState

use of android.telephony.ims.ImsExternalCallState in project android_frameworks_opt_telephony by LineageOS.

the class ImsExternalCallTrackerTest method testAddExternalCall.

@FlakyTest
@Test
@Ignore
public void testAddExternalCall() {
    List<ImsExternalCallState> dep = new ArrayList<>();
    dep.add(new ImsExternalCallState(CALL_ID, TEST_ADDRESS, false, /* isPullable */
    ImsExternalCallState.CALL_STATE_CONFIRMED, ImsCallProfile.CALL_TYPE_VOICE, false));
    mTracker.refreshExternalCallState(dep);
    ArgumentCaptor<Connection> connectionArgumentCaptor = ArgumentCaptor.forClass(Connection.class);
    verify(mCallNotifier).notifyUnknownConnection(connectionArgumentCaptor.capture());
    Connection connection = connectionArgumentCaptor.getValue();
    assert (connection instanceof ImsExternalConnection);
}
Also used : ArrayList(java.util.ArrayList) Connection(com.android.internal.telephony.Connection) ImsExternalCallState(android.telephony.ims.ImsExternalCallState) FlakyTest(androidx.test.filters.FlakyTest) Ignore(org.junit.Ignore) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Aggregations

ImsExternalCallState (android.telephony.ims.ImsExternalCallState)3 ArrayMap (android.util.ArrayMap)1 FlakyTest (androidx.test.filters.FlakyTest)1 Connection (com.android.internal.telephony.Connection)1 ImsExternalCallTracker (com.android.internal.telephony.imsphone.ImsExternalCallTracker)1 ImsPhone (com.android.internal.telephony.imsphone.ImsPhone)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1