Search in sources :

Example 26 with ImsCall

use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTracker method resumeWaitingOrHolding.

/* package */
void resumeWaitingOrHolding() throws CallStateException {
    if (DBG)
        log("resumeWaitingOrHolding");
    try {
        if (mForegroundCall.getState().isAlive()) {
            // resume foreground call after holding background call
            // they were switched before holding
            ImsCall imsCall = mForegroundCall.getImsCall();
            if (imsCall != null) {
                imsCall.resume();
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_RESUME);
            }
        } else if (mRingingCall.getState() == ImsPhoneCall.State.WAITING) {
            // accept waiting call after holding background call
            ImsCall imsCall = mRingingCall.getImsCall();
            if (imsCall != null) {
                imsCall.accept(ImsCallProfile.getCallTypeFromVideoState(mPendingCallVideoState));
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_ACCEPT);
            }
        } else {
            // Just resume background call.
            // To distinguish resuming call with swapping calls
            // we do not switch calls.here
            // ImsPhoneConnection.update will chnage the parent when completed
            ImsCall imsCall = mBackgroundCall.getImsCall();
            if (imsCall != null) {
                imsCall.resume();
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_RESUME);
            }
        }
    } catch (ImsException e) {
        throw new CallStateException(e.getMessage());
    }
}
Also used : CallStateException(com.android.internal.telephony.CallStateException) ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException)

Example 27 with ImsCall

use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTracker method hangup.

// ***** Called from ImsPhoneCall
public void hangup(ImsPhoneCall call) throws CallStateException {
    if (DBG)
        log("hangup call");
    if (call.getConnections().size() == 0) {
        throw new CallStateException("no connections");
    }
    ImsCall imsCall = call.getImsCall();
    boolean rejectCall = false;
    if (call == mRingingCall) {
        if (Phone.DEBUG_PHONE)
            log("(ringing) hangup incoming");
        rejectCall = true;
    } else if (call == mForegroundCall) {
        if (call.isDialingOrAlerting()) {
            if (Phone.DEBUG_PHONE) {
                log("(foregnd) hangup dialing or alerting...");
            }
        } else {
            if (Phone.DEBUG_PHONE) {
                log("(foregnd) hangup foreground");
            }
        // held call will be resumed by onCallTerminated
        }
    } else if (call == mBackgroundCall) {
        if (Phone.DEBUG_PHONE) {
            log("(backgnd) hangup waiting or background");
        }
    } else {
        throw new CallStateException("ImsPhoneCall " + call + "does not belong to ImsPhoneCallTracker " + this);
    }
    call.onHangupLocal();
    try {
        if (imsCall != null) {
            if (rejectCall) {
                imsCall.reject(ImsReasonInfo.CODE_USER_DECLINE);
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_REJECT);
            } else {
                imsCall.terminate(ImsReasonInfo.CODE_USER_TERMINATED);
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_TERMINATE);
            }
        } else if (mPendingMO != null && call == mForegroundCall) {
            // is holding a foreground call
            mPendingMO.update(null, ImsPhoneCall.State.DISCONNECTED);
            mPendingMO.onDisconnect();
            removeConnection(mPendingMO);
            mPendingMO = null;
            updatePhoneState();
            removeMessages(EVENT_DIAL_PENDINGMO);
        }
    } catch (ImsException e) {
        throw new CallStateException(e.getMessage());
    }
    mPhone.notifyPreciseCallStateChanged();
}
Also used : CallStateException(com.android.internal.telephony.CallStateException) ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException)

Example 28 with ImsCall

use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneConnection method updateWifiStateFromExtras.

/**
 * Updates the wifi state based on the {@link ImsCallProfile#EXTRA_CALL_RAT_TYPE}.
 * The call is considered to be a WIFI call if the extra value is
 * {@link ServiceState#RIL_RADIO_TECHNOLOGY_IWLAN}.
 *
 * @param extras The ImsCallProfile extras.
 */
private void updateWifiStateFromExtras(Bundle extras) {
    if (extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE) || extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT)) {
        ImsCall call = getImsCall();
        boolean isWifi = false;
        if (call != null) {
            isWifi = call.isWifiCall();
        }
        // Report any changes
        if (isWifi() != isWifi) {
            setWifi(isWifi);
        }
    }
}
Also used : ImsCall(com.android.ims.ImsCall)

Example 29 with ImsCall

use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTrackerTest method placeCallAndMakeActive.

private ImsPhoneConnection placeCallAndMakeActive() {
    try {
        doAnswer(new Answer<ImsCall>() {

            @Override
            public ImsCall answer(InvocationOnMock invocation) throws Throwable {
                mImsCallListener = (ImsCall.Listener) invocation.getArguments()[2];
                ImsCall imsCall = spy(new ImsCall(mContext, mImsCallProfile));
                imsCall.setListener(mImsCallListener);
                imsCallMocking(imsCall);
                return imsCall;
            }
        }).when(mImsManager).makeCall(eq(mImsCallProfile), (String[]) any(), (ImsCall.Listener) any());
    } catch (ImsException ie) {
    }
    ImsPhoneConnection connection = null;
    try {
        connection = (ImsPhoneConnection) mCTUT.dial("+16505551212", ImsCallProfile.CALL_TYPE_VOICE, null);
    } catch (Exception ex) {
        ex.printStackTrace();
        Assert.fail("unexpected exception thrown" + ex.getMessage());
    }
    if (connection == null) {
        Assert.fail("connection is null");
    }
    ImsCall imsCall = connection.getImsCall();
    imsCall.getImsCallSessionListenerProxy().callSessionProgressing(imsCall.getSession(), new ImsStreamMediaProfile());
    imsCall.getImsCallSessionListenerProxy().callSessionStarted(imsCall.getSession(), new ImsCallProfile());
    return connection;
}
Also used : ImsCallProfile(android.telephony.ims.ImsCallProfile) ImsCall(com.android.ims.ImsCall) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ImsStreamMediaProfile(android.telephony.ims.ImsStreamMediaProfile) ImsException(com.android.ims.ImsException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ImsException(com.android.ims.ImsException) RemoteException(android.os.RemoteException) CallStateException(com.android.internal.telephony.CallStateException)

Example 30 with ImsCall

use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTest method testGetImsCall.

@Test
@SmallTest
public void testGetImsCall() {
    doReturn(mImsCall).when(mConnection1).getImsCall();
    mImsCallUT.attach(mConnection1, Call.State.ACTIVE);
    ImsCall imsCall = mImsCallUT.getImsCall();
    assertEquals(mImsCall, imsCall);
}
Also used : ImsCall(com.android.ims.ImsCall) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ImsCall (com.android.ims.ImsCall)48 ImsException (com.android.ims.ImsException)19 SmallTest (android.test.suitebuilder.annotation.SmallTest)16 CallStateException (com.android.internal.telephony.CallStateException)16 TelephonyTest (com.android.internal.telephony.TelephonyTest)16 Test (org.junit.Test)16 ImsCallProfile (android.telephony.ims.ImsCallProfile)8 FlakyTest (androidx.test.filters.FlakyTest)8 RemoteException (android.os.RemoteException)6 Connection (com.android.internal.telephony.Connection)5 ImsPhoneCall (com.android.internal.telephony.imsphone.ImsPhoneCall)5 ImsPhone (com.android.internal.telephony.imsphone.ImsPhone)4 ImsReasonInfo (android.telephony.ims.ImsReasonInfo)3 ImsMultiEndpoint (com.android.ims.ImsMultiEndpoint)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Bundle (android.os.Bundle)2 PersistableBundle (android.os.PersistableBundle)2 TestConferenceEventPackageParser (com.android.internal.telephony.test.TestConferenceEventPackageParser)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2