示例#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));
 }