Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93ddd210 authored by Hemant Gupta's avatar Hemant Gupta Committed by Android Git Automerger
Browse files

am 8567b5b1: am 9c3aff47: SAP: Fix missing connect response when call ongoing at connect

* commit '8567b5b1':
  SAP: Fix missing connect response when call ongoing at connect
parents db594682 8567b5b1
Loading
Loading
Loading
Loading
+22 −13
Original line number Diff line number Diff line
@@ -422,7 +422,10 @@ public class SapServer extends Thread implements Callback {
             *        - Initiate a FORCED shutdown
             *        - Wait for RIL deinit to complete
             */
            if(mState != SAP_STATE.DISCONNECTED) {
            if (mState == SAP_STATE.CONNECTING_CALL_ONGOING) {
                /* Most likely remote device closed rfcomm, update state */
                changeState(SAP_STATE.DISCONNECTED);
            } else if (mState != SAP_STATE.DISCONNECTED) {
                if(mState != SAP_STATE.DISCONNECTING &&
                        mIsLocalInitDisconnect != true) {
                    sendDisconnectInd(SapMessage.DISC_FORCED);
@@ -509,7 +512,6 @@ public class SapServer extends Thread implements Callback {
            if (isCallOngoing() == true) {
                /* If a call is ongoing we set the state, inform the SAP client and wait for a state
                 * change intent from the TelephonyManager with state IDLE. */
                changeState(SAP_STATE.CONNECTING_CALL_ONGOING);
                reply.setConnectionStatus(SapMessage.CON_STATUS_OK_ONGOING_CALL);
            } else {
                /* no call is ongoing, initiate the connect sequence:
@@ -651,11 +653,12 @@ public class SapServer extends Thread implements Callback {

        if(DEBUG) Log.i(TAG_HANDLER, "in Shutdown()");
        try {
            if (mRfcommOut != null)
                mRfcommOut.close();
        } catch (IOException e) {}
        try {
            if (mRfcommIn != null)
                mRfcommIn.close();

        } catch (IOException e) {}
        mRfcommIn = null;
        mRfcommOut = null;
@@ -714,19 +717,25 @@ public class SapServer extends Thread implements Callback {
            switch(sapMsg.getMsgType()) {

                case SapMessage.ID_CONNECT_RESP:
                    if (sapMsg.getConnectionStatus() == SapMessage.CON_STATUS_OK) {
                        // This is successful connect response from RIL/modem.
                        changeState(SAP_STATE.CONNECTED);
                    } else if(sapMsg.getConnectionStatus() == SapMessage.CON_STATUS_OK_ONGOING_CALL
                              && mState != SAP_STATE.CONNECTING_CALL_ONGOING) {
                        changeState(SAP_STATE.CONNECTING_CALL_ONGOING);
                    } else if(mState == SAP_STATE.CONNECTING_CALL_ONGOING) {
                    if(mState == SAP_STATE.CONNECTING_CALL_ONGOING) {
                        /* Hold back the connect resp if a call was ongoing when the connect req
                         * was received.
                         * A response with status call-ongoing was sent, and the connect response
                         * received from the RIL when call ends must be discarded.
                         */
                        if (sapMsg.getConnectionStatus() == SapMessage.CON_STATUS_OK) {
                            // This is successful connect response from RIL/modem.
                            changeState(SAP_STATE.CONNECTED);
                        }
                        if(VERBOSE) Log.i(TAG, "Hold back the connect resp, as a call was ongoing" +
                                " when the initial response were sent.");
                        sapMsg = null;
                    } else if (sapMsg.getConnectionStatus() == SapMessage.CON_STATUS_OK) {
                        // This is successful connect response from RIL/modem.
                        changeState(SAP_STATE.CONNECTED);
                    } else if(sapMsg.getConnectionStatus() ==
                            SapMessage.CON_STATUS_OK_ONGOING_CALL) {
                        changeState(SAP_STATE.CONNECTING_CALL_ONGOING);
                    } else if(sapMsg.getConnectionStatus() != SapMessage.CON_STATUS_OK) {
                        /* Most likely the peer will try to connect again, hence we keep the
                         * connection to RIL open and stay in connecting state.