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

Commit 9c819ed0 authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

Fixed that data call setup failed after default data SIM switches

am: 0979b71e

* commit '0979b71e':
  Fixed that data call setup failed after default data SIM switches

Change-Id: I91ae8f6437a457c3bfa786af3be639bdff8e480f
parents cd0093ea 0979b71e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -823,7 +823,7 @@ public class SubscriptionController extends ISub.Stub {
            }

            // Once the records are loaded, notify DcTracker
            updateAllDataConnectionTrackers();
            sPhones[slotId].updateDataConnectionTracker();

            if (DBG) logdl("[addSubInfoRecord]- info size=" + sSlotIdxToSubId.size());

+1 −0
Original line number Diff line number Diff line
@@ -3988,6 +3988,7 @@ public class DcTracker extends Handler {
        onUpdateIcc();

        mUserDataEnabled = getDataEnabled();
        mAutoAttachOnCreation.set(false);

        ((GsmCdmaPhone)mPhone).updateCurrentCarrierInProvider();
    }
+28 −6
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
@@ -233,10 +234,10 @@ public class SubscriptionControllerTest extends TelephonyTest {
        assertEquals(disNum, subInfo.getNumber());

        /* verify broadcast intent */
        ArgumentCaptor<Intent> mCaptorIntent = ArgumentCaptor.forClass(Intent.class);
        verify(mContext, atLeast(1)).sendBroadcast(mCaptorIntent.capture());
        ArgumentCaptor<Intent> captorIntent = ArgumentCaptor.forClass(Intent.class);
        verify(mContext, atLeast(1)).sendBroadcast(captorIntent.capture());
        assertEquals(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED,
                mCaptorIntent.getValue().getAction());
                captorIntent.getValue().getAction());
    }

    @Test @SmallTest
@@ -281,9 +282,30 @@ public class SubscriptionControllerTest extends TelephonyTest {
        assertEquals(Integer.parseInt(mCcMncVERIZON.substring(3)), subInfo.getMnc());

         /* verify broadcast intent */
        ArgumentCaptor<Intent> mCaptorIntent = ArgumentCaptor.forClass(Intent.class);
        verify(mContext, atLeast(1)).sendBroadcast(mCaptorIntent.capture());
        ArgumentCaptor<Intent> captorIntent = ArgumentCaptor.forClass(Intent.class);
        verify(mContext, atLeast(1)).sendBroadcast(captorIntent.capture());
        assertEquals(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED,
                mCaptorIntent.getValue().getAction());
                captorIntent.getValue().getAction());
    }

    @Test
    @SmallTest
    public void testSetDefaultDataSubId() throws Exception {
        doReturn(1).when(mPhone).getSubId();

        mSubscriptionControllerUT.setDefaultDataSubId(1);

        verify(mPhone, times(1)).updateDataConnectionTracker();
        ArgumentCaptor<Intent> captorIntent = ArgumentCaptor.forClass(Intent.class);
        verify(mContext, times(1)).sendStickyBroadcastAsUser(
                captorIntent.capture(), eq(UserHandle.ALL));

        Intent intent = captorIntent.getValue();
        assertEquals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED, intent.getAction());

        Bundle b = intent.getExtras();

        assertTrue(b.containsKey(PhoneConstants.SUBSCRIPTION_KEY));
        assertEquals(1, b.getInt(PhoneConstants.SUBSCRIPTION_KEY));
    }
}
+70 −1
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.content.Intent;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.LinkProperties;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.net.Uri;
import android.os.HandlerThread;
import android.os.IBinder;
@@ -36,6 +38,7 @@ import android.telephony.ServiceState;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.MediumTest;
import android.util.LocalLog;

import com.android.internal.telephony.DctConstants;
import com.android.internal.telephony.ISub;
@@ -97,6 +100,8 @@ public class DcTrackerTest extends TelephonyTest {
    ISub mIsub;
    @Mock
    IBinder mBinder;
    @Mock
    NetworkRequest mNetworkRequest;

    private DcTracker mDct;

@@ -349,7 +354,6 @@ public class DcTrackerTest extends TelephonyTest {
        assertEquals(apnSetting, mDct.getActiveApnString(PhoneConstants.APN_TYPE_DEFAULT));
        assertArrayEquals(new String[]{PhoneConstants.APN_TYPE_DEFAULT}, mDct.getActiveApnTypes());
        assertTrue(mDct.getAnyDataEnabled());
        assertTrue(mDct.getDataEnabled());

        assertEquals(DctConstants.State.CONNECTED, mDct.getOverallState());
        assertEquals(DctConstants.State.CONNECTED, mDct.getState(PhoneConstants.APN_TYPE_DEFAULT));
@@ -379,6 +383,8 @@ public class DcTrackerTest extends TelephonyTest {
    @MediumTest
    public void testDataSetup() {

        mDct.setDataEnabled(true);

        mSimulatedCommands.setDataCallResponse(true, createDataCallResponse());

        StringBuilder sb = new StringBuilder();
@@ -435,6 +441,9 @@ public class DcTrackerTest extends TelephonyTest {
    @Test
    @MediumTest
    public void testDataRetry() {

        mDct.setDataEnabled(true);

        DataCallResponse dcResponse = createDataCallResponse();
        // LOST_CONNECTION(0x10004) is a non-permanent failure, so we'll retry data setup later.
        dcResponse.status = 0x10004;
@@ -608,4 +617,64 @@ public class DcTrackerTest extends TelephonyTest {
        mDct.setDataOnRoamingEnabled(roamingEnabled);
        waitForMs(200);
    }

    // Test the default data switch scenario.
    @Test
    @MediumTest
    public void testDDSResetAutoAttach() throws Exception {

        mDct.setDataEnabled(true);

        mContextFixture.putBooleanResource(
                com.android.internal.R.bool.config_auto_attach_data_on_creation, true);

        mSimulatedCommands.setDataCallResponse(true, createDataCallResponse());

        StringBuilder sb = new StringBuilder();
        boolean allowed = isDataAllowed(sb);
        assertFalse(sb.toString(), allowed);

        ArgumentCaptor<Integer> intArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
        verify(mUiccController, times(1)).registerForIccChanged(eq(mDct),
                intArgumentCaptor.capture(), eq(null));
        // Ideally this should send EVENT_ICC_CHANGED.
        mDct.sendMessage(mDct.obtainMessage(intArgumentCaptor.getValue(), null));
        waitForMs(100);

        verify(mSimRecords, times(1)).registerForRecordsLoaded(eq(mDct),
                intArgumentCaptor.capture(), eq(null));
        // Ideally this should send EVENT_RECORDS_LOADED.
        mDct.sendMessage(mDct.obtainMessage(intArgumentCaptor.getValue(), null));
        waitForMs(100);

        verify(mSST, times(1)).registerForDataConnectionAttached(eq(mDct),
                intArgumentCaptor.capture(), eq(null));
        // Ideally this should send EVENT_DATA_CONNECTION_ATTACHED");
        mDct.sendMessage(mDct.obtainMessage(intArgumentCaptor.getValue(), null));
        waitForMs(200);

        NetworkCapabilities nc = new NetworkCapabilities();
        nc.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
        NetworkRequest nr = new NetworkRequest(nc, 0, 0);
        LocalLog l = new LocalLog(100);
        mDct.requestNetwork(nr, l);
        waitForMs(200);

        verifyDataConnected(FAKE_APN1);

        assertTrue(mDct.getAutoAttachOnCreation());
        mDct.update();
        // The auto attach flag should be reset after update
        assertFalse(mDct.getAutoAttachOnCreation());

        verify(mSST, times(1)).registerForDataConnectionDetached(eq(mDct),
                intArgumentCaptor.capture(), eq(null));
        // Ideally this should send EVENT_DATA_CONNECTION_DETACHED
        mDct.sendMessage(mDct.obtainMessage(intArgumentCaptor.getValue(), null));
        waitForMs(200);

        // Data should not be allowed since auto attach flag has been reset.
        allowed = isDataAllowed(sb);
        assertFalse(sb.toString(), allowed);
    }
}