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

Commit 28c071a8 authored by Ling Ma's avatar Ling Ma Committed by Android (Google) Code Review
Browse files

Merge "Handle source PDN lost during HO"

parents 02db1669 b16e6d72
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -1417,6 +1417,13 @@ public class DataNetwork extends StateMachine {
                                + AccessNetworkConstants.transportTypeToString(transport)
                                + " data call list changed event. " + responseList);
                    } else {
                        // If source PDN is reported lost, notify network agent that the PDN is
                        // temporarily suspended and the old interface name is no longer usable.
                        boolean currentPdnIsAlive = responseList.stream()
                                .anyMatch(r -> mCid.get(mTransport) == r.getId());
                        if (!currentPdnIsAlive) {
                            notifyNetworkUnusable();
                        }
                        log("Defer message " + eventToString(msg.what) + ":" + responseList);
                        deferMessage(msg);
                    }
@@ -1464,6 +1471,25 @@ public class DataNetwork extends StateMachine {
            }
            return HANDLED;
        }

        /**
         * Notify network agent that the PDN is temporarily suspended and the old interface name is
         * no longer usable. The state will be re-evaluated when the handover ends.
         */
        private void notifyNetworkUnusable() {
            log(AccessNetworkConstants.transportTypeToString(mTransport)
                    + " reports current PDN lost, update capability to SUSPENDED,"
                    + " TNA interfaceName to \"\"");
            mNetworkCapabilities = new NetworkCapabilities
                    .Builder(mNetworkCapabilities)
                    .removeCapability(
                            NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED)
                    .build();
            mNetworkAgent.sendNetworkCapabilities(mNetworkCapabilities);

            mLinkProperties.setInterfaceName("");
            mNetworkAgent.sendLinkProperties(mLinkProperties);
        }
    }

    /**
+19 −1
Original line number Diff line number Diff line
@@ -989,12 +989,30 @@ public class DataNetworkTest extends TelephonyTest {
    public void testHandover() throws Exception {
        setupDataNetwork();

        setSuccessfulSetupDataResponse(mMockedWlanDataServiceManager, 456);
        // Now handover to IWLAN
        mDataNetworkUT.startHandover(AccessNetworkConstants.TRANSPORT_TYPE_WLAN, null);
        // the source transport might report PDN lost
        mDataNetworkUT.sendMessage(8/*EVENT_DATA_STATE_CHANGED*/,
                new AsyncResult(AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                        Collections.emptyList(), null));
        processAllMessages();

        // make sure interface name of source PDN is cleared
        assertThat(mDataNetworkUT.getLinkProperties().getInterfaceName()).isNotEqualTo("ifname");
        // make sure the capability of source PDN is set to SUSPENDED
        assertThat(mDataNetworkUT.getNetworkCapabilities()
                .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED)).isFalse();
        verify(mMockedWwanDataServiceManager).startHandover(eq(123), any(Message.class));

        // continue the HO
        setSuccessfulSetupDataResponse(mMockedWlanDataServiceManager, 456);
        Message msg = new Message();
        msg.what = 26/*EVENT_NOTIFY_HANDOVER_STARTED_RESPONSE*/;
        msg.arg2 = AccessNetworkConstants.TRANSPORT_TYPE_WLAN;
        msg.obj = null;
        mDataNetworkUT.sendMessage(msg);
        processAllMessages();

        verify(mLinkBandwidthEstimator).unregisterCallback(any(
                LinkBandwidthEstimatorCallback.class));
        assertThat(mDataNetworkUT.getTransport())