framework是如何与WPAS通信的

那么现在我们来反向走读
framework如何通知WPAS执行一些操作的

以 开启wifi 为例,代码走到 WifiNative 之后(不要问我为什么会走到这里)

// WifiNative.java
public boolean connectToNetwork(@NonNull String ifaceName, WifiConfiguration configuration) {
    // Abort ongoing scan before connect() to unblock connection request.
    mWifiCondManager.abortScan(ifaceName);
    return mSupplicantStaIfaceHal.connectToNetwork(ifaceName, configuration);
}
 
//SupplicantStaIfaceHal.java
/**
 * Hal calls for bring up/shut down of the supplicant daemon and for
 * sending requests to the supplicant daemon
 */
/** 
 * checkSupplicantStaNetworkAndLogFailure 方法
 * 根据ifacename从hashmap中取出对应的SupplicantStaNetworkHal
 */
public boolean connectToNetwork(@NonNull String ifaceName, @NonNull WifiConfiguration config) {
    SupplicantStaNetworkHal networkHandle = checkSupplicantStaNetworkAndLogFailure(ifaceName, "connectToNetwork");
    if (!networkHandle.select()) {
        loge("Failed to select network configuration: " + config.getKey());
        return false;
    }
    return true;
}
 
//SupplicantStaNetworkHal.java
/**
 * Wrapper class for ISupplicantStaNetwork HAL calls. Gets and sets supplicant sta network variables
 * and interacts with networks.
 */
/**
 * Trigger a connection to this network.
 * @return true if it succeeds, false otherwise.
 */
public boolean select() {
    synchronized (mLock) {
        final String methodStr = "select";
        if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
        try {
            SupplicantStatus status = mISupplicantStaNetwork.select();
            return checkStatusAndLogFailure(status, methodStr);
        } catch (RemoteException e) {
            handleRemoteException(e, methodStr);
            return false;
        }
    }
}
 
private ISupplicantStaNetwork mISupplicantStaNetwork;

最终,是由 ISupplicantStaNetwork.select() 来完成
ISupplicantStaNetwork 是 framework 与 hal 的联络人

external\wpa_supplicant_8\wpa_supplicant\hidl\1.3\sta_network.h 中
声明了 StaNetwork 这个类

/**
 * Implementation of StaNetwork hidl object. Each unique hidl
 * object is used for control operations on a specific network
 * controlled by wpa_supplicant.
 */
classStaNetwork : public V1_3::ISupplicantStaNetwork

//StaNetwork.select()的具体实现如下

SupplicantStatusStaNetwork::selectInternal()
{
structwpa_ssid*wpa_ssid=retrieveNetworkPtr();
if (wpa_ssid->disabled==2) {
return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
    }
structwpa_supplicant*wpa_s=retrieveIfacePtr();
wpa_s->scan_min_time.sec=0;
wpa_s->scan_min_time.usec=0;
wpa_supplicant_select_network(wpa_s, wpa_ssid);
return {SupplicantStatusCode::SUCCESS, ""};
}

wpa_supplicant_select_network 写在 supplicant 层

这样,连接指令(其实没有指令机制,,,之前想错了)就从framework传到了supplicant
至于,连接动作怎么走到 WifiNative 的,可以看我写的这篇博客
WiFi 启动流程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值