public PhonyConnection(SipAudioCall sipCall) throws SipException { Log.d(TAG, "PhonyConnection: called."); setInitializing(); setAudioModeIsVoip(true); setConnectionCapabilities(CAPABILITY_MUTE); mSipCall = sipCall; mSipCall.setListener(mSipListener); }
@Override public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) { Log.d(TAG, "onCreateIncomingConnection: called."); if (request.getExtras() == null) { return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "No extras on request.")); } Intent sipIntent = request.getExtras().getParcelable(EXTRA_INCOMING_CALL_INTENT); if (sipIntent == null) { return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "No SIP intent.")); } try { SipAudioCall audioCall = PhonySipUtil.getSipManager(this).takeAudioCall(sipIntent, null); PhonyConnection connection = new PhonyConnection(audioCall); connection.setAddress(Uri.parse(audioCall.getPeerProfile().getUriString()), TelecomManager.PRESENTATION_ALLOWED); connection.setInitialized(); return connection; } catch (SipException e) { e.printStackTrace(); return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "SipExecption", "Check the stack trace for more information.", e.getLocalizedMessage())); } }
@Override public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) { Log.d(TAG, "onCreateOutgoingConnection: called."); try { SipAudioCall audioCall = PhonySipUtil.getSipManager(this).makeAudioCall(connectionManagerPhoneAccount.getId(), Uri.decode(request.getAddress().toString()), null, PhonySipUtil.EXPIRY_TIME); PhonyConnection connection = new PhonyConnection(audioCall); connection.setAddress(request.getAddress(), TelecomManager.PRESENTATION_ALLOWED); connection.setInitialized(); return connection; } catch (SipException e) { e.printStackTrace(); return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "SipExecption", "Check the stack trace for more information.", e.getLocalizedMessage())); } }
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case CALL_ADDRESS: showDialog(CALL_ADDRESS); break; case SET_AUTH_INFO: updatePreferences(); break; case HANG_UP: if (mSipAudioCall != null) { try { mSipAudioCall.endCall(); } catch (SipException se) { Log.d("WalkieActivity", "Error ending mSipAudioCall.", se); } mSipAudioCall.close(); } break; } return true; }
@Override public void onDisconnect() { Log.d(TAG, "onDisconnect: called."); try { mSipCall.endCall(); setDisconnected(new DisconnectCause(DisconnectCause.LOCAL)); destroy(); } catch (SipException e) { e.printStackTrace(); } }
@Override public void onAnswer() { Log.d(TAG, "onAnswer: called."); try { mSipCall.answerCall(PhonySipUtil.EXPIRY_TIME); } catch (SipException e) { e.printStackTrace(); setDisconnected(new DisconnectCause(DisconnectCause.ERROR, "SipExecption", "Check the stack trace for more information.", e.getLocalizedMessage())); } }
@Override public void onReject() { Log.d(TAG, "onReject: called."); try { mSipCall.endCall(); } catch (SipException e) { e.printStackTrace(); setDisconnected(new DisconnectCause(DisconnectCause.ERROR, "SipExecption", "Check the stack trace for more information.", e.getLocalizedMessage())); } }
private void endPhone() { try { if (call != null) { call.endCall(); call.close(); updateStatus(STATE_CONNECTED); } } catch (SipException e) { e.printStackTrace(); } }
private void closeLocalProfile() { if (sipManager == null) return; if (sipProfile != null) { try { sipManager.close(sipProfile.getUriString()); } catch (SipException e) { e.printStackTrace(); Log.e(TAG, "Failed to close SipProfile: " + e.getMessage()); } } }
public AfricasTalkingException(SipException sip) { super(sip.getCause()); }