コード例 #1
0
  /* package */
  void resumeWaitingOrHolding() throws CallStateException {
    if (DBG) log("resumeWaitingOrHolding");

    try {
      if (mForegroundCall.getState().isAlive()) {
        // resume foreground call after holding background call
        // they were switched before holding
        ImsCall imsCall = mForegroundCall.getImsCall();
        if (imsCall != null) imsCall.resume();
      } else if (mRingingCall.getState() == ImsPhoneCall.State.WAITING) {
        // accept waiting call after holding background call
        ImsCall imsCall = mRingingCall.getImsCall();
        if (imsCall != null) imsCall.accept(ImsCallProfile.CALL_TYPE_VOICE);
      } else {
        // Just resume background call.
        // To distinguish resuming call with swapping calls
        // we do not switch calls.here
        // ImsPhoneConnection.update will chnage the parent when completed
        ImsCall imsCall = mBackgroundCall.getImsCall();
        if (imsCall != null) imsCall.resume();
      }
    } catch (ImsException e) {
      throw new CallStateException(e.getMessage());
    }
  }
コード例 #2
0
  /**
   * Accepts a call with the specified video state. The video state is the video state that the user
   * has agreed upon in the InCall UI.
   *
   * @param videoState The video State
   * @throws CallStateException
   */
  void acceptCall(int videoState) throws CallStateException {
    if (DBG) log("acceptCall");

    if (mForegroundCall.getState().isAlive() && mBackgroundCall.getState().isAlive()) {
      throw new CallStateException("cannot accept call");
    }

    if ((mRingingCall.getState() == ImsPhoneCall.State.WAITING)
        && mForegroundCall.getState().isAlive()) {
      setMute(false);
      switchWaitingOrHoldingAndActive();
    } else if (mRingingCall.getState().isRinging()) {
      if (DBG) log("acceptCall: incoming...");
      // Always unmute when answering a new call
      setMute(false);
      try {
        ImsCall imsCall = mRingingCall.getImsCall();
        if (imsCall != null) {
          imsCall.accept(ImsCallProfile.getCallTypeFromVideoState(videoState));
        } else {
          throw new CallStateException("no valid ims call");
        }
      } catch (ImsException e) {
        throw new CallStateException("cannot accept call");
      }
    } else {
      throw new CallStateException("phone not ringing");
    }
  }