Platform: Rockchip

OS: Android 6.0

Kernel: 3.10.92

,这里看一下它的移除过程是怎样的,当选择界面的FORGET时,会触发以下流程调用。

0818b9ca8b590ca3270a3433284dd417.png

onForget ->

forget ->     mWifiManager.forget ->  WiFiSettings.java //参数为当前选择forget的config的netid       sAsyncChannel.sendMessage -> 异步通道发送给WifiStateMachine,cmd是FORGET_NETWORK         processMessage -> WifiStateMachine.java  //当前处于ConnectedState,调用父类的父类ConnectModeState           mWifiConfigStore.getWifiConfiguration //根据netid得到对应的config           mWifiConfigStore.canModifyNetwork //检查调用者是否有权限remove network           mWifiConfigStore.forgetNetwork ->             removeConfigAndSendBroadcastIfNeeded ->     //执行清理操作               mConfiguredNetworks.remove  //从ConfiguredNetworks中移除               mScanDetailCaches.remove               sendConfiguredNetworksChangedBroadcast //发广播wifi状态变化: WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION             mWifiNative.removeNetwork ->               doBooleanCommand //通知WPAS移除network,命令是"REMOVE_NETWORK " + netId,这和用wpa_cli客户端的方法是一样的             mWifiNative.saveConfig ->               doBooleanCommand     //通知WPAS更新配置文件wpa_supplicant.conf           handleEvent WifiMonitor.java -> WPAS移除完毕之后会发DISCONNECTED事件过来,由WifiMonitor负责接收             handleNetworkStateChange ->               notifyNetworkStateChange ->                 mStateMachine.sendMessage ->  //NETWORK_DISCONNECTION_EVENT, 发给WifiStateMachine                   processMessage -> //ConnectedState                     dispatchEvent ->  接着WifiMonitor又收到WPAS发来的STATE_CHANGE事件                       handleSupplicantStateChange ->                         notifySupplicantStateChange -> //                           mStateMachine.sendMessage -> //SUPPLICANT_STATE_CHANGE_EVENT                             processMessage -> //当前处于ConnectedState,调用父类的父类ConnectModeState                               handleNetworkDisconnect ->                                 stopRssiMonitoringOffload -> //通知HAL stop rssi                                   mWifiNative.stopRssiMonitoring ->                                     stopRssiMonitoringNative ->                                       android_net_wifi_stop_rssi_monitoring_native ->                                         hal_fn.wifi_stop_rssi_monitoring                                  clearCurrentConfigBSSID -> //清理bssid                                    clearConfigBSSID                                  stopDhcp -> //关dchp,之前有分析过startdhcp的                                    handlePostDhcpSetup                                    mDhcpStateMachine.sendMessage  //DhcpStateMachine.CMD_STOP_DHCP                                      processMessage ->  //DhcpBoundState                                        processMessage -> //DhcpHaveAddressState的父类DhcpState                                          transitionTo(mStoppedState) ->                                            exit -> //DhcpHaveAddressState                                              setIpAddress ->                                                mNMService.setInterfaceConfig //通知netd设置ip                                  mNwService.clearInterfaceAddresses                                  mNwService.disableIpv6                                  setNetworkDetailedState    //这部分和ConnectionService有关,打算后面再细讲                                  mNetworkAgent.sendNetworkInfo                                  sendNetworkStateChangeBroadcast //广播WifiManager.NETWORK_STATE_CHANGED_ACTION                               transitionTo(mDisconnectedState) ->                                 exit -> //ConnectedState                                   setScanAlarm //关闭周期性scan                                 enter -> //DisconnectedState                                   startScan //断开连接后进入定期扫描

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐