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

Commit 073c2df6 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed that data was created in suspended state

Fixed a regression introduced by ag/15133908. The network
was created when the device was out of service, then connectivity
service saw the data state changed from CONNECTING to SUSPENDED.
The fix is always creating the data with NOT_SUSPENDED capability,
then immediately update the suspended state after that. (In fact
we already used this mechanism in aosp/1443087)

Test: atest DataConnectionTest
Fix: 193847808
Change-Id: I4217bb1715d9fb576579512226d6a68d440fb99d
parent e11b6b6a
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -2919,11 +2919,6 @@ public class DataConnection extends StateMachine {

                mDisabledApnTypeBitMask |= getDisallowedApnTypes();
                updateLinkPropertiesHttpProxy();
                // The suspended state is only meaningful when data is in active state. We need to
                // make sure the suspended state is correct as soon as we enter active state.
                // After this, the network agent will be created with the correct suspended state
                // (i.e. NOT_SUSPENDED capability).
                updateSuspendState();
                mNetworkAgent = new DcNetworkAgent(DataConnection.this, mPhone, mScore,
                        configBuilder.build(), provider, mTransportType);

+25 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

@@ -46,6 +47,7 @@ import android.net.KeepalivePacketData;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.NattKeepalivePacketData;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.os.AsyncResult;
import android.os.Handler;
@@ -1320,6 +1322,29 @@ public class DataConnectionTest extends TelephonyTest {
        assertTrue(isSuspended());
    }

    @Test
    public void testDataCreatedWhenOutOfService() throws Exception {
        serviceStateChangedEvent(ServiceState.STATE_OUT_OF_SERVICE,
                ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN);
        ArgumentCaptor<NetworkCapabilities> ncCaptor =
                ArgumentCaptor.forClass(NetworkCapabilities.class);
        doReturn(mock(Network.class)).when(mConnectivityManager).registerNetworkAgent(
                any(), any(), any(), ncCaptor.capture(), any(), any(), anyInt());

        doReturn(mApn1).when(mApnContext).getApnSetting();
        doReturn(ApnSetting.TYPE_DEFAULT).when(mApnContext).getApnTypeBitmask();
        doReturn(true).when(mSST).isConcurrentVoiceAndDataAllowed();
        connectEvent(true);
        waitForMs(100);

        NetworkCapabilities nc = ncCaptor.getValue();
        // The network must be created with NOT_SUSPENDED capability.
        assertTrue(nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED));

        // But it's final state must be suspended.
        assertTrue(isSuspended());
    }

    @Test
    public void testDataServiceTempUnavailable() throws Exception {
        setFailedSetupDataResponse(DataServiceCallback.RESULT_ERROR_TEMPORARILY_UNAVAILABLE);