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

Commit 5488b8a7 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Change to not notify all of connected if EVENT_DISCONNECT is pending

Bug: 23067429
Change-Id: Ic3405608d7aadcf14b38e0ce4e35f7dcd1be0bf2
parent f6188dcc
Loading
Loading
Loading
Loading
+28 −10
Original line number Diff line number Diff line
@@ -1770,8 +1770,17 @@ public final class DataConnection extends StateMachine {
                log("DcActiveState: connected after retrying call notifyAllOfConnected");
                mRetryManager.setRetryCount(0);
            }

            boolean createNetworkAgent = true;
            // If a disconnect is already pending, avoid notifying all of connected
            if (DataConnection.this.getHandler().hasMessages(EVENT_DISCONNECT) ||
                    DataConnection.this.getHandler().hasMessages(EVENT_DISCONNECT_ALL)) {
                log("DcActiveState: skipping notifyAllOfConnected()");
                createNetworkAgent = false;
            } else {
                // If we were retrying there maybe more than one, otherwise they'll only be one.
                notifyAllOfConnected(Phone.REASON_CONNECTED);
            }

            mPhone.getCallTracker().registerForVoiceCallStarted(getHandler(),
                    DataConnection.EVENT_DATA_CONNECTION_VOICE_CALL_STARTED, null);
@@ -1790,10 +1799,13 @@ public final class DataConnection extends StateMachine {

            final NetworkMisc misc = new NetworkMisc();
            misc.subscriberId = mPhone.getSubscriberId();

            if (createNetworkAgent) {
                mNetworkAgent = new DcNetworkAgent(getHandler().getLooper(), mPhone.getContext(),
                        "DcNetworkAgent", mNetworkInfo, makeNetworkCapabilities(), mLinkProperties,
                        50, misc);
            }
        }

        @Override
        public void exit() {
@@ -1811,9 +1823,11 @@ public final class DataConnection extends StateMachine {

            mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED,
                    reason, mNetworkInfo.getExtraInfo());
            if (mNetworkAgent != null) {
                mNetworkAgent.sendNetworkInfo(mNetworkInfo);
                mNetworkAgent = null;
            }
        }

        @Override
        public boolean processMessage(Message msg) {
@@ -1906,13 +1920,17 @@ public final class DataConnection extends StateMachine {
                }
                case EVENT_DATA_CONNECTION_ROAM_ON: {
                    mNetworkInfo.setRoaming(true);
                    if (mNetworkAgent != null) {
                        mNetworkAgent.sendNetworkInfo(mNetworkInfo);
                    }
                    retVal = HANDLED;
                    break;
                }
                case EVENT_DATA_CONNECTION_ROAM_OFF: {
                    mNetworkInfo.setRoaming(false);
                    if (mNetworkAgent != null) {
                        mNetworkAgent.sendNetworkInfo(mNetworkInfo);
                    }
                    retVal = HANDLED;
                    break;
                }
@@ -1936,7 +1954,7 @@ public final class DataConnection extends StateMachine {
                }
                case EVENT_DATA_CONNECTION_VOICE_CALL_STARTED:
                case EVENT_DATA_CONNECTION_VOICE_CALL_ENDED: {
                    if (updateNetworkInfoSuspendState()) {
                    if (updateNetworkInfoSuspendState() && mNetworkAgent != null) {
                        // state changed
                        mNetworkAgent.sendNetworkInfo(mNetworkInfo);
                    }