@Override public void onCallTerminated(ImsCall imsCall, ImsReasonInfo reasonInfo) { if (DBG) log("onCallTerminated reasonCode=" + reasonInfo.getCode()); ImsPhoneCall.State oldState = mForegroundCall.getState(); int cause = getDisconnectCauseFromReasonInfo(reasonInfo); ImsPhoneConnection conn = findConnection(imsCall); if (DBG) log("cause = " + cause + " conn = " + conn); if (conn != null && conn.isIncoming() && conn.getConnectTime() == 0) { // Missed if (cause == DisconnectCause.NORMAL) { cause = DisconnectCause.INCOMING_MISSED; } if (DBG) log("Incoming connection of 0 connect time detected - translated cause = " + cause); } if (cause == DisconnectCause.NORMAL && conn != null && conn.getImsCall().isMerged()) { // Call was terminated while it is merged instead of a remote disconnect. cause = DisconnectCause.IMS_MERGED_SUCCESSFULLY; } processCallStateChange(imsCall, ImsPhoneCall.State.DISCONNECTED, cause); }
private synchronized ImsPhoneConnection findConnection(ImsCall imsCall) { for (ImsPhoneConnection conn : mConnections) { if (conn.getImsCall() == imsCall) { return conn; } } return null; }