use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class DataConnectionTest method testModemSuggestRetry.
@Test
@SmallTest
public void testModemSuggestRetry() throws Exception {
DataCallResponse response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(0).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
assertEquals(response.getSuggestedRetryTime(), getSuggestedRetryDelay(response));
response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(1000).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
assertEquals(response.getSuggestedRetryTime(), getSuggestedRetryDelay(response));
response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(9999).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
assertEquals(response.getSuggestedRetryTime(), getSuggestedRetryDelay(response));
}
use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class RadioIndication method responseDataCallListChanged.
private void responseDataCallListChanged(int indicationType, List<?> dcList) {
mRil.processIndication(indicationType);
if (RIL.RILJ_LOGD)
mRil.unsljLogRet(RIL_UNSOL_DATA_CALL_LIST_CHANGED, dcList);
ArrayList<DataCallResponse> response = RIL.convertDataCallResultList(dcList);
mRil.mDataCallListChangedRegistrants.notifyRegistrants(new AsyncResult(null, response, null));
}
use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class DataConnection method connect.
/**
* Begin setting up a data connection, calls setupDataCall
* and the ConnectionParams will be returned with the
* EVENT_SETUP_DATA_CONNECTION_DONE
*
* @param cp is the connection parameters
*
* @return Fail cause if failed to setup data connection. {@link DataFailCause#NONE} if success.
*/
@DataFailureCause
private int connect(ConnectionParams cp) {
log("connect: carrier='" + mApnSetting.getEntryName() + "' APN='" + mApnSetting.getApnName() + "' proxy='" + mApnSetting.getProxyAddressAsString() + "' port='" + mApnSetting.getProxyPort() + "'");
if (cp.mApnContext != null)
cp.mApnContext.requestLog("DataConnection.connect");
// Check if we should fake an error.
if (mDcTesterFailBringUpAll.getDcFailBringUp().mCounter > 0) {
DataCallResponse response = new DataCallResponse.Builder().setCause(mDcTesterFailBringUpAll.getDcFailBringUp().mFailCause).setSuggestedRetryTime(mDcTesterFailBringUpAll.getDcFailBringUp().mSuggestedRetryTime).setMtuV4(PhoneConstants.UNSET_MTU).setMtuV6(PhoneConstants.UNSET_MTU).build();
Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
AsyncResult.forMessage(msg, response, null);
sendMessage(msg);
if (DBG) {
log("connect: FailBringUpAll=" + mDcTesterFailBringUpAll.getDcFailBringUp() + " send error response=" + response);
}
mDcTesterFailBringUpAll.getDcFailBringUp().mCounter -= 1;
return DataFailCause.NONE;
}
mCreateTime = -1;
mLastFailTime = -1;
mLastFailCause = DataFailCause.NONE;
Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
msg.obj = cp;
DataProfile dp = DcTracker.createDataProfile(mApnSetting, cp.mProfileId, cp.mIsPreferredApn);
// We need to use the actual modem roaming state instead of the framework roaming state
// here. This flag is only passed down to ril_service for picking the correct protocol (for
// old modem backward compatibility).
boolean isModemRoaming = mPhone.getServiceState().getDataRoamingFromRegistration();
// If the apn is NOT metered, we will allow data roaming regardless of the setting.
boolean isUnmeteredApnType = !ApnSettingUtils.isMeteredApnType(cp.mApnContext.getApnTypeBitmask(), mPhone);
// Set this flag to true if the user turns on data roaming. Or if we override the roaming
// state in framework, we should set this flag to true as well so the modem will not reject
// the data call setup (because the modem actually thinks the device is roaming).
boolean allowRoaming = mPhone.getDataRoamingEnabled() || (isModemRoaming && (!mPhone.getServiceState().getDataRoaming() || isUnmeteredApnType));
if (DBG) {
log("allowRoaming=" + allowRoaming + ", mPhone.getDataRoamingEnabled()=" + mPhone.getDataRoamingEnabled() + ", isModemRoaming=" + isModemRoaming + ", mPhone.getServiceState().getDataRoaming()=" + mPhone.getServiceState().getDataRoaming() + ", isUnmeteredApnType=" + isUnmeteredApnType);
}
// Check if this data setup is a handover.
LinkProperties linkProperties = null;
int reason = DataService.REQUEST_REASON_NORMAL;
if (cp.mRequestType == DcTracker.REQUEST_TYPE_HANDOVER) {
// If this is a data setup for handover, we need to pass the link properties
// of the existing data connection to the modem.
DcTracker dcTracker = mPhone.getDcTracker(getHandoverSourceTransport());
if (dcTracker == null || cp.mApnContext == null) {
loge("connect: Handover failed. dcTracker=" + dcTracker + ", apnContext=" + cp.mApnContext);
return DataFailCause.HANDOVER_FAILED;
}
DataConnection dc = dcTracker.getDataConnectionByApnType(cp.mApnContext.getApnType());
if (dc == null) {
loge("connect: Can't find data connection for handover.");
return DataFailCause.HANDOVER_FAILED;
}
// Preserve the potential network agent from the source data connection. The ownership
// is not transferred at this moment.
mHandoverSourceNetworkAgent = dc.getNetworkAgent();
if (mHandoverSourceNetworkAgent == null) {
loge("Cannot get network agent from the source dc " + dc.getName());
return DataFailCause.HANDOVER_FAILED;
}
linkProperties = dc.getLinkProperties();
if (linkProperties == null || linkProperties.getLinkAddresses().isEmpty()) {
loge("connect: Can't find link properties of handover data connection. dc=" + dc);
return DataFailCause.HANDOVER_FAILED;
}
mHandoverLocalLog.log("Handover started. Preserved the agent.");
log("Get the handover source network agent: " + mHandoverSourceNetworkAgent);
dc.setHandoverState(HANDOVER_STATE_BEING_TRANSFERRED);
reason = DataService.REQUEST_REASON_HANDOVER;
}
mDataServiceManager.setupDataCall(ServiceState.rilRadioTechnologyToAccessNetworkType(cp.mRilRat), dp, isModemRoaming, allowRoaming, reason, linkProperties, msg);
TelephonyMetrics.getInstance().writeSetupDataCall(mPhone.getPhoneId(), cp.mRilRat, dp.getProfileId(), dp.getApn(), dp.getProtocolType());
return DataFailCause.NONE;
}
use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class SimulatedCommands method setupDataCall.
@Override
public void setupDataCall(int accessNetworkType, DataProfile dataProfile, boolean isRoaming, boolean allowRoaming, int reason, LinkProperties linkProperties, Message result) {
SimulatedCommandsVerifier.getInstance().setupDataCall(accessNetworkType, dataProfile, isRoaming, allowRoaming, reason, linkProperties, result);
if (mSetupDataCallResult == null) {
try {
mSetupDataCallResult = new SetupDataCallResult();
mSetupDataCallResult.status = 0;
mSetupDataCallResult.suggestedRetryTime = -1;
mSetupDataCallResult.cid = 1;
mSetupDataCallResult.active = 2;
mSetupDataCallResult.type = "IP";
mSetupDataCallResult.ifname = "rmnet_data7";
mSetupDataCallResult.addresses = "12.34.56.78";
mSetupDataCallResult.dnses = "98.76.54.32";
mSetupDataCallResult.gateways = "11.22.33.44";
mSetupDataCallResult.pcscf = "fd00:976a:c305:1d::8 fd00:976a:c202:1d::7 fd00:976a:c305:1d::5";
mSetupDataCallResult.mtu = 1440;
} catch (Exception e) {
}
}
// Store different cids to simulate concurrent IMS and default data calls
if ((dataProfile.getSupportedApnTypesBitmask() & ApnSetting.TYPE_IMS) == ApnSetting.TYPE_IMS) {
mSetupDataCallResult.cid = 0;
} else {
mSetupDataCallResult.cid = 1;
}
DataCallResponse response = RIL.convertDataCallResult(mSetupDataCallResult);
if (mDcSuccess) {
resultSuccess(result, response);
} else {
resultFail(result, response, new RuntimeException("Setup data call failed!"));
}
}
use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class TelephonyMetricsTest method testWriteOnSetupDataCallResponse.
// Test write on setup data call response
@Test
@SmallTest
public void testWriteOnSetupDataCallResponse() throws Exception {
DataCallResponse response = new DataCallResponse.Builder().setCause(5).setSuggestedRetryTime(6).setId(7).setLinkStatus(8).setProtocolType(ApnSetting.PROTOCOL_IPV4V6).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
mMetrics.writeOnRilSolicitedResponse(mPhone.getPhoneId(), 1, 2, RIL_REQUEST_SETUP_DATA_CALL, response);
TelephonyLog log = buildProto();
assertEquals(1, log.events.length);
assertEquals(0, log.callSessions.length);
assertEquals(0, log.smsSessions.length);
assertFalse(log.eventsDropped);
TelephonyEvent.RilSetupDataCallResponse respProto = log.events[0].setupDataCallResponse;
assertEquals(5, respProto.status);
assertEquals(6, respProto.suggestedRetryTimeMillis);
assertEquals(7, respProto.call.cid);
assertEquals(PDP_TYPE_IPV4V6, respProto.call.type);
assertEquals(FAKE_IFNAME, respProto.call.iframe);
}
Aggregations