Search in sources :

Example 1 with SipService

use of com.voipgrid.vialer.sip.SipService in project vialer-android by VoIPGRID.

the class CallActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    if (mIncomingCallIsRinging && mPausedRinging) {
        mMediaManager.startIncomingCallRinger();
    }
    mPausedRinging = false;
    mRemoteLogger.d("onResume");
    // Bind the SipService to the activity.
    if (!mSipServiceBound && mSipService == null) {
        mRemoteLogger.i("SipService not bound!");
        if (bindService(new Intent(this, SipService.class), mSipServiceConnection, Context.BIND_AUTO_CREATE)) {
            mShouldUnbind = true;
        }
    }
    if (!mOnTransfer && mSipService != null && mSipService.getCurrentCall() != null) {
        if (mSipService.getCurrentCall().isOnHold()) {
            mRemoteLogger.d("SipService has call on hold");
            if (!mOnHold) {
                mRemoteLogger.i("But the activity DOES not have the call on hold. Match the sip service.");
                mOnHold = true;
                updateCallButton(R.id.button_onhold, true);
                onCallStatusUpdate(CALL_PUT_ON_HOLD_ACTION);
            } else if (!findViewById(R.id.button_onhold).isActivated()) {
                mRemoteLogger.i("Call is on hold but the button is not active. Update the button");
                updateCallButton(R.id.button_onhold, true);
            }
        }
    }
    // Make sure service is bound before updating status.
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            if (!mSipServiceBound) {
                finishWithDelay();
            } else if (mSipService.getCurrentCall() == null) {
                mRemoteLogger.d("runnable in onResume Current Call is null");
                onCallStatusUpdate(CALL_DISCONNECTED_MESSAGE);
            }
        }
    }, MAX_ALLOWED_MS_TO_BIND_SIP_SERVICE);
}
Also used : Handler(android.os.Handler) Intent(android.content.Intent) SipService(com.voipgrid.vialer.sip.SipService)

Example 2 with SipService

use of com.voipgrid.vialer.sip.SipService in project vialer-android by VoIPGRID.

the class AccountActivity method onCheckedChanged.

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (mPreferences.hasSipEnabled() == isChecked) {
        /* nothing changed, so return */
        return;
    }
    mPreferences.setSipEnabled(isChecked);
    if (!isChecked) {
        // Unregister at middleware.
        MiddlewareHelper.unregister(this);
        // Stop the sipservice.
        stopService(new Intent(this, SipService.class));
        mSipIdEditText.setVisibility(View.GONE);
    } else {
        enableProgressBar(true);
        new AsyncTask<Void, Void, PhoneAccount>() {

            @Override
            protected PhoneAccount doInBackground(Void... params) {
                return mPhoneAccountHelper.getLinkedPhoneAccount();
            }

            @Override
            protected void onPostExecute(PhoneAccount phoneAccount) {
                super.onPostExecute(phoneAccount);
                if (phoneAccount != null) {
                    mPhoneAccountHelper.savePhoneAccountAndRegister(phoneAccount);
                    updateAndPopulate();
                } else {
                    // Make sure sip is disabled in preference and the switch is returned
                    // to disabled. Setting disabled in the settings first makes sure
                    // the onCheckChanged does not execute the code that normally is executed
                    // on a change in the check of the switch.
                    setVoIPAccount();
                }
            }
        }.execute();
    }
}
Also used : PhoneAccount(com.voipgrid.vialer.api.models.PhoneAccount) Intent(android.content.Intent) SipService(com.voipgrid.vialer.sip.SipService)

Aggregations

Intent (android.content.Intent)2 SipService (com.voipgrid.vialer.sip.SipService)2 Handler (android.os.Handler)1 PhoneAccount (com.voipgrid.vialer.api.models.PhoneAccount)1