use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class DcTracker method getPreciseDataConnectionState.
/**
* Return the Precise Data Connection State information
*/
@NonNull
public PreciseDataConnectionState getPreciseDataConnectionState(String apnType, boolean isSuspended, int networkType) {
int telState = convertDctStateToTelephonyDataState(getState(apnType));
// voice call state and device + rat capability
if ((telState == TelephonyManager.DATA_CONNECTED || telState == TelephonyManager.DATA_DISCONNECTING) && isSuspended) {
telState = TelephonyManager.DATA_SUSPENDED;
}
ApnSetting apnSetting = getActiveApnSetting(apnType);
int apnTypesBitmask = ApnSetting.getApnTypesBitmaskFromString(apnType);
// TODO: should the data fail cause be populated?
return new PreciseDataConnectionState(telState, networkType, apnTypesBitmask, apnType, getLinkProperties(apnType), DataFailCause.NONE, apnSetting);
}
use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class ApnContextTest method testProvisionApn.
@Test
@SmallTest
public void testProvisionApn() throws Exception {
mContextFixture.putResource(R.string.mobile_provisioning_apn, "fake_apn");
ApnSetting myApn = ApnSetting.makeApnSetting(// id
2163, // numeric
"44010", // name
"sp-mode", // apn
"fake_apn", // proxy
null, // port
-1, // mmsc
null, // mmsproxy
null, // mmsport
-1, // user
"", // password
"", // authtype
-1, // types
ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_SUPL, // protocol
ApnSetting.PROTOCOL_IP, // roaming_protocol
ApnSetting.PROTOCOL_IP, // carrier_enabled
true, // networktype_bismask
0, // profile_id
0, // modem_cognitive
false, // max_conns
0, // wait_time
0, // max_conns_time
0, // mtu
0, // mvno_type
-1, // mnvo_match_data
"");
mApnContext.setApnSetting(myApn);
assertTrue(mApnContext.isProvisioningApn());
mApnContext.setApnSetting(mApnSetting);
assertFalse(mApnContext.isProvisioningApn());
}
use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class RILTest method testSetInitialAttachApn.
@FlakyTest
@Test
public void testSetInitialAttachApn() throws Exception {
ApnSetting apnSetting = ApnSetting.makeApnSetting(-1, "22210", "Vodafone IT", "web.omnitel.it", null, -1, null, null, -1, "", "", 0, ApnSetting.TYPE_DUN, ApnSetting.PROTOCOL_IP, ApnSetting.PROTOCOL_IP, true, 0, 0, false, 0, 0, 0, 0, -1, "");
DataProfile dataProfile = DcTracker.createDataProfile(apnSetting, apnSetting.getProfileId(), false);
boolean isRoaming = false;
mRILUnderTest.setInitialAttachApn(dataProfile, isRoaming, obtainMessage());
verify(mRadioProxy).setInitialAttachApn(mSerialNumberCaptor.capture(), eq((DataProfileInfo) invokeMethod(mRILInstance, "convertToHalDataProfile10", new Class<?>[] { DataProfile.class }, new Object[] { dataProfile })), eq(dataProfile.isPersistent()), eq(isRoaming));
verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SET_INITIAL_ATTACH_APN);
}
use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testFetchDunApn.
// Test for fetchDunApns()
@Test
@SmallTest
public void testFetchDunApn() {
sendInitializationEvents();
String dunApnString = "[ApnSettingV3]HOT mobile PC,pc.hotm,,,,,,,,,440,10,,DUN,,,true," + "0,,,,,,,,";
ApnSetting dunApnExpected = ApnSetting.fromString(dunApnString);
Settings.Global.putString(mContext.getContentResolver(), Settings.Global.TETHER_DUN_APN, dunApnString);
// should return APN from Setting
ApnSetting dunApn = mDct.fetchDunApns().get(0);
assertTrue(dunApnExpected.equals(dunApn));
Settings.Global.putString(mContext.getContentResolver(), Settings.Global.TETHER_DUN_APN, null);
// should return APN from db
dunApn = mDct.fetchDunApns().get(0);
assertEquals(FAKE_APN5, dunApn.getApnName());
}
use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testCheckForCompatibleDataConnectionWithDunWhenIdsChange.
// This tests simulates the race case where the sim status change event is triggered, the
// default data connection is attached, and then the carrier config gets changed which bumps
// the database id which we want to ignore when cleaning up connections and matching against
// the dun APN. Tests b/158908392.
@Test
@SmallTest
public void testCheckForCompatibleDataConnectionWithDunWhenIdsChange() throws Exception {
// Set dun as a support apn type of FAKE_APN1
mApnSettingContentProvider.setFakeApn1Types("default,supl,dun");
// Enable the default apn
mSimulatedCommands.setDataCallResult(true, createSetupDataCallResult());
mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// Load the sim and attach the data connection without firing the carrier changed event
final String logMsgPrefix = "testCheckForCompatibleDataConnectionWithDunWhenIdsChange: ";
sendSimStateUpdated(logMsgPrefix);
sendEventDataConnectionAttached(logMsgPrefix);
waitForMs(200);
// Confirm that FAKE_APN1 comes up as a dun candidate
ApnSetting dunApn = mDct.fetchDunApns().get(0);
assertEquals(dunApn.getApnName(), FAKE_APN1);
Map<Integer, ApnContext> apnContexts = mDct.getApnContexts().stream().collect(Collectors.toMap(ApnContext::getApnTypeBitmask, x -> x));
// Double check that the default apn content is connected while the dun apn context is not
assertEquals(apnContexts.get(ApnSetting.TYPE_DEFAULT).getState(), DctConstants.State.CONNECTED);
assertNotEquals(apnContexts.get(ApnSetting.TYPE_DUN).getState(), DctConstants.State.CONNECTED);
// Change the row ids the same way as what happens when we have old apn values in the
// carrier table
mApnSettingContentProvider.setRowIdOffset(100);
sendCarrierConfigChanged(logMsgPrefix);
waitForMs(200);
mDct.enableApn(ApnSetting.TYPE_DUN, DcTracker.REQUEST_TYPE_NORMAL, null);
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
Map<Integer, ApnContext> apnContextsAfterRowIdsChanged = mDct.getApnContexts().stream().collect(Collectors.toMap(ApnContext::getApnTypeBitmask, x -> x));
// Make sure that the data connection used earlier wasn't cleaned up and still in use.
assertEquals(apnContexts.get(ApnSetting.TYPE_DEFAULT).getDataConnection(), apnContextsAfterRowIdsChanged.get(ApnSetting.TYPE_DEFAULT).getDataConnection());
// Check that the DUN is using the same active data connection
assertEquals(apnContexts.get(ApnSetting.TYPE_DEFAULT).getDataConnection(), apnContextsAfterRowIdsChanged.get(ApnSetting.TYPE_DUN).getDataConnection());
}
Aggregations