InCallPresenter.java revision 64f6ec50ac061ccd063bfb1093e91600e4bac286
1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.incallui; 18 19import com.google.android.collect.Sets; 20import com.google.common.base.Preconditions; 21 22import android.content.Context; 23import android.content.Intent; 24 25import com.android.services.telephony.common.Call; 26import com.android.services.telephony.common.Call.Capabilities; 27import com.google.common.collect.Lists; 28 29import java.util.ArrayList; 30import java.util.Set; 31 32/** 33 * Takes updates from the CallList and notifies the InCallActivity (UI) 34 * of the changes. 35 * Responsible for starting the activity for a new call and finishing the activity when all calls 36 * are disconnected. 37 * Creates and manages the in-call state and provides a listener pattern for the presenters 38 * that want to listen in on the in-call state changes. 39 * TODO: This class has become more of a state machine at this point. Consider renaming. 40 */ 41public class InCallPresenter implements CallList.Listener { 42 43 private static InCallPresenter sInCallPresenter; 44 45 private final Set<InCallStateListener> mListeners = Sets.newHashSet(); 46 private final ArrayList<IncomingCallListener> mIncomingCallListeners = Lists.newArrayList(); 47 48 private AudioModeProvider mAudioModeProvider; 49 private StatusBarNotifier mStatusBarNotifier; 50 private ContactInfoCache mContactInfoCache; 51 private Context mContext; 52 private CallList mCallList; 53 private InCallActivity mInCallActivity; 54 private InCallState mInCallState = InCallState.NO_CALLS; 55 private ProximitySensor mProximitySensor; 56 private boolean mServiceConnected = false; 57 58 /** 59 * Is true when the activity has been previously started. Some code needs to know not just if 60 * the activity is currently up, but if it had been previously shown in foreground for this 61 * in-call session (e.g., StatusBarNotifier). This gets reset when the session ends in the 62 * tear-down method. 63 */ 64 private boolean mIsActivityPreviouslyStarted = false; 65 66 public static synchronized InCallPresenter getInstance() { 67 if (sInCallPresenter == null) { 68 sInCallPresenter = new InCallPresenter(); 69 } 70 return sInCallPresenter; 71 } 72 73 public void setUp(Context context, CallList callList, AudioModeProvider audioModeProvider) { 74 if (mServiceConnected) { 75 Log.i(this, "New service connection replacing existing one."); 76 // retain the current resources, no need to create new ones. 77 Preconditions.checkState(context == mContext); 78 Preconditions.checkState(callList == mCallList); 79 Preconditions.checkState(audioModeProvider == mAudioModeProvider); 80 return; 81 } 82 83 Preconditions.checkNotNull(context); 84 mContext = context; 85 86 mContactInfoCache = ContactInfoCache.getInstance(context); 87 88 mStatusBarNotifier = new StatusBarNotifier(context, mContactInfoCache, mCallList); 89 addListener(mStatusBarNotifier); 90 91 mAudioModeProvider = audioModeProvider; 92 93 mProximitySensor = new ProximitySensor(context, mAudioModeProvider); 94 addListener(mProximitySensor); 95 96 mCallList = callList; 97 98 // This only gets called by the service so this is okay. 99 mServiceConnected = true; 100 101 // The final thing we do in this set up is add ourselves as a listener to CallList. This 102 // will kick off an update and the whole process can start. 103 mCallList.addListener(this); 104 105 Log.d(this, "Finished InCallPresenter.setUp"); 106 } 107 108 /** 109 * Called when the telephony service has disconnected from us. This will happen when there are 110 * no more active calls. However, we may still want to continue showing the UI for 111 * certain cases like showing "Call Ended". 112 * What we really want is to wait for the activity and the service to both disconnect before we 113 * tear things down. This method sets a serviceConnected boolean and calls a secondary method 114 * that performs the aforementioned logic. 115 */ 116 public void tearDown() { 117 Log.d(this, "tearDown"); 118 mServiceConnected = false; 119 attemptCleanup(); 120 } 121 122 private void attemptFinishActivity() { 123 final boolean doFinish = (mInCallActivity != null && isActivityStarted()); 124 Log.i(this, "Hide in call UI: " + doFinish); 125 126 if (doFinish) { 127 mInCallActivity.finish(); 128 } 129 } 130 131 /** 132 * Called when the UI begins or ends. Starts the callstate callbacks if the UI just began. 133 * Attempts to tear down everything if the UI just ended. See #tearDown for more insight on 134 * the tear-down process. 135 */ 136 public void setActivity(InCallActivity inCallActivity) { 137 boolean updateListeners = false; 138 boolean doAttemptCleanup = false; 139 140 if (inCallActivity != null) { 141 if (mInCallActivity == null) { 142 updateListeners = true; 143 Log.i(this, "UI Initialized"); 144 } else if (mInCallActivity != inCallActivity) { 145 Log.wtf(this, "Setting a second activity before destroying the first."); 146 } else { 147 // since setActivity is called onStart(), it can be called multiple times. 148 // This is fine and ignorable, but we do not want to update the world every time 149 // this happens (like going to/from background) so we do not set updateListeners. 150 } 151 152 mInCallActivity = inCallActivity; 153 154 // By the time the UI finally comes up, the call may already be disconnected. 155 // If that's the case, we may need to show an error dialog. 156 if (mCallList != null && mCallList.getDisconnectedCall() != null) { 157 maybeShowErrorDialogOnDisconnect(mCallList.getDisconnectedCall()); 158 } 159 160 // When the UI comes up, we need to first check the in-call state. 161 // If we are showing NO_CALLS, that means that a call probably connected and 162 // then immediately disconnected before the UI was able to come up. 163 // If we dont have any calls, start tearing down the UI instead. 164 // NOTE: This code relies on {@link #mInCallActivity} being set so we run it after 165 // it has been set. 166 if (mInCallState == InCallState.NO_CALLS) { 167 Log.i(this, "UI Intialized, but no calls left. shut down."); 168 attemptFinishActivity(); 169 return; 170 } 171 } else { 172 Log.i(this, "UI Destroyed)"); 173 updateListeners = true; 174 mInCallActivity = null; 175 176 // We attempt cleanup for the destroy case but only after we recalculate the state 177 // to see if we need to come back up or stay shut down. This is why we do the cleanup 178 // after the call to onCallListChange() instead of directly here. 179 doAttemptCleanup = true; 180 } 181 182 // Messages can come from the telephony layer while the activity is coming up 183 // and while the activity is going down. So in both cases we need to recalculate what 184 // state we should be in after they complete. 185 // Examples: (1) A new incoming call could come in and then get disconnected before 186 // the activity is created. 187 // (2) All calls could disconnect and then get a new incoming call before the 188 // activity is destroyed. 189 // 190 // b/1122139 - We previously had a check for mServiceConnected here as well, but there are 191 // cases where we need to recalculate the current state even if the service in not 192 // connected. In particular the case where startOrFinish() is called while the app is 193 // already finish()ing. In that case, we skip updating the state with the knowledge that 194 // we will check again once the activity has finished. That means we have to recalculate the 195 // state here even if the service is disconnected since we may not have finished a state 196 // transition while finish()ing. 197 if (updateListeners) { 198 onCallListChange(mCallList); 199 } 200 201 if (doAttemptCleanup) { 202 attemptCleanup(); 203 } 204 } 205 206 /** 207 * Called when there is a change to the call list. 208 * Sets the In-Call state for the entire in-call app based on the information it gets from 209 * CallList. Dispatches the in-call state to all listeners. Can trigger the creation or 210 * destruction of the UI based on the states that is calculates. 211 */ 212 @Override 213 public void onCallListChange(CallList callList) { 214 InCallState newState = getPotentialStateFromCallList(callList); 215 newState = startOrFinishUi(newState); 216 217 // Renable notification shade and soft navigation buttons, if we are no longer in the 218 // incoming call screen 219 if (!newState.isIncoming()) { 220 CallCommandClient.getInstance().setSystemBarNavigationEnabled(true); 221 } 222 223 // Set the new state before announcing it to the world 224 Log.i(this, "Phone switching state: " + mInCallState + " -> " + newState); 225 mInCallState = newState; 226 227 // notify listeners of new state 228 for (InCallStateListener listener : mListeners) { 229 Log.d(this, "Notify " + listener + " of state " + mInCallState.toString()); 230 listener.onStateChange(mInCallState, callList); 231 } 232 } 233 234 /** 235 * Called when there is a new incoming call. 236 * 237 * @param call 238 */ 239 @Override 240 public void onIncomingCall(Call call) { 241 InCallState newState = startOrFinishUi(InCallState.INCOMING); 242 243 Log.i(this, "Phone switching state: " + mInCallState + " -> " + newState); 244 mInCallState = newState; 245 246 // Disable notification shade and soft navigation buttons 247 if (newState.isIncoming()) { 248 CallCommandClient.getInstance().setSystemBarNavigationEnabled(false); 249 } 250 251 for (IncomingCallListener listener : mIncomingCallListeners) { 252 listener.onIncomingCall(mInCallState, call); 253 } 254 } 255 256 /** 257 * Called when a call becomes disconnected. Called everytime an existing call 258 * changes from being connected (incoming/outgoing/active) to disconnected. 259 */ 260 @Override 261 public void onDisconnect(Call call) { 262 hideDialpadForDisconnect(); 263 maybeShowErrorDialogOnDisconnect(call); 264 265 // We need to do the run the same code as onCallListChange. 266 onCallListChange(CallList.getInstance()); 267 } 268 269 /** 270 * Given the call list, return the state in which the in-call screen should be. 271 */ 272 public static InCallState getPotentialStateFromCallList(CallList callList) { 273 InCallState newState = InCallState.NO_CALLS; 274 275 if (callList.getIncomingCall() != null) { 276 newState = InCallState.INCOMING; 277 } else if (callList.getOutgoingCall() != null) { 278 newState = InCallState.OUTGOING; 279 } else if (callList.getActiveCall() != null || 280 callList.getBackgroundCall() != null || 281 callList.getDisconnectedCall() != null || 282 callList.getDisconnectingCall() != null) { 283 newState = InCallState.INCALL; 284 } 285 286 return newState; 287 } 288 289 public void addIncomingCallListener(IncomingCallListener listener) { 290 Preconditions.checkNotNull(listener); 291 mIncomingCallListeners.add(listener); 292 } 293 294 public void removeIncomingCallListener(IncomingCallListener listener) { 295 Preconditions.checkNotNull(listener); 296 mIncomingCallListeners.remove(listener); 297 } 298 299 public void addListener(InCallStateListener listener) { 300 Preconditions.checkNotNull(listener); 301 mListeners.add(listener); 302 } 303 304 public void removeListener(InCallStateListener listener) { 305 Preconditions.checkNotNull(listener); 306 mListeners.remove(listener); 307 } 308 309 public AudioModeProvider getAudioModeProvider() { 310 return mAudioModeProvider; 311 } 312 313 public ContactInfoCache getContactInfoCache() { 314 return mContactInfoCache; 315 } 316 317 public ProximitySensor getProximitySensor() { 318 return mProximitySensor; 319 } 320 321 /** 322 * Hangs up any active or outgoing calls. 323 */ 324 public void hangUpOngoingCall() { 325 // By the time we receive this intent, we could be shut down and call list 326 // could be null. Bail in those cases. 327 if (mCallList == null) { 328 return; 329 } 330 331 Call call = mCallList.getOutgoingCall(); 332 if (call == null) { 333 call = mCallList.getActiveOrBackgroundCall(); 334 } 335 336 if (call != null) { 337 CallCommandClient.getInstance().disconnectCall(call.getCallId()); 338 } 339 } 340 341 /** 342 * Returns true if the incall app is the foreground application. 343 */ 344 public boolean isShowingInCallUi() { 345 return (isActivityStarted() && mInCallActivity.isForegroundActivity()); 346 } 347 348 /** 349 * Returns true of the activity has been created and is running. 350 * Returns true as long as activity is not destroyed or finishing. This ensures that we return 351 * true even if the activity is paused (not in foreground). 352 */ 353 public boolean isActivityStarted() { 354 return (mInCallActivity != null && 355 !mInCallActivity.isDestroyed() && 356 !mInCallActivity.isFinishing()); 357 } 358 359 public boolean isActivityPreviouslyStarted() { 360 return mIsActivityPreviouslyStarted; 361 } 362 363 /** 364 * Called when the activity goes in/out of the foreground. 365 */ 366 public void onUiShowing(boolean showing) { 367 // We need to update the notification bar when we leave the UI because that 368 // could trigger it to show again. 369 if (mStatusBarNotifier != null) { 370 mStatusBarNotifier.updateNotification(mInCallState, mCallList); 371 } 372 373 if (mProximitySensor != null) { 374 mProximitySensor.onInCallShowing(showing); 375 } 376 377 if (showing) { 378 mIsActivityPreviouslyStarted = true; 379 } 380 } 381 382 /** 383 * Brings the app into the foreground if possible. 384 */ 385 public void bringToForeground(boolean showDialpad) { 386 // Before we bring the incall UI to the foreground, we check to see if: 387 // 1. We've already started the activity once for this session 388 // 2. If it exists, the activity is not already in the foreground 389 // 3. We are in a state where we want to show the incall ui 390 if (mIsActivityPreviouslyStarted && !isShowingInCallUi() && 391 mInCallState != InCallState.NO_CALLS) { 392 showInCall(showDialpad); 393 } 394 } 395 396 public void onPostDialCharWait(int callId, String chars) { 397 mInCallActivity.showPostCharWaitDialog(callId, chars); 398 } 399 400 /** 401 * Handles the green CALL key while in-call. 402 * @return true if we consumed the event. 403 */ 404 public boolean handleCallKey() { 405 Log.v(this, "handleCallKey"); 406 407 // The green CALL button means either "Answer", "Unhold", or 408 // "Swap calls", or can be a no-op, depending on the current state 409 // of the Phone. 410 411 /** 412 * INCOMING CALL 413 */ 414 final CallList calls = CallList.getInstance(); 415 final Call incomingCall = calls.getIncomingCall(); 416 Log.v(this, "incomingCall: " + incomingCall); 417 418 // (1) Attempt to answer a call 419 if (incomingCall != null) { 420 CallCommandClient.getInstance().answerCall(incomingCall.getCallId()); 421 return true; 422 } 423 424 /** 425 * ACTIVE CALL 426 */ 427 final Call activeCall = calls.getActiveCall(); 428 if (activeCall != null) { 429 // TODO: This logic is repeated from CallButtonPresenter.java. We should 430 // consolidate this logic. 431 final boolean isGeneric = activeCall.can(Capabilities.GENERIC_CONFERENCE); 432 final boolean canMerge = activeCall.can(Capabilities.MERGE_CALLS); 433 final boolean canSwap = activeCall.can(Capabilities.SWAP_CALLS); 434 435 Log.v(this, "activeCall: " + activeCall + ", isGeneric: " + isGeneric + ", canMerge: " + 436 canMerge + ", canSwap: " + canSwap); 437 438 // (2) Attempt actions on Generic conference calls 439 if (activeCall.isConferenceCall() && isGeneric) { 440 if (canMerge) { 441 CallCommandClient.getInstance().merge(); 442 return true; 443 } else if (canSwap) { 444 CallCommandClient.getInstance().swap(); 445 return true; 446 } 447 } 448 449 // (3) Swap calls 450 if (canSwap) { 451 CallCommandClient.getInstance().swap(); 452 return true; 453 } 454 } 455 456 /** 457 * BACKGROUND CALL 458 */ 459 final Call heldCall = calls.getBackgroundCall(); 460 if (heldCall != null) { 461 // We have a hold call so presumeable it will always support HOLD...but 462 // there is no harm in double checking. 463 final boolean canHold = heldCall.can(Capabilities.HOLD); 464 465 Log.v(this, "heldCall: " + heldCall + ", canHold: " + canHold); 466 467 // (4) unhold call 468 if (heldCall.getState() == Call.State.ONHOLD && canHold) { 469 CallCommandClient.getInstance().hold(heldCall.getCallId(), false); 470 return true; 471 } 472 } 473 474 // Always consume hard keys 475 return true; 476 } 477 478 /** 479 * A dialog could have prevented in-call screen from being previously finished. 480 * This function checks to see if there should be any UI left and if not attempts 481 * to tear down the UI. 482 */ 483 public void onDismissDialog() { 484 Log.i(this, "Dialog dismissed"); 485 if (mInCallState == InCallState.NO_CALLS) { 486 attemptFinishActivity(); 487 attemptCleanup(); 488 } 489 } 490 491 /** 492 * For some disconnected causes, we show a dialog. This calls into the activity to show 493 * the dialog if appropriate for the call. 494 */ 495 private void maybeShowErrorDialogOnDisconnect(Call call) { 496 // For newly disconnected calls, we may want to show a dialog on specific error conditions 497 if (isActivityStarted() && call.getState() == Call.State.DISCONNECTED) { 498 mInCallActivity.maybeShowErrorDialogOnDisconnect(call.getDisconnectCause()); 499 } 500 } 501 502 /** 503 * Hides the dialpad. Called when a call is disconnected (Requires hiding dialpad). 504 */ 505 private void hideDialpadForDisconnect() { 506 if (isActivityStarted()) { 507 mInCallActivity.hideDialpadForDisconnect(); 508 } 509 } 510 511 /** 512 * When the state of in-call changes, this is the first method to get called. It determines if 513 * the UI needs to be started or finished depending on the new state and does it. 514 */ 515 private InCallState startOrFinishUi(InCallState newState) { 516 Log.d(this, "startOrFinishUi: " + mInCallState + " -> " + newState); 517 518 // TODO: Consider a proper state machine implementation 519 520 // If the state isn't changing, we have already done any starting/stopping of 521 // activities in a previous pass...so lets cut out early 522 if (newState == mInCallState) { 523 return newState; 524 } 525 526 // A new Incoming call means that the user needs to be notified of the the call (since 527 // it wasn't them who initiated it). We do this through full screen notifications and 528 // happens indirectly through {@link StatusBarListener}. 529 // 530 // The process for incoming calls is as follows: 531 // 532 // 1) CallList - Announces existence of new INCOMING call 533 // 2) InCallPresenter - Gets announcement and calculates that the new InCallState 534 // - should be set to INCOMING. 535 // 3) InCallPresenter - This method is called to see if we need to start or finish 536 // the app given the new state. 537 // 4) StatusBarNotifier - Listens to InCallState changes. InCallPresenter calls 538 // StatusBarNotifier explicitly to issue a FullScreen Notification 539 // that will either start the InCallActivity or show the user a 540 // top-level notification dialog if the user is in an immersive app. 541 // That notification can also start the InCallActivity. 542 // 5) InCallActivity - Main activity starts up and at the end of its onCreate will 543 // call InCallPresenter::setActivity() to let the presenter 544 // know that start-up is complete. 545 // 546 // [ AND NOW YOU'RE IN THE CALL. voila! ] 547 // 548 // Our app is started using a fullScreen notification. We need to do this whenever 549 // we get an incoming call. 550 final boolean startStartupSequence = (InCallState.INCOMING == newState); 551 552 // A new outgoing call indicates that the user just now dialed a number and when that 553 // happens we need to display the screen immediateley. 554 // 555 // This is different from the incoming call sequence because we do not need to shock the 556 // user with a top-level notification. Just show the call UI normally. 557 final boolean showCallUi = (InCallState.OUTGOING == newState); 558 559 // TODO: Can we be suddenly in a call without it having been in the outgoing or incoming 560 // state? I havent seen that but if it can happen, the code below should be enabled. 561 // showCallUi |= (InCallState.INCALL && !isActivityStarted()); 562 563 // The only time that we have an instance of mInCallActivity and it isn't started is 564 // when it is being destroyed. In that case, lets avoid bringing up another instance of 565 // the activity. When it is finally destroyed, we double check if we should bring it back 566 // up so we aren't going to lose anything by avoiding a second startup here. 567 boolean activityIsFinishing = mInCallActivity != null && !isActivityStarted(); 568 if (activityIsFinishing) { 569 Log.i(this, "Undo the state change: " + newState + " -> " + mInCallState); 570 return mInCallState; 571 } 572 573 if (showCallUi) { 574 Log.i(this, "Start in call UI"); 575 showInCall(false); 576 } else if (startStartupSequence) { 577 Log.i(this, "Start Full Screen in call UI"); 578 579 // We're about the bring up the in-call UI for an incoming call. If we still have 580 // dialogs up, we need to clear them out before showing incoming screen. 581 if (isActivityStarted()) { 582 mInCallActivity.dismissPendingDialogs(); 583 } 584 startUi(newState); 585 } else if (newState == InCallState.NO_CALLS) { 586 // The new state is the no calls state. Tear everything down. 587 attemptFinishActivity(); 588 } 589 590 return newState; 591 } 592 593 private void startUi(InCallState inCallState) { 594 final Call incomingCall = mCallList.getIncomingCall(); 595 final boolean isCallWaiting = (incomingCall != null && 596 incomingCall.getState() == Call.State.CALL_WAITING); 597 598 // If the screen is off, we need to make sure it gets turned on for incoming calls. 599 // This normally works just fine thanks to FLAG_TURN_SCREEN_ON but that only works 600 // when the activity is first created. Therefore, to ensure the screen is turned on 601 // for the call waiting case, we finish() the current activity and start a new one. 602 // There should be no jank from this since the screen is already off and will remain so 603 // until our new activity is up. 604 if (mProximitySensor.isScreenReallyOff() && isCallWaiting) { 605 if (isActivityStarted()) { 606 mInCallActivity.finish(); 607 } 608 mInCallActivity = null; 609 } 610 611 mStatusBarNotifier.updateNotificationAndLaunchIncomingCallUi(inCallState, mCallList); 612 } 613 614 /** 615 * Checks to see if both the UI is gone and the service is disconnected. If so, tear it all 616 * down. 617 */ 618 private void attemptCleanup() { 619 boolean shouldCleanup = (mInCallActivity == null && !mServiceConnected && 620 mInCallState == InCallState.NO_CALLS); 621 Log.i(this, "attemptCleanup? " + shouldCleanup); 622 623 if (shouldCleanup) { 624 mIsActivityPreviouslyStarted = false; 625 626 // blow away stale contact info so that we get fresh data on 627 // the next set of calls 628 if (mContactInfoCache != null) { 629 mContactInfoCache.clearCache(); 630 } 631 mContactInfoCache = null; 632 633 if (mProximitySensor != null) { 634 removeListener(mProximitySensor); 635 mProximitySensor.tearDown(); 636 } 637 mProximitySensor = null; 638 639 mAudioModeProvider = null; 640 641 if (mStatusBarNotifier != null) { 642 removeListener(mStatusBarNotifier); 643 } 644 mStatusBarNotifier = null; 645 646 if (mCallList != null) { 647 mCallList.removeListener(this); 648 } 649 mCallList = null; 650 651 mContext = null; 652 mInCallActivity = null; 653 654 mListeners.clear(); 655 mIncomingCallListeners.clear(); 656 657 Log.d(this, "Finished InCallPresenter.CleanUp"); 658 } 659 } 660 661 private void showInCall(boolean showDialpad) { 662 mContext.startActivity(getInCallIntent(showDialpad)); 663 } 664 665 public Intent getInCallIntent(boolean showDialpad) { 666 final Intent intent = new Intent(Intent.ACTION_MAIN, null); 667 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 668 | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS 669 | Intent.FLAG_ACTIVITY_NO_USER_ACTION); 670 intent.setClass(mContext, InCallActivity.class); 671 if (showDialpad) { 672 intent.putExtra(InCallActivity.SHOW_DIALPAD_EXTRA, true); 673 } 674 675 return intent; 676 } 677 678 /** 679 * Private constructor. Must use getInstance() to get this singleton. 680 */ 681 private InCallPresenter() { 682 } 683 684 /** 685 * All the main states of InCallActivity. 686 */ 687 public enum InCallState { 688 // InCall Screen is off and there are no calls 689 NO_CALLS, 690 691 // Incoming-call screen is up 692 INCOMING, 693 694 // In-call experience is showing 695 INCALL, 696 697 // User is dialing out 698 OUTGOING; 699 700 public boolean isIncoming() { 701 return (this == INCOMING); 702 } 703 704 public boolean isConnectingOrConnected() { 705 return (this == INCOMING || 706 this == OUTGOING || 707 this == INCALL); 708 } 709 } 710 711 /** 712 * Interface implemented by classes that need to know about the InCall State. 713 */ 714 public interface InCallStateListener { 715 // TODO: Enhance state to contain the call objects instead of passing CallList 716 public void onStateChange(InCallState state, CallList callList); 717 } 718 719 public interface IncomingCallListener { 720 public void onIncomingCall(InCallState state, Call call); 721 } 722} 723