文章目录
Android P WiFi 框架
Android P相比于Android O的变化
- 多了WifiStateMachinePrime(状态机的前处理机制),wifiService的相关cmd 不再是直接send 给WifiStateMachine,而是被送到WifiStateMachinePrime先进行处理后,再送往WifiStateMachine
- 也多了一层ClientModeManager处理(将之前初始化wpa_supplicant专门抽出一层类在这里面来做),详细看后面的代码
Wifi 整体流程框架图
- 基本与Android O Wifi 主体框架一致
- 三板斧的套路还是被传承下来(1. Application <–> 2. WiFiService(WifiStateMachine) <–> 3. WifiNative(wpa_supplicant – wlan drv))
代码流程
1. WifiSettings --> WifiManager
点击 wifi button 开启wifi 触发的代码流程如下,
- wifiSettings 响应onPreferenceTreeClick 送往WifiEnable
- WifiEnabler 根据传入的状态,call WifiManager 设置wifi状态 (开启跳转到WifiServiceImpl)
packages/apps/Settings/src/com/android/settings/wifi/WifiSettings.java
public boolean onPreferenceTreeClick(Preference preference){
.....
return super.onPreferenceTreeClick(preference);
}
packages/apps/Settings/src/com/android/settings/wifi/WifiEnabler.java
public boolean onSwitchToggled(boolean isChecked){
....
mWifiManager.setWifiEnabled(isChecked); // wifiManager 设置wifi 状态
}
2. WifiManager --> WifiService --> WifiServiceImpl -->WifiController
- 还是老套路,逐级进入WifiService,WifiSe