Пример #1
0
  private void initializeResources() {
    callScreen = (CallScreen) findViewById(R.id.callScreen);
    state = STATE_IDLE;

    callScreen.setHangupButtonListener(new HangupButtonListener());
    callScreen.setIncomingCallActionListener(new IncomingCallActionListener());

    DirectoryUpdateReceiver.scheduleDirectoryUpdate(this);
  }
Пример #2
0
        public void onServiceConnected(ComponentName className, IBinder service) {
          RedPhone.this.redPhoneService =
              ((RedPhoneService.RedPhoneServiceBinder) service).getService();
          redPhoneService.setCallStateHandler(callStateHandler);

          PersonInfo personInfo = redPhoneService.getRemotePersonInfo();

          switch (redPhoneService.getState()) {
            case STATE_IDLE:
              callScreen.reset();
              break;
            case STATE_RINGING:
              handleIncomingCall(personInfo.getNumber());
              break;
            case STATE_DIALING:
              handleOutgoingCall(personInfo.getNumber());
              break;
            case STATE_ANSWERING:
              handleAnswerCall();
              break;
            case STATE_CONNECTED:
              handleCallConnected("XXXX");
              break;
          }
        }
Пример #3
0
 private void handleLoginFailed() {
   state = STATE_IDLE;
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(),
       getString(R.string.RedPhone_login_failed_exclamation));
   delayedFinish();
 }
Пример #4
0
 private void handleCallConnected(String sas) {
   getWindow().addFlags(WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES);
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_connected), sas);
   state = STATE_CONNECTED;
   redPhoneService.notifyCallConnectionUIUpdateComplete();
 }
Пример #5
0
  private void handleCallBusy() {
    callScreen.setActiveCall(
        redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_busy));

    state = STATE_IDLE;
    delayedFinish(BUSY_SIGNAL_DELAY_FINISH);
  }
Пример #6
0
  private void handleAnswerCall() {
    state = STATE_ANSWERING;
    callScreen.setActiveCall(
        redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_answering));

    Intent intent = new Intent(this, RedPhoneService.class);
    intent.setAction(RedPhoneService.ACTION_ANSWER_CALL);
    startService(intent);
  }
Пример #7
0
  private void handleTerminate(int terminationType) {
    Log.w("RedPhone", "handleTerminate called");
    Log.w("RedPhone", "Termination Stack:", new Exception());

    if (state == STATE_DIALING) {
      if (terminationType == LOCAL_TERMINATE) {
        callScreen.setActiveCall(
            redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_cancelling_call));
      } else {
        callScreen.setActiveCall(
            redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_call_rejected));
      }
    } else if (state != STATE_IDLE) {
      callScreen.setActiveCall(
          redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_ending_call));
    }

    state = STATE_IDLE;
    delayedFinish();
  }
Пример #8
0
  private void handleDenyCall() {
    state = STATE_IDLE;

    Intent intent = new Intent(this, RedPhoneService.class);
    intent.setAction(RedPhoneService.ACTION_DENY_CALL);
    startService(intent);

    callScreen.setActiveCall(
        redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_ending_call));
    delayedFinish();
  }
Пример #9
0
 private void handleClientFailure(String msg) {
   state = STATE_IDLE;
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_client_failed));
   if (msg != null && !isFinishing()) {
     AlertDialog.Builder ad = new AlertDialog.Builder(this);
     ad.setTitle("Fatal Error");
     ad.setMessage(msg);
     ad.setCancelable(false);
     ad.setPositiveButton(
         "Ok",
         new OnClickListener() {
           public void onClick(DialogInterface dialog, int arg) {
             RedPhone.this.handleTerminate(LOCAL_TERMINATE);
           }
         });
     ad.show();
   }
 }
Пример #10
0
 private void handlePerformingHandshake() {
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_performing_handshake));
 }
Пример #11
0
 private void handleRecipientUnavailable() {
   state = STATE_IDLE;
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_recipient_unavailable));
   delayedFinish();
 }
Пример #12
0
 private void handleConnectingToInitiator() {
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_connecting));
 }
Пример #13
0
 private void handleCallRinging() {
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_ringing));
 }
Пример #14
0
 private void handleOutgoingCall(String remoteNumber) {
   state = STATE_DIALING;
   callScreen.setActiveCall(
       PersonInfo.getInstance(this, remoteNumber), getString(R.string.RedPhone_dialing));
 }
Пример #15
0
 private void handleIncomingCall(String remoteNumber) {
   state = STATE_RINGING;
   callScreen.setIncomingCall(PersonInfo.getInstance(this, remoteNumber));
 }