一、主要联系
当数据连接变化时数据图标的刷新过程,主要有这几步:
Step 1:DcTracker::notifyDataConnection 遍历各个apn类型,分别发送通知到phone;
Step 2:Phonebase::notifyDataConnection 通知到notifier;
Step 3:DefaultPhoneNotifier::notifyDataConnection 调用doNotifyDataConnection;
Setp 4:DefaultPhoneNotifier::doNotifyDataConnection 调用notifyDataConnectionForSubscriber;
Step 5:TelephonyRegistry::notifyDataConnectionForSubscriber 调用onDataConnectionStateChanged。
二、具体代码调用
2.1 DcTracker:
public class DcTracker extends DcTrackerBase;
protected void notifyDataConnection(String reason) {
if (DBG) log("notifyDataConnection: reason=" + reason);
for (ApnContext apnContext : mApnContexts.values()) {
if ((mAttached.get() || !mOosIsDisconnect) && apnContext.isReady()) {
if (DBG) log("notifyDataConnection: type:" + apnContext.getApnType());
mPhone.notifyDataConnection(reason != null ? reason : apnContext.getReason(),
apnContext.getApnType());
}
}
notifyOffApnsOfAvailability(reason);
}
protected final Phone mPhone;
2.2 DcTrackerBase:
protected void notifyDataConnection(String reason) {
for (int id = 0; id < DctConstants.APN_NUM_TYPES; id++) {
if (mDataEnabled[id]) {
mPhone.notifyDataConnection(reason, apnIdToType(id));
}
}
notifyOffApnsOfAvailability(reason);
}
protected PhoneBase mPhone;
2.3 PhoneBase:
public abstract class PhoneBase extends Handler implements Phone
public void notifyDataConnection(String reason, String apnType,
PhoneConstants.DataState state) {
mNotifier.notifyDataConnection(this, reason, apnType, state);
}
protected PhoneNotifier mNotifier;
2.4 DefaultPhoneNotifier:
public class DefaultPhoneNotifier implements PhoneNotifier
public void notifyDataConnection(Phone sender, String reason, String apnType,
PhoneConstants.DataState state) {
doNotifyDataConnection(sender, reason, apnType, state);
}
2.4.1 doNotifyDataConnection:
protected ITelephonyRegistry mRegistry;
mRegistry.notifyDataConnectionForSubscriber();
2.5 TelephonyRegistry:
class TelephonyRegistry extends ITelephonyRegistry.Stub
notifyDataConnectionForSubscriber:
r.callback.onDataConnectionStateChanged()
至此,不往下分析了.