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

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

Fallback if the preference is already changed

When DcTracker is about to handover the data connection,
if we find the preference already changed back to the source
transport, then we just fallback to the source transport.

Bug: 189475714
Test: atest DcTrackerTest
Change-Id: I1ecc6160a35216a80c9edde60766008ef4a0098d
parent 3c5a43e3
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1647,7 +1647,12 @@ public class DcTracker extends Handler {
            if (DBG) log(str.toString());
            apnContext.requestLog(str.toString());
            if (requestType == REQUEST_TYPE_HANDOVER) {
                sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, false);
                // If fails due to latest preference already changed back to source transport, then
                // just fallback (will not attempt handover anymore, and will not tear down the
                // data connection on source transport.
                boolean fallback = dataConnectionReasons.contains(
                        DataDisallowedReasonType.ON_OTHER_TRANSPORT);
                sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, fallback);
            }
            return;
        }
+16 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.net.NetworkPolicyManager;
import android.net.NetworkRequest;
import android.net.Uri;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
@@ -2982,4 +2983,19 @@ public class DcTrackerTest extends TelephonyTest {
        // Ensure handover is not completed yet
        verify(handler, never()).sendMessageDelayed(any(), anyLong());
    }

    @Test
    public void testPreferenceChangedFallback() {
        Handler handler = Mockito.mock(Handler.class);
        doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WLAN).when(mTransportManager)
                .getPreferredTransport(anyInt());
        Message handoverCompleteMessage = Message.obtain(handler);
        addHandoverCompleteMsg(handoverCompleteMessage, ApnSetting.TYPE_IMS);
        initApns(ApnSetting.TYPE_IMS_STRING, new String[]{ApnSetting.TYPE_IMS_STRING});
        mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_HANDOVER,
                handoverCompleteMessage);
        waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
        Bundle bundle = handoverCompleteMessage.getData();
        assertTrue(bundle.getBoolean("extra_handover_failure_fallback"));
    }
}