use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testNetworkStatusChangedRecoveryON.
@FlakyTest
@Test
@SmallTest
public void testNetworkStatusChangedRecoveryON() throws Exception {
ContentResolver resolver = mContext.getContentResolver();
Settings.Global.putInt(resolver, Settings.Global.DATA_STALL_RECOVERY_ON_BAD_NETWORK, 1);
Settings.System.putInt(resolver, "radio.data.stall.recovery.action", 0);
doReturn(new SignalStrength()).when(mPhone).getSignalStrength();
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
sendInitializationEvents();
ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
verify(mSimulatedCommandsVerifier, timeout(TEST_TIMEOUT).times(2)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
logd("Sending EVENT_NETWORK_STATUS_CHANGED");
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.VALID_NETWORK, 1, null));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
logd("Sending EVENT_NETWORK_STATUS_CHANGED");
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.INVALID_NETWORK, 1, null));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// Data connection is running on a different thread. Have to wait.
waitForMs(200);
verify(mSimulatedCommandsVerifier, times(1)).getDataCallList(any(Message.class));
}
use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testRecoveryStepPDPReset.
@FlakyTest
@Test
@SmallTest
public void testRecoveryStepPDPReset() throws Exception {
ContentResolver resolver = mContext.getContentResolver();
Settings.Global.putInt(resolver, Settings.Global.DATA_STALL_RECOVERY_ON_BAD_NETWORK, 1);
Settings.Global.putLong(resolver, Settings.Global.MIN_DURATION_BETWEEN_RECOVERY_STEPS_IN_MS, 100);
Settings.System.putInt(resolver, "radio.data.stall.recovery.action", 1);
doReturn(new SignalStrength()).when(mPhone).getSignalStrength();
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
sendInitializationEvents();
ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
verify(mSimulatedCommandsVerifier, timeout(TEST_TIMEOUT).times(2)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
logd("Sending EVENT_NETWORK_STATUS_CHANGED false");
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.INVALID_NETWORK, 1, null));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
waitForMs(200);
// expected tear down all DataConnections
verify(mSimulatedCommandsVerifier, times(1)).deactivateDataCall(eq(DataService.REQUEST_REASON_NORMAL), anyInt(), any(Message.class));
}
use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testRecoveryStepRestartRadio.
@Test
@SmallTest
public void testRecoveryStepRestartRadio() throws Exception {
ContentResolver resolver = mContext.getContentResolver();
Settings.Global.putInt(resolver, Settings.Global.DATA_STALL_RECOVERY_ON_BAD_NETWORK, 1);
Settings.Global.putLong(resolver, Settings.Global.MIN_DURATION_BETWEEN_RECOVERY_STEPS_IN_MS, 100);
Settings.System.putInt(resolver, "radio.data.stall.recovery.action", 3);
doReturn(new SignalStrength()).when(mPhone).getSignalStrength();
doReturn(PhoneConstants.State.IDLE).when(mPhone).getState();
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
sendInitializationEvents();
ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
verify(mSimulatedCommandsVerifier, times(1)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
logd("Sending EVENT_NETWORK_STATUS_CHANGED false");
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.INVALID_NETWORK, 1, null));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// expected to get preferred network type
verify(mSST, times(1)).powerOffRadioSafely();
}
use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testCarrierActionSetMeteredApnsEnabled.
// Test for API carrierActionSetMeteredApnsEnabled.
@FlakyTest
@Ignore
@Test
@MediumTest
public void testCarrierActionSetMeteredApnsEnabled() throws Exception {
// step 1: setup two DataCalls one for Internet and IMS
// step 2: set data is enabled
// step 3: cold sim is detected
// step 4: all data connection is torn down
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
sendInitializationEvents();
ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
verify(mSimulatedCommandsVerifier, times(2)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 5, 1, NETWORK_TYPE_LTE_BITMASK);
assertTrue(mDct.isAnyDataConnected());
AsyncResult ar = new AsyncResult(null, new Pair<>(false, DataEnabledSettings.REASON_DATA_ENABLED_BY_CARRIER), null);
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_ENABLED_CHANGED, ar));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// Data connection is running on a different thread. Have to wait.
waitForMs(200);
// Validate all metered data connections have been torn down
verify(mSimulatedCommandsVerifier, times(1)).deactivateDataCall(eq(DataService.REQUEST_REASON_NORMAL), anyInt(), any(Message.class));
assertTrue(mDct.isAnyDataConnected());
assertEquals(DctConstants.State.IDLE, mDct.getState(PhoneConstants.APN_TYPE_DEFAULT));
}
use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DataProfileTest method testCreateFromApnSettingWithNetworkTypeBitmask.
@SmallTest
public void testCreateFromApnSettingWithNetworkTypeBitmask() throws Exception {
DataProfile dp = DcTracker.createDataProfile(mApn3, mApn3.getProfileId(), false);
assertEquals(mApn3.getProfileId(), dp.getProfileId());
assertEquals(mApn3.getApnName(), dp.getApn());
assertEquals(mApn3.getProtocol(), dp.getProtocolType());
assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType());
assertEquals(mApn3.getUser(), dp.getUserName());
assertEquals(mApn3.getPassword(), dp.getPassword());
// TYPE_3GPP2
assertEquals(2, dp.getType());
assertEquals(mApn3.getWaitTime(), dp.getWaitTime());
assertEquals(mApn3.isEnabled(), dp.isEnabled());
int expectedBearerBitmap = mApn3.getNetworkTypeBitmask();
assertEquals(expectedBearerBitmap, dp.getBearerBitmask());
}
Aggregations