Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java +16 −16 Original line number Diff line number Diff line Loading @@ -16,6 +16,19 @@ package com.android.internal.telephony.dataconnection; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_ALL; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_DEFAULT; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_HIPRI; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_IA; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_MMS; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_SUPL; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.junit.Assert.assertEquals; import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; import android.test.suitebuilder.annotation.SmallTest; Loading @@ -24,7 +37,6 @@ import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyTest; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; Loading @@ -33,18 +45,6 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_ALL; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_DEFAULT; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_HIPRI; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_IA; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_MMS; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_SUPL; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.junit.Assert.assertEquals; public class ApnSettingTest extends TelephonyTest { private PersistableBundle mBundle; Loading @@ -61,15 +61,15 @@ public class ApnSettingTest extends TelephonyTest { super.tearDown(); } private ApnSetting createApnSetting(String[] apnTypes) { static ApnSetting createApnSetting(String[] apnTypes) { return createApnSettingInternal(apnTypes, true); } private ApnSetting createDisabledApnSetting(String[] apnTypes) { private static ApnSetting createDisabledApnSetting(String[] apnTypes) { return createApnSettingInternal(apnTypes, false); } private ApnSetting createApnSettingInternal(String[] apnTypes, boolean carrierEnabled) { private static ApnSetting createApnSettingInternal(String[] apnTypes, boolean carrierEnabled) { return new ApnSetting( 2163, // id "44010", // numeric Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java +197 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony.dataconnection; import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; import static com.android.internal.telephony.dataconnection.ApnSettingTest.createApnSetting; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; Loading Loading @@ -61,6 +62,7 @@ import android.telephony.SubscriptionManager; import android.test.mock.MockContentProvider; import android.test.mock.MockContentResolver; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import android.util.LocalLog; import com.android.internal.telephony.DctConstants; Loading Loading @@ -113,6 +115,12 @@ public class DcTrackerTest extends TelephonyTest { NetworkRequest mNetworkRequest; @Mock SubscriptionInfo mSubscriptionInfo; @Mock ApnContext mApnContext; @Mock ApnSetting mApnSetting; @Mock DcAsyncChannel mDcac; private DcTracker mDct; private DcTrackerTestHandler mDcTrackerTestHandler; Loading Loading @@ -337,6 +345,8 @@ public class DcTrackerTest extends TelephonyTest { mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mBundle = mContextFixture.getCarrierConfigBundle(); mSimulatedCommands.setDataCallResponse(true, createDataCallResponse()); mDcTrackerTestHandler = new DcTrackerTestHandler(getClass().getSimpleName()); mDcTrackerTestHandler.start(); waitUntilReady(); Loading Loading @@ -670,7 +680,6 @@ public class DcTrackerTest extends TelephonyTest { waitForMs(200); } @FlakyTest @Test @MediumTest public void testDataCallOnUserDisableRoaming() throws Exception { Loading @@ -680,13 +689,16 @@ public class DcTrackerTest extends TelephonyTest { boolean roamingEnabled = mDct.getDataRoamingEnabled(); boolean dataEnabled = mDct.getDataEnabled(); doReturn(true).when(mServiceState).getDataRoaming(); //set Default and MMS to be metered in the CarrierConfigManager mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_ROAMING_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS}); mDct.setEnabled(5, true); mDct.setEnabled(0, true); doReturn(true).when(mServiceState).getDataRoaming(); logd("Sending DATA_ENABLED_CMD"); mDct.setDataEnabled(true); logd("Sending DISABLE_ROAMING_CMD"); mDct.setDataRoamingEnabled(false); Loading @@ -699,9 +711,6 @@ public class DcTrackerTest extends TelephonyTest { mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); logd("Sending DATA_ENABLED_CMD"); mDct.setDataEnabled(true); waitForMs(200); verify(mSimulatedCommandsVerifier, times(1)).setInitialAttachApn(any(DataProfile.class), eq(true), nullable(Message.class)); Loading Loading @@ -826,4 +835,187 @@ public class DcTrackerTest extends TelephonyTest { mDct.setDataEnabled(dataEnabled); waitForMs(200); } private void initApns(String targetApn, String[] canHandleTypes) { doReturn(targetApn).when(mApnContext).getApnType(); doReturn(true).when(mApnContext).isConnectable(); ApnSetting apnSetting = createApnSetting(canHandleTypes); doReturn(apnSetting).when(mApnContext).getNextApnSetting(); doReturn(apnSetting).when(mApnContext).getApnSetting(); doReturn(mDcac).when(mApnContext).getDcAc(); doReturn(true).when(mApnContext).isEnabled(); doReturn(true).when(mApnContext).getDependencyMet(); doReturn(true).when(mApnContext).isReady(); doReturn(true).when(mApnContext).hasNoRestrictedRequests(eq(true)); } // Test the emergency APN setup. @Test @SmallTest public void testTrySetupDataEmergencyApn() throws Exception { initApns(PhoneConstants.APN_TYPE_EMERGENCY, new String[]{PhoneConstants.APN_TYPE_ALL}); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(1)).setupDataCall( eq(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the unmetered APN setup when data is disabled. @Test @SmallTest public void testTrySetupDataUnmeteredDataDisabled() throws Exception { initApns(PhoneConstants.APN_TYPE_FOTA, new String[]{PhoneConstants.APN_TYPE_ALL}); mDct.setDataEnabled(false); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(1)).setupDataCall( eq(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the metered APN setup when data is disabled. @Test @SmallTest public void testTrySetupMeteredDataDisabled() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); mDct.setDataEnabled(false); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(0)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the restricted data request when data is disabled. @Test @SmallTest public void testTrySetupRestrictedDataDisabled() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); doReturn(false).when(mApnContext).hasNoRestrictedRequests(eq(true)); mDct.setDataEnabled(false); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(1)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the default data when data is not connectable. @Test @SmallTest public void testTrySetupNotConnectable() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); doReturn(false).when(mApnContext).isConnectable(); mDct.setDataEnabled(true); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(0)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the default data on IWLAN. @Test @SmallTest public void testTrySetupDefaultOnIWLAN() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN).when(mServiceState) .getRilDataRadioTechnology(); mDct.setDataEnabled(true); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(0)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the default data when the phone is in ECBM. @Test @SmallTest public void testTrySetupDefaultInECBM() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); doReturn(true).when(mPhone).isInEcm(); mDct.setDataEnabled(true); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(0)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } } Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java +16 −16 Original line number Diff line number Diff line Loading @@ -16,6 +16,19 @@ package com.android.internal.telephony.dataconnection; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_ALL; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_DEFAULT; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_HIPRI; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_IA; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_MMS; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_SUPL; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.junit.Assert.assertEquals; import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; import android.test.suitebuilder.annotation.SmallTest; Loading @@ -24,7 +37,6 @@ import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyTest; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; Loading @@ -33,18 +45,6 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_ALL; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_DEFAULT; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_HIPRI; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_IA; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_MMS; import static com.android.internal.telephony.PhoneConstants.APN_TYPE_SUPL; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.junit.Assert.assertEquals; public class ApnSettingTest extends TelephonyTest { private PersistableBundle mBundle; Loading @@ -61,15 +61,15 @@ public class ApnSettingTest extends TelephonyTest { super.tearDown(); } private ApnSetting createApnSetting(String[] apnTypes) { static ApnSetting createApnSetting(String[] apnTypes) { return createApnSettingInternal(apnTypes, true); } private ApnSetting createDisabledApnSetting(String[] apnTypes) { private static ApnSetting createDisabledApnSetting(String[] apnTypes) { return createApnSettingInternal(apnTypes, false); } private ApnSetting createApnSettingInternal(String[] apnTypes, boolean carrierEnabled) { private static ApnSetting createApnSettingInternal(String[] apnTypes, boolean carrierEnabled) { return new ApnSetting( 2163, // id "44010", // numeric Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java +197 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony.dataconnection; import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; import static com.android.internal.telephony.dataconnection.ApnSettingTest.createApnSetting; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; Loading Loading @@ -61,6 +62,7 @@ import android.telephony.SubscriptionManager; import android.test.mock.MockContentProvider; import android.test.mock.MockContentResolver; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import android.util.LocalLog; import com.android.internal.telephony.DctConstants; Loading Loading @@ -113,6 +115,12 @@ public class DcTrackerTest extends TelephonyTest { NetworkRequest mNetworkRequest; @Mock SubscriptionInfo mSubscriptionInfo; @Mock ApnContext mApnContext; @Mock ApnSetting mApnSetting; @Mock DcAsyncChannel mDcac; private DcTracker mDct; private DcTrackerTestHandler mDcTrackerTestHandler; Loading Loading @@ -337,6 +345,8 @@ public class DcTrackerTest extends TelephonyTest { mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mBundle = mContextFixture.getCarrierConfigBundle(); mSimulatedCommands.setDataCallResponse(true, createDataCallResponse()); mDcTrackerTestHandler = new DcTrackerTestHandler(getClass().getSimpleName()); mDcTrackerTestHandler.start(); waitUntilReady(); Loading Loading @@ -670,7 +680,6 @@ public class DcTrackerTest extends TelephonyTest { waitForMs(200); } @FlakyTest @Test @MediumTest public void testDataCallOnUserDisableRoaming() throws Exception { Loading @@ -680,13 +689,16 @@ public class DcTrackerTest extends TelephonyTest { boolean roamingEnabled = mDct.getDataRoamingEnabled(); boolean dataEnabled = mDct.getDataEnabled(); doReturn(true).when(mServiceState).getDataRoaming(); //set Default and MMS to be metered in the CarrierConfigManager mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_ROAMING_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS}); mDct.setEnabled(5, true); mDct.setEnabled(0, true); doReturn(true).when(mServiceState).getDataRoaming(); logd("Sending DATA_ENABLED_CMD"); mDct.setDataEnabled(true); logd("Sending DISABLE_ROAMING_CMD"); mDct.setDataRoamingEnabled(false); Loading @@ -699,9 +711,6 @@ public class DcTrackerTest extends TelephonyTest { mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); logd("Sending DATA_ENABLED_CMD"); mDct.setDataEnabled(true); waitForMs(200); verify(mSimulatedCommandsVerifier, times(1)).setInitialAttachApn(any(DataProfile.class), eq(true), nullable(Message.class)); Loading Loading @@ -826,4 +835,187 @@ public class DcTrackerTest extends TelephonyTest { mDct.setDataEnabled(dataEnabled); waitForMs(200); } private void initApns(String targetApn, String[] canHandleTypes) { doReturn(targetApn).when(mApnContext).getApnType(); doReturn(true).when(mApnContext).isConnectable(); ApnSetting apnSetting = createApnSetting(canHandleTypes); doReturn(apnSetting).when(mApnContext).getNextApnSetting(); doReturn(apnSetting).when(mApnContext).getApnSetting(); doReturn(mDcac).when(mApnContext).getDcAc(); doReturn(true).when(mApnContext).isEnabled(); doReturn(true).when(mApnContext).getDependencyMet(); doReturn(true).when(mApnContext).isReady(); doReturn(true).when(mApnContext).hasNoRestrictedRequests(eq(true)); } // Test the emergency APN setup. @Test @SmallTest public void testTrySetupDataEmergencyApn() throws Exception { initApns(PhoneConstants.APN_TYPE_EMERGENCY, new String[]{PhoneConstants.APN_TYPE_ALL}); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(1)).setupDataCall( eq(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the unmetered APN setup when data is disabled. @Test @SmallTest public void testTrySetupDataUnmeteredDataDisabled() throws Exception { initApns(PhoneConstants.APN_TYPE_FOTA, new String[]{PhoneConstants.APN_TYPE_ALL}); mDct.setDataEnabled(false); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(1)).setupDataCall( eq(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the metered APN setup when data is disabled. @Test @SmallTest public void testTrySetupMeteredDataDisabled() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); mDct.setDataEnabled(false); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(0)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the restricted data request when data is disabled. @Test @SmallTest public void testTrySetupRestrictedDataDisabled() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); doReturn(false).when(mApnContext).hasNoRestrictedRequests(eq(true)); mDct.setDataEnabled(false); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(1)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the default data when data is not connectable. @Test @SmallTest public void testTrySetupNotConnectable() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); doReturn(false).when(mApnContext).isConnectable(); mDct.setDataEnabled(true); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(0)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the default data on IWLAN. @Test @SmallTest public void testTrySetupDefaultOnIWLAN() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN).when(mServiceState) .getRilDataRadioTechnology(); mDct.setDataEnabled(true); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(0)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } // Test the default data when the phone is in ECBM. @Test @SmallTest public void testTrySetupDefaultInECBM() throws Exception { initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL}); doReturn(true).when(mPhone).isInEcm(); mDct.setDataEnabled(true); mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[]{PhoneConstants.APN_TYPE_DEFAULT}); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); waitForMs(200); logd("Sending EVENT_DATA_CONNECTION_ATTACHED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null)); waitForMs(200); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext)); waitForMs(200); verify(mSimulatedCommandsVerifier, times(0)).setupDataCall( anyInt(), any(DataProfile.class), eq(false), eq(false), any(Message.class)); } }