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

Commit 5be46018 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Fallback if the preference is already changed" into sc-dev

parents bf38a84c f6b978f4
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"));
    }
}