onDataSetupComplete()是在建立数据业务后,在DataConnection中的DcActiveState状态中enter()方法里面通过notifyAllOfConnected(Phone.REASON_CONNECTED);调用的.

1.onDataSetupComplete() 方法对应的事件消息是DctConstants.EVENT_DATA_SETUP_COMPLETE:

2.在该方法中将区分ar.exception == null 为true表示建立成功,或者 ar.exception != null表示建立失败进行处理.

if(ar.exception == null)对应处理如下:

ApnSetting apn = apnContext.getApnSetting();//如果apn的proxy不为空表示是彩信的apn,如果prot为空就设置为8080

if (apn != null && apn.proxy != null && apn.proxy.length() != 0) {

try {

    String port = apn.port;

    if (TextUtils.isEmpty(port)) port = "8080";

    ProxyInfo proxy = new ProxyInfo(apn.proxy,Integer.parseInt(port), null);

    dcac.setLinkPropertiesHttpProxySync(proxy);

} catch (NumberFormatException e) {

    loge("onDataSetupComplete: NumberFormatException making ProxyProperties (" +apn.port + "): " + e);

}

}

如果当前是default apn且当前无preferred apn那么就要设置preferred apn:

if (mCanSetPreferApn && mPreferredApn == null) {

if (DBG) log("onDataSetupComplete: PREFERRED APN is null");

mPreferredApn = apn;

if (mPreferredApn != null) {

    setPreferredApn(mPreferredApn.id);

}

}

completeConnection(apnContext);方法里面通过mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());通知status bar更新数据网络图标或者systemui通过注册PhoneStateListener方法来监听事件得到改变..通过 startNetStatPoll();方法周期性读取底层接口文件,判断终端是否发送和接受数据,从而更新UI界面的上下行图标。startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);方法周期性地检测终端是否出现问题:同样是读取底层文件,当连续发送10个包,但没有收到回复时,认为终端出现问题,需要进行恢复.

......

if(ar.exception != null)对应处理如下:

如果是永久性的失败,那么就更新apn为永久性失败.

// If the data call failure cause is a permanent failure, we mark the APN as permanent failed.

if (isPermanentFail(cause)) {

 log("cause = " + cause + ", mark apn as permanent failed. apn = " + apn);

 apnContext.markApnPermanentFailed(apn);

}

通过下面的方法onDataSetupCompleteError(ar);进行建立数据业务重试机制,获得modem层返回的重试时间,再调用AlarmManager设置定时重试.

long delay = apnContext.getDelayForNextApn(mFailFast);

// Check if we need to retry or not.

if (delay >= 0) {

if (DBG) log("onDataSetupCompleteError: Try next APN. delay = " + delay);

apnContext.setState(DctConstants.State.SCANNING);

// Wait a bit before trying the next APN, so that

// we're not tying up the RIL command channel

startAlarmForReconnect(delay, apnContext);

} else {

// If we are not going to retry any APN, set this APN context to failed state.

// This would be the final state of a data connection.

apnContext.setState(DctConstants.State.FAILED);

mPhone.notifyDataConnection(Phone.REASON_APN_FAILED, apnContext.getApnType());

apnContext.setDataConnectionAc(null);

log("onDataSetupCompleteError: Stop retrying APNs.");

}

results matching ""

    No results matching ""