use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.
the class ImsPhoneCallTracker method canAddVideoCallDuringImsAudioCall.
private boolean canAddVideoCallDuringImsAudioCall(int videoState) {
if (mAllowHoldingVideoCall) {
return true;
}
ImsCall call = mForegroundCall.getImsCall();
if (call == null) {
call = mBackgroundCall.getImsCall();
}
boolean isImsAudioCallActiveOrHolding = (mForegroundCall.getState() == Call.State.ACTIVE || mBackgroundCall.getState() == Call.State.HOLDING) && call != null && !call.isVideoCall();
/* return TRUE if there doesn't exist ims audio call in either active
or hold states */
return !isImsAudioCallActiveOrHolding || !VideoProfile.isVideo(videoState);
}
use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.
the class ImsPhoneCallTracker method downgradeVideoCall.
/**
* Handles downgrading a video call. The behavior depends on carrier capabilities; we will
* attempt to take one of the following actions (in order of precedence):
* 1. If supported by the carrier, the call will be downgraded to an audio-only call.
* 2. If the carrier supports video pause signalling, the video will be paused.
* 3. The call will be disconnected.
* @param reasonCode The {@link ImsReasonInfo} reason code for the downgrade.
* @param conn The {@link ImsPhoneConnection} to downgrade.
*/
private void downgradeVideoCall(int reasonCode, ImsPhoneConnection conn) {
ImsCall imsCall = conn.getImsCall();
if (imsCall != null) {
if (conn.hasCapabilities(Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL | Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE) && !mSupportPauseVideo) {
log("downgradeVideoCall :: callId=" + conn.getTelecomCallId() + " Downgrade to audio");
// If the carrier supports downgrading to voice, then we can simply issue a
// downgrade to voice instead of terminating the call.
modifyVideoCall(imsCall, VideoProfile.STATE_AUDIO_ONLY);
} else if (mSupportPauseVideo && reasonCode != ImsReasonInfo.CODE_WIFI_LOST) {
// The carrier supports video pause signalling, so pause the video if we didn't just
// lose wifi; in that case just disconnect.
log("downgradeVideoCall :: callId=" + conn.getTelecomCallId() + " Pause audio");
mShouldUpdateImsConfigOnDisconnect = true;
conn.pauseVideo(VideoPauseTracker.SOURCE_DATA_ENABLED);
} else {
log("downgradeVideoCall :: callId=" + conn.getTelecomCallId() + " Disconnect call.");
// At this point the only choice we have is to terminate the call.
imsCall.terminate(ImsReasonInfo.CODE_USER_TERMINATED, reasonCode);
}
}
}
use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.
the class ImsPhoneCallTracker method hangup.
public void hangup(ImsPhoneCall call, @android.telecom.Call.RejectReason int rejectReason) throws CallStateException {
if (DBG)
log("hangup call - reason=" + rejectReason);
if (call.getConnectionsCount() == 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 if (call == mHandoverCall) {
if (Phone.DEBUG_PHONE) {
log("(handover) hangup handover (SRVCC) call");
}
} else {
throw new CallStateException("ImsPhoneCall " + call + "does not belong to ImsPhoneCallTracker " + this);
}
call.onHangupLocal();
try {
if (imsCall != null) {
if (rejectCall) {
if (rejectReason == android.telecom.Call.REJECT_REASON_UNWANTED) {
imsCall.reject(ImsReasonInfo.CODE_SIP_USER_MARKED_UNWANTED);
} else {
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 ImsPhoneCallTracker method handleDataEnabledChange.
/**
* Handles changes to the enabled state of mobile data.
* When data is disabled, handles auto-downgrade of video calls over LTE.
* When data is enabled, handled resuming of video calls paused when data was disabled.
* @param enabled {@code true} if mobile data is enabled, {@code false} if mobile data is
* disabled.
* @param reasonCode The {@link ImsReasonInfo} code for the data enabled state change.
*/
private void handleDataEnabledChange(boolean enabled, int reasonCode) {
if (!enabled) {
// data charges.
for (ImsPhoneConnection conn : mConnections) {
ImsCall imsCall = conn.getImsCall();
if (imsCall != null && imsCall.isVideoCall() && !imsCall.isWifiCall()) {
log("handleDataEnabledChange - downgrading " + conn);
downgradeVideoCall(reasonCode, conn);
}
}
} else if (mSupportPauseVideo) {
// Data was re-enabled, so un-pause previously paused video calls.
for (ImsPhoneConnection conn : mConnections) {
// If video is paused, check to see if there are any pending pauses due to enabled
// state of data changing.
log("handleDataEnabledChange - resuming " + conn);
if (VideoProfile.isPaused(conn.getVideoState()) && conn.wasVideoPausedFromSource(VideoPauseTracker.SOURCE_DATA_ENABLED)) {
// The data enabled state was a cause of a pending pause, so potentially
// resume the video now.
conn.resumeVideo(VideoPauseTracker.SOURCE_DATA_ENABLED);
}
}
mShouldUpdateImsConfigOnDisconnect = false;
}
}
use of com.android.ims.ImsCall in project android_frameworks_opt_telephony by LineageOS.
the class ImsPhoneCallTracker method sendCallStartFailedDisconnect.
public void sendCallStartFailedDisconnect(ImsCall imsCall, ImsReasonInfo reasonInfo) {
mPendingMO = null;
ImsPhoneConnection conn = findConnection(imsCall);
Call.State callState;
if (conn != null) {
callState = conn.getState();
} else {
// Need to fall back in case connection is null; it shouldn't be, but a sane
// fallback is to assume we're dialing. This state is only used to
// determine which disconnect string to show in the case of a low battery
// disconnect.
callState = Call.State.DIALING;
}
int cause = getDisconnectCauseFromReasonInfo(reasonInfo, callState);
processCallStateChange(imsCall, ImsPhoneCall.State.DISCONNECTED, cause);
if (conn != null) {
conn.setPreciseDisconnectCause(getPreciseDisconnectCauseFromReasonInfo(reasonInfo));
}
mPhone.notifyImsReason(reasonInfo);
}
Aggregations