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

Commit 20f35fcf authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Fixed data connection stuck in activating state am: c46a1044

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/15418964

Change-Id: I6085703aae3b29c289442c643e5f7292546140bb
parents 9c97f570 c46a1044
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1038,6 +1038,8 @@ public class DataConnection extends StateMachine {
        }

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

@@ -1049,8 +1051,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;
        }

@@ -1090,7 +1091,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());
    }
}