use of android.telephony.Annotation.DataFailureCause 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;
}
Aggregations