Home | History | Annotate | Download | only in phone

Lines Matching refs:Call

34 import com.android.services.telephony.common.Call;
35 import com.android.services.telephony.common.Call.Capabilities;
36 import com.android.services.telephony.common.Call.State;
54 * Creates a Call model from Call state and data received from the telephony
55 * layer. The telephony layer maintains 3 conceptual objects: Phone, Call,
62 * There are 3 Call instances that exist for the lifetime of this class which
66 * A Connection most closely resembles what the layperson would consider a call.
68 * three Call instances. Which of the three Calls owns the Connection changes
71 * This class models a new Call class from Connection objects received from
72 * the telephony layer. We use Connection references as identifiers for a call;
73 * new reference = new call.
75 * TODO: Create a new Call class to replace the simple call Id ints
78 * The new Call models are parcellable for transfer via the CallHandlerService
92 private final HashMap<Connection, Call> mCallMap = Maps.newHashMap();
93 private final HashMap<Connection, Call> mConfCallMap = Maps.newHashMap();
114 // call CallModeler's onNewRingingConnection.
140 public List<Call> getFullList() {
141 final List<Call> calls =
150 for (Entry<Connection, Call> entry : mCallMap.entrySet()) {
156 for (Entry<Connection, Call> entry : mConfCallMap.entrySet()) {
170 // We dont get the traditional onIncomingCall notification for cdma call waiting,
173 final com.android.internal.telephony.Call teleCall =
176 if (teleCall.getState() == com.android.internal.telephony.Call.State.WAITING) {
182 Call call = onNewRingingConnection(connection);
189 Log.e(TAG, "CDMA Call waiting notification without a matching connection.");
193 // Cdma call was rejected...
198 Log.e(TAG, "CDMA Call waiting rejection without an incoming call.");
205 * call.
212 // If we reset the connection, that mean we can now tell the user that the call is actually
213 // part of the conference call and move it out of the dialing state. To do this, issue a
220 private boolean hasLiveCallInternal(HashMap<Connection, Call> map) {
221 for (Call call : map.values()) {
222 final int state = call.getState();
223 if (state == Call.State.ACTIVE ||
224 state == Call.State.CALL_WAITING ||
225 state == Call.State.CONFERENCED ||
226 state == Call.State.DIALING ||
227 state == Call.State.REDIALING ||
228 state == Call.State.INCOMING ||
229 state == Call.State.ONHOLD ||
230 state == Call.State.DISCONNECTING) {
243 HashMap<Connection, Call> map) {
244 for (Call call : map.values()) {
245 final int state = call.getState();
246 if (state == Call.State.ACTIVE || Call.State.isDialing(state)) {
256 * Handles the POST_ON_DIAL_CHARS message from the Phone (see our call to
271 final Call call = getCallFromMap(mCallMap, c, false);
272 if (call == null) {
273 Log.i(TAG, "Call no longer exists. Skipping onPostDialWait().");
276 mListener.onPostDialAction(state, call.getCallId(),
292 /* package */ Call onNewRingingConnection(Connection conn) {
294 final Call call = getCallFromMap(mCallMap, conn, true);
296 if (call != null) {
297 updateCallFromConnection(call, conn, false);
300 mListeners.get(i).onIncoming(call);
305 return call;
310 final Call call = getCallFromMap(mCallMap, conn, false);
312 if (call != null) {
313 final boolean wasConferenced = call.getState() == State.CONFERENCED;
315 updateCallFromConnection(call, conn, false);
318 mListeners.get(i).onDisconnect(call);
321 // If it was a conferenced call, we need to run the entire update
339 final List<Call> updatedCalls = Lists.newArrayList();
354 * either ringing, foreground, or background). For each orphaned call, it sets the call state
360 private void doUpdate(boolean fullUpdate, List<Call> out) {
361 final List<com.android.internal.telephony.Call> telephonyCalls = Lists.newArrayList();
374 // Cycle through all the Connections on all the Calls. Update our Call objects
375 // to reflect any new state and send the updated Call objects to the handler service.
376 for (com.android.internal.telephony.Call telephonyCall : telephonyCalls) {
390 com.android.internal.telephony.Call.State.DISCONNECTED &&
392 com.android.internal.telephony.Call.State.IDLE &&
396 com.android.internal.telephony.Call.State.DISCONNECTING;
399 // not create a new call if the call did not exist.
402 // New connections return a Call with INVALID state, which does not translate to
403 // a state in the internal.telephony.Call object. This ensures that staleness
405 final Call call = getCallFromMap(mCallMap, connection, shouldCreate /* create */);
407 if (call == null || !shouldUpdate) {
412 boolean changed = updateCallFromConnection(call, connection, false);
415 out.add(call);
419 // We do a second loop to address conference call scenarios. We do this as a separate
431 final Call call = mCallMap.get(orphanedConnection);
432 call.setState(Call.State.IDLE);
433 out.add(call);
439 final Call call = mCallMap.get(orphanedConnection);
440 call.setState(Call.State.IDLE);
441 out.add(call);
449 * Checks to see if the connection is the first connection in a conference call.
450 * If it is a conference call, we will create a new Conference Call object or
451 * update the existing conference call object for that connection.
452 * If it is not a conference call but a previous associated conference call still exists,
458 private boolean updateForConferenceCalls(Connection connection, List<Call> updatedCalls) {
459 // We consider this connection a conference connection if the call it
460 // belongs to is a multiparty call AND it is the first live connection.
466 // If this connection is the main connection for the conference call, then create or update
467 // a Call object for that conference call.
469 final Call confCall = getCallFromMap(mConfCallMap, connection, true);
476 if (DBG) Log.d(TAG, "Updating a conference call: " + confCall);
478 // It is possible that through a conference call split, there may be lingering conference
481 final Call oldConfCall = getCallFromMap(mConfCallMap, connection, false);
483 // We found a conference call for this connection, which is no longer a conference call.
486 if (DBG) Log.d(TAG, "Cleaning up an old conference call: " + oldConfCall);
499 private Connection getEarliestLiveConnection(com.android.internal.telephony.Call call) {
500 final List<Connection> connections = call.getConnections();
517 * Sets the new call state onto the call and performs some additional logic
520 private void setNewState(Call call, int newState, Connection connection) {
521 Preconditions.checkState(call.getState() != newState);
523 // When starting an outgoing call, we need to grab gateway information
524 // for the call, if available, and set it.
527 if (Call.State.isDialing(newState)) {
529 call.setGatewayNumber(info.getFormattedGatewayNumber());
530 call.setGatewayPackage(info.packageName);
532 } else if (!Call.State.isConnected(newState)) {
536 call.setState(newState);
540 * Updates the Call properties to match the state of the connection object
542 * @param call The call object to update.
543 * @param connection The connection object from which to update call.
547 private boolean updateCallFromConnection(Call call, Connection connection,
553 if (call.getState() != newState) {
554 setNewState(call, newState, connection);
558 final Call.DisconnectCause newDisconnectCause =
560 if (call.getDisconnectCause() != newDisconnectCause) {
561 call.setDisconnectCause(newDisconnectCause);
565 final long oldConnectTime = call.getConnectTime();
567 call.setConnectTime(connection.getConnectTime());
573 final String oldNumber = call.getNumber();
580 call.setNumber(newNumber);
586 if (call.getNumberPresentation() != newNumberPresentation) {
587 call.setNumberPresentation(newNumberPresentation);
592 final String oldCnapName = call.getCnapName();
594 call.setCnapName(connection.getCnapName());
600 if (call.getCnapNamePresentation() != newCnapNamePresentation) {
601 call.setCnapNamePresentation(newCnapNamePresentation);
609 // 3) Adding the correct children into the Call
611 ImmutableSortedSet<Integer> oldSet = call.getChildCallIds();
612 call.removeAllChildren();
616 final Call childCall = getCallFromMap(mCallMap, childConn, false);
618 call.addChildId(childCall.getCallId());
622 changed |= !oldSet.equals(call.getChildCallIds());
626 * !!! Uses values from connection and call collected above so this part must be last !!!
628 final int newCapabilities = getCapabilitiesFor(connection, call, isForConference);
629 if (call.getCapabilities() != newCapabilities) {
630 call.setCapabilities(newCapabilities);
640 private int getCapabilitiesFor(Connection connection, Call call, boolean isForConference) {
641 final boolean callIsActive = (call.getState() == Call.State.ACTIVE);
663 // "Mute": only enabled when the foreground call is ACTIVE.
679 canRespondViaText = RejectWithTextMessageManager.allowRespondViaSmsForCall(call,
718 * Returns true if the Connection is part of a multiparty call.
719 * We do this by checking the isMultiparty() method of the telephony.Call object and also
728 // "dialing" 3way call for CDMA calls.
742 com.android.internal.telephony.Call.State connState = connection.getState();
744 // For the "fake" outgoing CDMA call, we need to always treat it as an outgoing call.
746 connState = com.android.internal.telephony.Call.State.DIALING;
779 // If we are dealing with a potential child call (not the parent conference call),
782 // if the connection is part of a multiparty call, and it is live,
792 private final ImmutableMap<Connection.DisconnectCause, Call.DisconnectCause> CAUSE_MAP =
793 ImmutableMap.<Connection.DisconnectCause, Call.DisconnectCause>builder()
794 .put(Connection.DisconnectCause.BUSY, Call.DisconnectCause.BUSY)
795 .put(Connection.DisconnectCause.CALL_BARRED, Call.DisconnectCause.CALL_BARRED)
797 Call.DisconnectCause.CDMA_ACCESS_BLOCKED)
799 Call.DisconnectCause.CDMA_ACCESS_FAILURE)
800 .put(Connection.DisconnectCause.CDMA_DROP, Call.DisconnectCause.CDMA_DROP)
801 .put(Connection.DisconnectCause.CDMA_INTERCEPT, Call.DisconnectCause.CDMA_INTERCEPT)
803 Call.DisconnectCause.CDMA_LOCKED_UNTIL_POWER_CYCLE)
805 Call.DisconnectCause.CDMA_NOT_EMERGENCY)
806 .put(Connection.DisconnectCause.CDMA_PREEMPTED, Call.DisconnectCause.CDMA_PREEMPTED)
807 .put(Connection.DisconnectCause.CDMA_REORDER, Call.DisconnectCause.CDMA_REORDER)
809 Call.DisconnectCause.CDMA_RETRY_ORDER)
810 .put(Connection.DisconnectCause.CDMA_SO_REJECT, Call.DisconnectCause.CDMA_SO_REJECT)
811 .put(Connection.DisconnectCause.CONGESTION, Call.DisconnectCause.CONGESTION)
812 .put(Connection.DisconnectCause.CS_RESTRICTED, Call.DisconnectCause.CS_RESTRICTED)
814 Call.DisconnectCause.CS_RESTRICTED_EMERGENCY)
816 Call.DisconnectCause.CS_RESTRICTED_NORMAL)
818 Call.DisconnectCause.ERROR_UNSPECIFIED)
819 .put(Connection.DisconnectCause.FDN_BLOCKED, Call.DisconnectCause.FDN_BLOCKED)
820 .put(Connection.DisconnectCause.ICC_ERROR, Call.DisconnectCause.ICC_ERROR)
822 Call.DisconnectCause.INCOMING_MISSED)
824 Call.DisconnectCause.INCOMING_REJECTED)
826 Call.DisconnectCause.INVALID_CREDENTIALS)
828 Call.DisconnectCause.INVALID_NUMBER)
829 .put(Connection.DisconnectCause.LIMIT_EXCEEDED, Call.DisconnectCause.LIMIT_EXCEEDED)
830 .put(Connection.DisconnectCause.LOCAL, Call.DisconnectCause.LOCAL)
831 .put(Connection.DisconnectCause.LOST_SIGNAL, Call.DisconnectCause.LOST_SIGNAL)
832 .put(Connection.DisconnectCause.MMI, Call.DisconnectCause.MMI)
833 .put(Connection.DisconnectCause.NORMAL, Call.DisconnectCause.NORMAL)
835 Call.DisconnectCause.NOT_DISCONNECTED)
837 Call.DisconnectCause.NUMBER_UNREACHABLE)
838 .put(Connection.DisconnectCause.OUT_OF_NETWORK, Call.DisconnectCause.OUT_OF_NETWORK)
839 .put(Connection.DisconnectCause.OUT_OF_SERVICE, Call.DisconnectCause.OUT_OF_SERVICE)
840 .put(Connection.DisconnectCause.POWER_OFF, Call.DisconnectCause.POWER_OFF)
841 .put(Connection.DisconnectCause.SERVER_ERROR, Call.DisconnectCause.SERVER_ERROR)
843 Call.DisconnectCause.SERVER_UNREACHABLE)
844 .put(Connection.DisconnectCause.TIMED_OUT, Call.DisconnectCause.TIMED_OUT)
846 Call.DisconnectCause.UNOBTAINABLE_NUMBER)
849 private Call.DisconnectCause translateDisconnectCauseFromTelephony(
856 return Call.DisconnectCause.UNKNOWN;
861 * This function does NOT set any of the Connection data onto the Call class.
862 * A separate call to updateCallFromConnection must be made for that purpose.
864 private Call getCallFromMap(HashMap<Connection, Call> map, Connection conn,
866 Call call = null;
868 // Find the call id or create if missing and requested.
871 call = map.get(conn);
873 call = createNewCall();
874 map.put(conn, call);
877 return call;
881 * Creates a brand new connection for the call.
883 private Call createNewCall() {
894 // The call to containsValue() is linear, however, most devices support a
898 return new Call(callId);
905 void onDisconnect(Call call);
906 void onIncoming(Call call);
907 void onUpdate(List<Call> calls);
913 * Result class for accessing a call by connection.
916 public Call mCall;
917 public Call mActionableCall;
920 private CallResult(Call call, Connection connection) {
921 this(call, call, connection);
924 private CallResult(Call call, Call actionableCall, Connection connection) {
925 mCall = call;
930 public Call getCall() {
934 // The call that should be used for call actions like hanging up.
935 public Call getActionableCall() {