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

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

Fixed data connection stuck in activating state

Data connection stuck in activating state when not able
to find network agent from the source data connection. The fix
is similar to ag/13952867.

Fix: 194779636
Test: atest DataConnectionTest
Change-Id: Ief7e6cdbeed3be708dd056cd5284f18da9308606
parent 252716d4
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1037,6 +1037,8 @@ public class DataConnection extends StateMachine {
        }

        if (srcDc == null) {
            loge("requestHandover: Cannot find source data connection.");
            onRquestHandoverFailed(cp);
            return;
        }

@@ -1048,8 +1050,7 @@ public class DataConnection extends StateMachine {
        mHandoverSourceNetworkAgent = srcDc.getNetworkAgent();
        if (mHandoverSourceNetworkAgent == null) {
            loge("requestHandover: Cannot get network agent from the source dc " + srcDc.getName());
            notifyConnectCompleted(cp, DataFailCause.UNKNOWN,
                    DataCallResponse.HANDOVER_FAILURE_MODE_UNKNOWN, false);
            onRquestHandoverFailed(cp);
            return;
        }

@@ -1089,7 +1090,8 @@ public class DataConnection extends StateMachine {
    /**
     * Called on the source data connection from the target data connection.
     */
    private void startHandover(Consumer<Integer> onTargetDcComplete) {
    @VisibleForTesting
    public void startHandover(Consumer<Integer> onTargetDcComplete) {
        logd("startHandover: " + toStringSimple());
        // Set the handover state to being transferred on "this" data connection which is the src.
        setHandoverState(HANDOVER_STATE_BEING_TRANSFERRED);
+21 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.internal.telephony.dataconnection.DcTrackerTest.FAKE_P
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
@@ -89,6 +90,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;

public class DataConnectionTest extends TelephonyTest {
    private static final int DEFAULT_DC_CID = 10;
@@ -1359,4 +1361,23 @@ public class DataConnectionTest extends TelephonyTest {
        verify(mDataThrottler).setRetryTime(eq(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_SUPL),
                eq(RetryManager.NO_SUGGESTED_RETRY_DELAY), eq(DcTracker.REQUEST_TYPE_NORMAL));
    }

    @Test
    public void testDataHandoverFailed() throws Exception {
        doReturn(mDefaultDc).when(mDcTracker).getDataConnectionByApnType(anyString());

        doAnswer(invocation -> {
            final Consumer<Integer> consumer = (Consumer<Integer>) invocation.getArguments()[0];
            consumer.accept(DataServiceCallback.RESULT_SUCCESS);
            return null;
        }).when(mDefaultDc).startHandover(any(Consumer.class));

        replaceInstance(ConnectionParams.class, "mRequestType", mCp,
                DcTracker.REQUEST_TYPE_HANDOVER);
        assertTrue(mDc.isInactive());
        connectEvent(false);

        // Make sure the data connection is still in inactive state
        assertTrue(mDc.isInactive());
    }
}