Home | History | Annotate | Download | only in incallui

Lines Matching refs:Call

27 import com.android.services.telephony.common.Call;
28 import com.android.services.telephony.common.Call.DisconnectCause;
37 * classes of changes to the call list as they are received from the telephony stack.
50 private final HashMap<Integer, Call> mCallMap = Maps.newHashMap();
72 * Called when a single call has changed.
74 public void onUpdate(Call call) {
75 Log.d(this, "onUpdate - ", call);
77 updateCallInMap(call);
82 * Called when a single call disconnects.
84 public void onDisconnect(Call call) {
85 Log.d(this, "onDisconnect: ", call);
87 boolean updated = updateCallInMap(call);
91 notifyCallUpdateListeners(call);
94 notifyListenersOfDisconnect(call);
99 * Called when a single call has changed.
101 public void onIncoming(Call call, List<String> textMessages) {
102 Log.d(this, "onIncoming - " + call);
104 updateCallInMap(call);
105 updateCallTextMap(call, textMessages);
108 listener.onIncomingCall(call);
115 public void onUpdate(List<Call> callsToUpdate) {
119 for (Call call : callsToUpdate) {
120 Log.d(this, "\t" + call);
122 updateCallInMap(call);
123 updateCallTextMap(call, null);
125 notifyCallUpdateListeners(call);
131 public void notifyCallUpdateListeners(Call call) {
132 final List<CallUpdateListener> listeners = mCallUpdateListenerMap.get(call.getCallId());
135 listener.onCallStateChanged(call);
141 * Add a call update listener for a call id.
143 * @param callId The call id to get updates for.
156 * Remove a call update listener for a call id.
158 * @param callId The call id to remove the listener for.
184 * call, the code should rely on the status of a specific Call and allow the presenters to
185 * update the Call object when the active call changes.
187 public Call getIncomingOrActive() {
188 Call retval = getIncomingCall();
195 public Call getOutgoingCall() {
196 Call call = getFirstCallWithState(Call.State.DIALING);
197 if (call == null) {
198 call = getFirstCallWithState(Call.State.REDIALING);
200 return call;
203 public Call getActiveCall() {
204 return getFirstCallWithState(Call.State.ACTIVE);
207 public Call getBackgroundCall() {
208 return getFirstCallWithState(Call.State.ONHOLD);
211 public Call getDisconnectedCall() {
212 return getFirstCallWithState(Call.State.DISCONNECTED);
215 public Call getDisconnectingCall() {
216 return getFirstCallWithState(Call.State.DISCONNECTING);
219 public Call getSecondBackgroundCall() {
220 return getCallWithState(Call.State.ONHOLD, 1);
223 public Call getActiveOrBackgroundCall() {
224 Call call = getActiveCall();
225 if (call == null) {
226 call = getBackgroundCall();
228 return call;
231 public Call getIncomingCall() {
232 Call call = getFirstCallWithState(Call.State.INCOMING);
233 if (call == null) {
234 call = getFirstCallWithState(Call.State.CALL_WAITING);
237 return call;
240 public Call getFirstCall() {
241 Call result = getIncomingCall();
246 result = getFirstCallWithState(Call.State.ACTIVE);
257 public Call getCall(int callId) {
262 for (Call call : mCallMap.values()) {
263 if (!isCallDead(call)) {
275 * Returns first call found in the call map with the specified state.
277 public Call getFirstCallWithState(int state) {
282 * Returns the [position]th call found in the call map with the specified state.
283 * TODO: Improve this logic to sort by call time.
285 public Call getCallWithState(int state, int positionToFind) {
286 Call retval = null;
288 for (Call call : mCallMap.values()) {
289 if (call.getState() == state) {
291 retval = call;
309 for (Call call : mCallMap.values()) {
310 final int state = call.getState();
311 if (state != Call.State.IDLE &&
312 state != Call.State.INVALID &&
313 state != Call.State.DISCONNECTED) {
315 call.setState(Call.State.DISCONNECTED);
316 call.setDisconnectCause(DisconnectCause.UNKNOWN);
317 updateCallInMap(call);
325 * It is up to the listeners to call back to determine what changed.
333 private void notifyListenersOfDisconnect(Call call) {
335 listener.onDisconnect(call);
340 * Updates the call entry in the local map.
341 * @return false if no call previously existed and no call was added, otherwise true.
343 private boolean updateCallInMap(Call call) {
344 Preconditions.checkNotNull(call);
348 final Integer id = new Integer(call.getCallId());
350 if (call.getState() == Call.State.DISCONNECTED) {
355 // UI has a chance to display anything it needs when a call is disconnected.
357 // Set up a timer to destroy the call after X seconds.
358 final Message msg = mHandler.obtainMessage(EVENT_DISCONNECTED_TIMEOUT, call);
359 mHandler.sendMessageDelayed(msg, getDelayForDisconnect(call));
361 mCallMap.put(id, call);
364 } else if (!isCallDead(call)) {
365 mCallMap.put(id, call);
375 private int getDelayForDisconnect(Call call) {
376 Preconditions.checkState(call.getState() == Call.State.DISCONNECTED);
379 final Call.DisconnectCause cause = call.getDisconnectCause();
402 private void updateCallTextMap(Call call, List<String> textResponses) {
403 Preconditions.checkNotNull(call);
405 final Integer id = new Integer(call.getCallId());
407 if (!isCallDead(call)) {
416 private boolean isCallDead(Call call) {
417 final int state = call.getState();
418 return Call.State.IDLE == state || Call.State.INVALID == state;
422 * Sets up a call for deletion and notifies listeners of change.
424 private void finishDisconnectedCall(Call call) {
425 call.setState(Call.State.IDLE);
426 updateCallInMap(call);
439 finishDisconnectedCall((Call) msg.obj);
450 * to the call list.
454 * Called when a new incoming call comes in.
456 * that want to perform an action on incoming call should respond in this method
460 public void onIncomingCall(Call call);
463 * Called anytime there are changes to the call list. The change can be switching call
471 * Called when a call switches to the disconnected state. This is the only method
474 public void onDisconnect(Call call);
478 // TODO: refactor and limit arg to be call state. Caller info is not needed.
479 public void onCallStateChanged(Call call);