Пример #1
0
    void initIncomingCall(SipAudioCall sipAudioCall, boolean makeCallWait) {
      SipProfile callee = sipAudioCall.getPeerProfile();
      SipConnection c = new SipConnection(this, callee);
      mConnections.add(c);

      Call.State newState = makeCallWait ? State.WAITING : State.INCOMING;
      c.initIncomingCall(sipAudioCall, newState);

      setState(newState);
      notifyNewRingingConnectionP(c);
    }
Пример #2
0
  public boolean canTake(Object incomingCall) {
    // FIXME: Is synchronizing on the class necessary, should we use a mLockObj?
    // Also there are many things not synchronized, of course
    // this may be true of CdmaPhone and GsmPhone too!!!
    synchronized (SipPhone.class) {
      if (!(incomingCall instanceof SipAudioCall)) {
        if (DBG) log("canTake: ret=false, not a SipAudioCall");
        return false;
      }
      if (mRingingCall.getState().isAlive()) {
        if (DBG) log("canTake: ret=false, ringingCall not alive");
        return false;
      }

      // FIXME: is it true that we cannot take any incoming call if
      // both foreground and background are active
      if (mForegroundCall.getState().isAlive() && mBackgroundCall.getState().isAlive()) {
        if (DBG) {
          log("canTake: ret=false," + " foreground and background both alive");
        }
        return false;
      }

      try {
        SipAudioCall sipAudioCall = (SipAudioCall) incomingCall;
        if (DBG) log("canTake: taking call from: " + sipAudioCall.getPeerProfile().getUriString());
        String localUri = sipAudioCall.getLocalProfile().getUriString();
        if (localUri.equals(mProfile.getUriString())) {
          boolean makeCallWait = mForegroundCall.getState().isAlive();
          mRingingCall.initIncomingCall(sipAudioCall, makeCallWait);
          if (sipAudioCall.getState() != SipSession.State.INCOMING_CALL) {
            // Peer cancelled the call!
            if (DBG) log("    canTake: call cancelled !!");
            mRingingCall.reset();
          }
          return true;
        }
      } catch (Exception e) {
        // Peer may cancel the call at any time during the time we hook
        // up ringingCall with sipAudioCall. Clean up ringingCall when
        // that happens.
        if (DBG) log("    canTake: exception e=" + e);
        mRingingCall.reset();
      }
      if (DBG) log("canTake: NOT taking !!");
      return false;
    }
  }