SIM卡开机流程,之前我们已经了解由PhoneFactory类的makeDefaultPhone方法中开始,在这个方法中,新建了一个DefaultPhoneNotifier对象
sPhoneNotifier = new DefaultPhoneNotifier();那么,先看看google对DefaultPhoneNotifier类的介绍
/**
* broadcast intents
*/
public class DefaultPhoneNotifier implements PhoneNotifier {
......
}从这个介绍中可以看到这个类的主要工作就是向外发送广播消息,那么,就来看看它是如何来完成其工作的
/*package*/
protected DefaultPhoneNotifier() {
mRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
"telephony.registry"));
}构造方法中,仅仅创建了一个对象,这个对象是什么?ITelephonyRegistry,我们可知,实现ITelephonyRegistry的是TelephonyRegistry类,也就是说,其实是新建了一个TelephonyRegister对象
遍观DefaultPhoneNotifier类,发现其都是notify一族的方法,那么我们就直接选取一个方法来看看,其究竟是如何来实现发送广播消息的
@Override
public void notifyDataConnection(Phone sender, String reason, String apnType,
PhoneConstants.DataState state) {
doNotifyDataConnection(sender, reason, apnType, state);
}
private void doNotifyDataConnection(Phone sender, String reason, String apnType,
PhoneConstants.DataState state) {
int subId = sender.getSubId();
long dds = SubscriptionManager.getDefaultDataSubId();
if (DBG) log("subId = " + subId + ", DDS = " + dds);
// TODO
// use apnType as the key to which connec

本文深入探讨了M平台SIM卡开机流程,重点关注DefaultPhoneNotifier类及其广播消息发送机制。从makeDefaultPhone方法开始,分析了DefaultPhoneNotifier的notify方法,特别是GSMPhone在数据状态变化时的角色。接着,详细阐述了doNotifyDataConnection方法的步骤,包括获取subId、Phone对象的数据以及调用TelephonyRegistry的notifyDataConnectionForSubscriber方法。在TelephonyRegistry内部,检查权限、更新卡槽信息并触发回调及广播更新。最后,预告了对Record类和listen方法的后续分析。
最低0.47元/天 解锁文章
2451

被折叠的 条评论
为什么被折叠?



