예제 #1
0
        @Override
        public void onReceive(Context context, Intent intent) {
          if (intent.getAction().equals(ImsManager.ACTION_IMS_INCOMING_CALL)) {
            if (DBG) log("onReceive : incoming call intent");

            if (mImsManager == null) return;

            if (mServiceId < 0) return;

            try {
              // Network initiated USSD will be treated by mImsUssdListener
              boolean isUssd = intent.getBooleanExtra(ImsManager.EXTRA_USSD, false);
              if (isUssd) {
                if (DBG) log("onReceive : USSD");
                mUssdSession = mImsManager.takeCall(mServiceId, intent, mImsUssdListener);
                if (mUssdSession != null) {
                  mUssdSession.accept(ImsCallProfile.CALL_TYPE_VOICE);
                }
                return;
              }

              // Normal MT call
              ImsCall imsCall = mImsManager.takeCall(mServiceId, intent, mImsCallListener);
              ImsPhoneConnection conn =
                  new ImsPhoneConnection(
                      mPhone.getContext(), imsCall, ImsPhoneCallTracker.this, mRingingCall);
              addConnection(conn);

              IImsVideoCallProvider imsVideoCallProvider =
                  imsCall.getCallSession().getVideoCallProvider();
              if (imsVideoCallProvider != null) {
                ImsVideoCallProviderWrapper imsVideoCallProviderWrapper =
                    new ImsVideoCallProviderWrapper(imsVideoCallProvider);
                conn.setVideoProvider(imsVideoCallProviderWrapper);
              }

              if ((mForegroundCall.getState() != ImsPhoneCall.State.IDLE)
                  || (mBackgroundCall.getState() != ImsPhoneCall.State.IDLE)) {
                conn.update(imsCall, ImsPhoneCall.State.WAITING);
              }

              mPhone.notifyNewRingingConnection(conn);
              mPhone.notifyIncomingRing();

              updatePhoneState();
              mPhone.notifyPreciseCallStateChanged();
            } catch (ImsException e) {
              loge("onReceive : exception " + e);
            } catch (RemoteException e) {
            }
          }
        }
예제 #2
0
  private void dialInternal(ImsPhoneConnection conn, int clirMode, int videoState) {
    if (conn == null) {
      return;
    }

    if (conn.getAddress() == null
        || conn.getAddress().length() == 0
        || conn.getAddress().indexOf(PhoneNumberUtils.WILD) >= 0) {
      // Phone number is invalid
      conn.setDisconnectCause(DisconnectCause.INVALID_NUMBER);
      sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO);
      return;
    }

    // Always unmute when initiating a new call
    setMute(false);
    int serviceType =
        PhoneNumberUtils.isEmergencyNumber(conn.getAddress())
            ? ImsCallProfile.SERVICE_TYPE_EMERGENCY
            : ImsCallProfile.SERVICE_TYPE_NORMAL;
    int callType = ImsCallProfile.getCallTypeFromVideoState(videoState);
    // TODO(vt): Is this sufficient?  At what point do we know the video state of the call?
    conn.setVideoState(videoState);

    try {
      String[] callees = new String[] {conn.getAddress()};
      ImsCallProfile profile = mImsManager.createCallProfile(mServiceId, serviceType, callType);
      profile.setCallExtraInt(ImsCallProfile.EXTRA_OIR, clirMode);

      ImsCall imsCall = mImsManager.makeCall(mServiceId, profile, callees, mImsCallListener);
      conn.setImsCall(imsCall);

      IImsVideoCallProvider imsVideoCallProvider = imsCall.getCallSession().getVideoCallProvider();
      if (imsVideoCallProvider != null) {
        ImsVideoCallProviderWrapper imsVideoCallProviderWrapper =
            new ImsVideoCallProviderWrapper(imsVideoCallProvider);
        conn.setVideoProvider(imsVideoCallProviderWrapper);
      }
    } catch (ImsException e) {
      loge("dialInternal : " + e);
      conn.setDisconnectCause(DisconnectCause.ERROR_UNSPECIFIED);
      sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO);
    } catch (RemoteException e) {
    }
  }