private void initializeResources() { callScreen = (CallScreen) findViewById(R.id.callScreen); state = STATE_IDLE; callScreen.setHangupButtonListener(new HangupButtonListener()); callScreen.setIncomingCallActionListener(new IncomingCallActionListener()); DirectoryUpdateReceiver.scheduleDirectoryUpdate(this); }
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; } }
private void handleLoginFailed() { state = STATE_IDLE; callScreen.setActiveCall( redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_login_failed_exclamation)); delayedFinish(); }
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(); }
private void handleCallBusy() { callScreen.setActiveCall( redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_busy)); state = STATE_IDLE; delayedFinish(BUSY_SIGNAL_DELAY_FINISH); }
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); }
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(); }
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(); }
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(); } }
private void handlePerformingHandshake() { callScreen.setActiveCall( redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_performing_handshake)); }
private void handleRecipientUnavailable() { state = STATE_IDLE; callScreen.setActiveCall( redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_recipient_unavailable)); delayedFinish(); }
private void handleConnectingToInitiator() { callScreen.setActiveCall( redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_connecting)); }
private void handleCallRinging() { callScreen.setActiveCall( redPhoneService.getRemotePersonInfo(), getString(R.string.RedPhone_ringing)); }
private void handleOutgoingCall(String remoteNumber) { state = STATE_DIALING; callScreen.setActiveCall( PersonInfo.getInstance(this, remoteNumber), getString(R.string.RedPhone_dialing)); }
private void handleIncomingCall(String remoteNumber) { state = STATE_RINGING; callScreen.setIncomingCall(PersonInfo.getInstance(this, remoteNumber)); }