[RK3288][Android6.0] WiFi之无线网络配置的忘记(移除)过程

Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92


之前有分析过 无线网络配置的保存过程 ,这里看一下它的移除过程是怎样的,当选择界面的FORGET时,会触发以下流程调用。


[RK3288][Android6.0] WiFi之无线网络配置的忘记(移除)过程_第1张图片


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 //断开连接后进入定期扫描

你可能感兴趣的:(子类__WiFi)