Example #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);
  }
Example #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;
          }
        }
Example #3
0
 private void handleLoginFailed() {
   state = STATE_IDLE;
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(),
       getString(R.string.RedPhone_login_failed_exclamation));
   delayedFinish();
 }
Example #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();
 }
Example #5
0
  private void handleCallBusy() {
    callScreen.setActiveCall(
        redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_busy));

    state = STATE_IDLE;
    delayedFinish(BUSY_SIGNAL_DELAY_FINISH);
  }
Example #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);
  }
Example #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();
  }
Example #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();
  }
Example #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();
   }
 }
Example #10
0
 private void handlePerformingHandshake() {
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_performing_handshake));
 }
Example #11
0
 private void handleRecipientUnavailable() {
   state = STATE_IDLE;
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_recipient_unavailable));
   delayedFinish();
 }
Example #12
0
 private void handleConnectingToInitiator() {
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_connecting));
 }
Example #13
0
 private void handleCallRinging() {
   callScreen.setActiveCall(
       redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_ringing));
 }
Example #14
0
 private void handleOutgoingCall(String remoteNumber) {
   state = STATE_DIALING;
   callScreen.setActiveCall(
       PersonInfo.getInstance(this, remoteNumber), getString(R.string.RedPhone_dialing));
 }
Example #15
0
 private void handleIncomingCall(String remoteNumber) {
   state = STATE_RINGING;
   callScreen.setIncomingCall(PersonInfo.getInstance(this, remoteNumber));
 }