use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testDataRetry.
// Test the scenario where the first data call setup is failed, and then retry the setup later.
@Test
@MediumTest
public void testDataRetry() throws Exception {
AsyncResult ar = new AsyncResult(null, new Pair<>(true, DataEnabledSettings.REASON_USER_DATA_ENABLED), null);
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_ENABLED_CHANGED, ar));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// LOST_CONNECTION(0x10004) is a non-permanent failure, so we'll retry data setup later.
SetupDataCallResult result = createSetupDataCallResult();
result.status = 0x10004;
// Simulate RIL fails the data call setup
mSimulatedCommands.setDataCallResult(true, result);
DataConnectionReasons dataConnectionReasons = new DataConnectionReasons();
boolean allowed = isDataAllowed(dataConnectionReasons);
assertFalse(dataConnectionReasons.toString(), allowed);
logd("Sending EVENT_ENABLE_APN");
// APN id 0 is APN_TYPE_DEFAULT
mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
sendInitializationEvents();
dataConnectionReasons = new DataConnectionReasons();
allowed = isDataAllowed(dataConnectionReasons);
assertTrue(dataConnectionReasons.toString(), allowed);
ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
// Verify if RIL command was sent properly.
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);
// This time we'll let RIL command succeed.
mSimulatedCommands.setDataCallResult(true, createSetupDataCallResult());
// Send event for reconnecting data
initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[] { PhoneConstants.APN_TYPE_ALL });
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_RECONNECT, mPhone.getPhoneId(), AccessNetworkConstants.TRANSPORT_TYPE_WWAN, mApnContext));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// Data connection is running on a different thread. Have to wait.
waitForMs(200);
dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
// Verify if RIL command was sent properly.
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_APN2, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
// Verify connected with APN2 setting.
verifyDataConnected(FAKE_APN2);
}
use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testRecoveryStepReRegister.
@Test
@SmallTest
public void testRecoveryStepReRegister() 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", 2);
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)).reRegisterNetwork(eq(null));
}
use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DataProfileTest method testEquals.
@SmallTest
public void testEquals() throws Exception {
DataProfile dp1 = DcTracker.createDataProfile(mApn1, mApn1.getProfileId(), false);
DataProfile dp2 = DcTracker.createDataProfile(mApn1, mApn1.getProfileId(), false);
assertEquals(dp1, dp2);
dp2 = DcTracker.createDataProfile(mApn2, mApn2.getProfileId(), false);
assertFalse(dp1.equals(dp2));
}
use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class DataProfileTest method testCreateFromApnSetting.
@SmallTest
public void testCreateFromApnSetting() throws Exception {
DataProfile dp = DcTracker.createDataProfile(mApn1, mApn1.getProfileId(), false);
assertEquals(mApn1.getProfileId(), dp.getProfileId());
assertEquals(mApn1.getApnName(), dp.getApn());
assertEquals(mApn1.getProtocol(), dp.getProtocolType());
assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType());
assertEquals(mApn1.getUser(), dp.getUserName());
assertEquals(mApn1.getPassword(), dp.getPassword());
// TYPE_COMMON
assertEquals(0, dp.getType());
assertEquals(mApn1.getWaitTime(), dp.getWaitTime());
assertEquals(mApn1.isEnabled(), dp.isEnabled());
assertFalse(dp.isPersistent());
assertFalse(dp.isPreferred());
}
use of android.telephony.data.DataProfile in project android_frameworks_opt_telephony by LineageOS.
the class RILTest method testSetupDataCall.
@Test
public void testSetupDataCall() throws Exception {
DataProfile dp = new DataProfile.Builder().setProfileId(PROFILE_ID).setApn(APN).setProtocolType(PROTOCOL).setAuthType(AUTH_TYPE).setUserName(USER_NAME).setPassword(PASSWORD).setType(TYPE).setMaxConnectionsTime(MAX_CONNS_TIME).setMaxConnections(MAX_CONNS).setWaitTime(WAIT_TIME).enable(APN_ENABLED).setSupportedApnTypesBitmask(SUPPORTED_APNT_YPES_BITMAK).setRoamingProtocolType(ROAMING_PROTOCOL).setBearerBitmask(BEARER_BITMASK).setMtu(MTU).setPersistent(PERSISTENT).setPreferred(false).build();
mRILUnderTest.setupDataCall(AccessNetworkConstants.AccessNetworkType.EUTRAN, dp, false, false, 0, null, obtainMessage());
ArgumentCaptor<DataProfileInfo> dpiCaptor = ArgumentCaptor.forClass(DataProfileInfo.class);
verify(mRadioProxy).setupDataCall(mSerialNumberCaptor.capture(), eq(AccessNetworkConstants.AccessNetworkType.EUTRAN), dpiCaptor.capture(), eq(true), eq(false), eq(false));
verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SETUP_DATA_CALL);
DataProfileInfo dpi = dpiCaptor.getValue();
assertEquals(PROFILE_ID, dpi.profileId);
assertEquals(APN, dpi.apn);
assertEquals(PROTOCOL, ApnSetting.getProtocolIntFromString(dpi.protocol));
assertEquals(AUTH_TYPE, dpi.authType);
assertEquals(USER_NAME, dpi.user);
assertEquals(PASSWORD, dpi.password);
assertEquals(TYPE, dpi.type);
assertEquals(MAX_CONNS_TIME, dpi.maxConnsTime);
assertEquals(MAX_CONNS, dpi.maxConns);
assertEquals(WAIT_TIME, dpi.waitTime);
assertEquals(APN_ENABLED, dpi.enabled);
assertEquals(SUPPORTED_APNT_YPES_BITMAK, dpi.supportedApnTypesBitmap);
assertEquals(ROAMING_PROTOCOL, ApnSetting.getProtocolIntFromString(dpi.protocol));
assertEquals(BEARER_BITMASK, ServiceState.convertBearerBitmaskToNetworkTypeBitmask(dpi.bearerBitmap >> 1));
assertEquals(MTU, dpi.mtu);
}
Aggregations