0

I have a function in my VoIP dialer app that should call a service that terminates a call. So when an incoming call enters the phone via the app, there are options to decline and answer. When I click on the decline option, it seems to terminate the call from the app, but in reality the phone is still ringing from the other user's phone. Same thing also happens when i make an outgoing call via the app, and decide to terminate. It cancels the call from the app, but still rings on the outgoing number's phone.

Below is my code

type here
public void hangUp(View view) throws Exception {
        stopRingTone();
        SipServiceCommand.declineIncomingCall(this, uri, callID1);
    }

This is the declineIncomingCall method:

type here
public static void declineIncomingCall(Context context, String accountID, int callID) {
        checkAccount(accountID);
        if(isAccountValid) {
            Intent intent = new Intent(context, SipService.class);
            intent.setAction(ACTION_DECLINE_INCOMING_CALL);
            intent.putExtra(PARAM_ACCOUNT_ID, accountID);
            intent.putExtra(PARAM_CALL_ID, callID);
            context.startService(intent);
        }
    }

THis is to stop the ringtone which is actually called in the onDestroy of the RingtonePlayingService :

type here
public void stopRingTone() {
        Intent stopIntent = new Intent(getApplicationContext(), RingTonePlayingService.class);
        stopService(stopIntent);
    }

Below are sip services handling decline call:

private void handleDeclineIncomingCall(Intent intent) {
        String accountID = intent.getStringExtra(PARAM_ACCOUNT_ID);
        int callID = intent.getIntExtra(PARAM_CALL_ID, 0);

        SipCall sipCall = getCall(accountID, callID);
        if (sipCall != null) {
            try {
                sipCall.declineIncomingCall();
            } catch (Exception exc) {
                Logger.error(TAG, "Error while declining incoming call. AccountID: "
                        + getValue(getApplicationContext(), accountID) + ", CallID: " + callID);
            }
        }
    }
public void declineIncomingCall() {
        CallOpParam param = new CallOpParam();
        param.setStatusCode(pjsip_status_code.PJSIP_SC_DECLINE);

        try {
            answer(param);
        } catch (Exception exc) {
            Logger.error(LOG_TAG, "Failed to decline incoming call", exc);
        }
    }

Call to the Call.java class from our SIP library

 public void hangup(CallOpParam prm) throws java.lang.Exception {
    pjsua2JNI.Call_hangup(swigCPtr, this, CallOpParam.getCPtr(prm), prm);
  }

Debugging with log statements show that the code runs into the correct blocks as it should, but somehow, it's not working as it should. I'd appreciate any help

Oleohi
  • 86
  • 1
  • 5

0 Answers0