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

Commit e3515e45 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed the data switch issue

Fixed the network detached and re-attached to a new data network
needs to be handled properly.

Fix: 380370027
Test: atest DataNetworkTest
Test: Basic telephony functionality tests
Test: DDS on SIM 1, make call on SIM 2, hang up call, repeat
Flag: EXEMPT bug fix
Change-Id: I35a2f1c7ab548734b11df38c3e1a1bf3105eb896
parent 7171466f
Loading
Loading
Loading
Loading
+21 −10
Original line number Diff line number Diff line
@@ -1394,9 +1394,15 @@ public class DataNetwork extends StateMachine {
                }
                case EVENT_DETACH_ALL_NETWORK_REQUESTS: {
                    for (TelephonyNetworkRequest networkRequest : mAttachedNetworkRequestList) {
                        networkRequest.setState(TelephonyNetworkRequest.REQUEST_STATE_UNSATISFIED);
                        // Check if the network request still belongs to this network, because
                        // during data switch, the network request can be attached to other network
                        // on a different SIM.
                        if (networkRequest.getAttachedNetwork() == DataNetwork.this) {
                            networkRequest.setState(
                                    TelephonyNetworkRequest.REQUEST_STATE_UNSATISFIED);
                            networkRequest.setAttachedNetwork(null);
                        }
                    }
                    log("All network requests detached.");
                    mAttachedNetworkRequestList.clear();
                    break;
@@ -2141,14 +2147,19 @@ public class DataNetwork extends StateMachine {
    private void onDetachNetworkRequest(@NonNull TelephonyNetworkRequest networkRequest,
            boolean shouldRetry) {
        mAttachedNetworkRequestList.remove(networkRequest);
        // Check if the network request still belongs to this network, because
        // during data switch, the network request can be attached to other network
        // on a different SIM.
        if (networkRequest.getAttachedNetwork() == DataNetwork.this) {
            networkRequest.setState(TelephonyNetworkRequest.REQUEST_STATE_UNSATISFIED);
            networkRequest.setAttachedNetwork(null);

            if (shouldRetry) {
                // Inform DataNetworkController that a network request was detached and should be
                // scheduled to retry.
            mDataNetworkCallback.invokeFromExecutor(
                    () -> mDataNetworkCallback.onRetryUnsatisfiedNetworkRequest(networkRequest));
                mDataNetworkCallback.invokeFromExecutor(() ->
                        mDataNetworkCallback.onRetryUnsatisfiedNetworkRequest(networkRequest));
            }
        }

        if (mAttachedNetworkRequestList.isEmpty()) {