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());
}
}
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();
}
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);
}
}
}
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;
}
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);
}
Aggregations