datso / react-native-pjsip

A PJSIP module for React Native.
http://datso.github.io/react-native-pjsip
GNU General Public License v3.0
272 stars 229 forks source link

Android call put on hold when interrupted by another and never gets back #137

Open Elf2707 opened 5 years ago

Elf2707 commented 5 years ago

I don't know is it a bug or not, but I found if user in the middle of the sip call gets GSM incoming call sip call goes to hold state and never come back to connected state.

As I understand it happens in this receiver:

private void doPauseAllCalls() {
      for (PjSipCall call : mCalls) {
           try {
                call.hold();
            } catch (Exception e) {
                Log.w(TAG, "Failed to put call on hold", e);
            }
        }
    }

protected class PhoneStateChangedReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            final String extraState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);

            if (TelephonyManager.EXTRA_STATE_RINGING.equals(extraState) || TelephonyManager.EXTRA_STATE_OFFHOOK.equals(extraState)) {
                Log.d(TAG, "GSM call received, pause all SIP calls and do not accept incoming SIP calls.");

                mGSMIdle = false;

                job(new Runnable() {
                    @Override
                    public void run() {
                        doPauseAllCalls();
                    }
                });
            } else if (TelephonyManager.EXTRA_STATE_IDLE.equals(extraState)) {
                Log.d(TAG, "GSM call released, allow to accept incoming calls.");
                mGSMIdle = true;
            }
        }
    }

As we could see here doPuseAllCalls calls when receiving GSM call, but nothing calls then GSM call released. Is this intentional behavior and user should handle unholding by himself for some reason?