1、注册观察者
--> PhoneFactory.makeDefaultPhones()
--> TelephonyComponentFactory.makeSubscriptionInfoUpdater()
--> new SubscriptionInfoUpdater()
--> PhoneConfigurationManager.registerForMultiSimConfigChange(this, EVENT_MULTI_SIM_CONFIG_CHANGED, null)
--> sMultiSimConfigChangeRegistrants.addUnique(h, what, obj) 观察者注册到通知者中
到这步,注册了对 EVENT_MULTI_SIM_CONFIG_CHANGED 事件的观察,当收到通知者notify时,就由SubscriptionInfoUpdater这个Handler对象来处理事件。
其实只要某个类中调用了PhoneConfigurationManager.registerForMultiSimConfigChange(),就会产生一个观察者并注册到通知者中
比如下面这些类的方法中都有注册观察者
2、触发事件
--> PhoneInterfaceManager.switchMultiSimConfig()
--> RadioConfig.setNumOfLiveModems()
--> RadioConfigProxy.setNumOfLiveModems()
--> 下发modem请求
--> modem返回响应,回调处理事件 EVENT_SWITCH_DSDS_CONFIG_DONE
--> ConfigurationManagerHandler.handleMessage()--> PhoneConfigurationManager.onMultiSimConfigChanged()
--> broadcastMultiSimConfigChange()
--> notifyMultiSimConfigChange()
--> sMultiSimConfigChangeRegistrants.notifyResult() 1.通知者通知观察者
--> SubscriptionInfoUpdater.handleMessage()
--> onMultiSimConfigChanged()private void onMultiSimConfigChanged() {int activeModemCount = ((TelephonyManager) sContext.getSystemService(Context.TELEPHONY_SERVICE)).getActiveModemCount();// For inactive modems, reset its states.for (int phoneId = activeModemCount; phoneId < SUPPORTED_MODEM_COUNT; phoneId++) {sIccId[phoneId] = null;sSimCardState[phoneId] = TelephonyManager.SIM_STATE_UNKNOWN;sSimApplicationState[phoneId] = TelephonyManager.SIM_STATE_UNKNOWN;}}--> Intent intent = new Intent(ACTION_MULTI_SIM_CONFIG_CHANGED); sendBroadcast(intent) 2.发送广播
--> ConfigLoaderBroadcastReceiver.onReceive()
--> sendMessge(EVENT_MULTI_SIM_CONFIG_CHANGED)
--> ConfigHandler.handleMessage()
--> CarrierConfigLoader.onMultiSimConfigChanged()
--> updateConfigForPhoneId()
--> sendMessage(mHandler.obtainMessage(EVENT_DO_FETCH_DEFAULT, phoneId, -1));
待续。。。