Enable WIFI时frameworks 在哪启动wpa_supplicant?
Android Frameworks中的代码流程大致如下:
private boolean startSupplicant() {
synchronized (mLock) {
if (!mIfaceMgr.hasAnyStaIfaceForConnectivity()) {
if (!startAndWaitForSupplicantConnection()) {
Log.e(TAG, "Failed to connect to supplicant");
return false;
}
if (!mSupplicantStaIfaceHal.registerDeathHandler(
new SupplicantDeathHandlerInternal())) {
Log.e(TAG, "Failed to register supplicant death handler");
return false;
}
}
return true;
}
}
service wpa_supplicant /vendor/bin/hw/wpa_supplicant -g@android:wpa_wlan0 -G1010 -O/data/vendor/wifi/wpa/sockets -Dnl80211 -iwlan0 -c /vendor/etc/wifi/wpa_supplicant.conf -N -Dnl80211 -ip2p0 -c /data/vendor/wifi/wpa/p2p_supplicant.conf -puse_p2p_group_interface=1 -d
interface android.hardware.wifi.supplicant@1.0::ISupplicant default
interface android.hardware.wifi.supplicant@1.1::ISupplicant default
interface android.hardware.wifi.supplicant@1.2::ISupplicant default
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot
系统需要配置:android.hardware.wifi.supplicant.xml
<manifest version="1.0" type="device">
<hal format="hidl">
<name>android.hardware.wifi.supplicant</name>
<transport>hwbinder</transport>
<version>1.4</version>
<interface>
<name>ISupplicant</name>
<instance>default</instance>
</interface>
</hal>
</manifest>
HAL 系统启动wpa_supplicant服务时的log如下:
04-14 10:37:43.970 850 1213 I SupplicantStaIfaceHal: Starting supplicant using HIDL
04-14 10:37:43.971 850 942 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.net.wifi.WIFI_STATE_CHANGED flg=0x4000010 (has extras) } to org.droidtv.tv.tptvservice/.tvinfo.WifiInfoReceiver
04-14 10:37:43.971 206 206 I hwservicemanager: Since android.hardware.wifi.supplicant@1.0::ISupplicant/default is not registered, trying to start it as a lazy HAL.
04-14 10:37:43.971 1724 1724 D CommonHelperService: Receive:WIFI_STATE_CHANGED_ACTION
04-14 10:37:43.971 850 1213 D SupplicantStaIfaceHal: Successfully triggered start of supplicant using HIDL
01-01 09:05:00.300 1 1 I init : Control message: Processed ctl.interface_start for 'android.hardware.wifi.supplicant@1.0::ISupplicant/default' from pid: 206 (/system/bin/hwservicemanager)
04-14 10:37:44.011 15900 15900 D wpa_supplicant: wpa_supplicant v2.10-devel-12
04-14 10:37:44.012 15900 15900 D wpa_supplicant: Global control interface '@android:wpa_wlan0'