(八十一)探索hidl-gen使用及IWifi.hal 实现

2023-12-19 07:48

本文主要是介绍(八十一)探索hidl-gen使用及IWifi.hal 实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.文件路径

/hardware/interfaces/wifi/1.0/IWifi.hal

/** Copyright 2016 The Android Open Source Project** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package android.hardware.wifi@1.0;import IWifiChip;
import IWifiEventCallback;/*** This is the root of the HAL module and is the interface returned when* loading an implementation of the Wi-Fi HAL. There must be at most one* module loaded in the system.*/
interface IWifi {/*** Requests notifications of significant events for the HAL. Multiple calls to* this must register multiple callbacks each of which must receive all* events. |IWifiEventCallback| object registration must be independent of the* state of the rest of the HAL and must persist though stops/starts. These* objects must be deleted when the corresponding client process is dead.** @param callback An instance of the |IWifiEventCallback| HIDL interface*        object.* @return status WifiStatus of the operation.*         Possible status codes:*         |WifiStatusCode.SUCCESS|,*         |WifiStatusCode.UNKNOWN|*/@entry@callflow(next={"*"})registerEventCallback(IWifiEventCallback callback)generates (WifiStatus status);/*** Get the current state of the HAL.** @return started true if started, false otherwise.*/isStarted() generates (bool started);/*** Perform any setup that is required to make use of the module. If the module* is already started then this must be a noop.* Must trigger |IWifiEventCallback.onStart| on success.** @return status WifiStatus of the operation.*         Possible status codes:*         |WifiStatusCode.SUCCESS|,*         |WifiStatusCode.NOT_AVAILABLE|,*         |WifiStatusCode.UNKNOWN|*/@entry@callflow(next={"registerEventCallback", "start", "stop", "getChip"})start() generates (WifiStatus status);/*** Tear down any state, ongoing commands, etc. If the module is already* stopped then this must be a noop. If the HAL is already stopped or it* succeeds then onStop must be called. After calling this all IWifiChip* objects will be considered invalid.* Must trigger |IWifiEventCallback.onStop| on success.* Must trigger |IWifiEventCallback.onFailure| on failure.** Calling stop then start is a valid way of resetting state in the HAL,* driver, firmware.** @return status WifiStatus of the operation.*         Possible status codes:*         |WifiStatusCode.SUCCESS|,*         |WifiStatusCode.NOT_STARTED|,*         |WifiStatusCode.UNKNOWN|*/@exit@callflow(next={"registerEventCallback", "start", "stop"})stop() generates (WifiStatus status);/*** Retrieve the list of all chip Id's on the device.* The corresponding |IWifiChip| object for any chip can be* retrieved using |getChip| method.** @return status WifiStatus of the operation.*         Possible status codes:*         |WifiStatusCode.SUCCESS|,*         |WifiStatusCode.NOT_STARTED|,*         |WifiStatusCode.UNKNOWN|* @return chipIds List of all chip Id's on the device.*/@callflow(next={"*"})getChipIds() generates (WifiStatus status, vec<ChipId> chipIds);/*** Gets a HIDL interface object for the chip corresponding to the* provided chipId.** @return status WifiStatus of the operation.*         Possible status codes:*         |WifiStatusCode.SUCCESS|,*         |WifiStatusCode.NOT_STARTED|,*         |WifiStatusCode.UNKNOWN|* @return chip HIDL interface object representing the chip.*/@callflow(next={"*"})getChip(ChipId chipId) generates (WifiStatus status, IWifiChip chip);
};

看起来也挺简单的,就是定义了一些未实现的接口,和接口定义差不多。

 

2.对应Android.bp文件

// This file is autogenerated by hidl-gen. Do not edit manually.filegroup {name: "android.hardware.wifi@1.0_hal",srcs: ["types.hal","IWifi.hal","IWifiApIface.hal","IWifiChip.hal","IWifiChipEventCallback.hal","IWifiEventCallback.hal","IWifiIface.hal","IWifiNanIface.hal","IWifiNanIfaceEventCallback.hal","IWifiP2pIface.hal","IWifiRttController.hal","IWifiRttControllerEventCallback.hal","IWifiStaIface.hal","IWifiStaIfaceEventCallback.hal",],
}genrule {name: "android.hardware.wifi@1.0_genc++",tools: ["hidl-gen"],cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi@1.0",srcs: [":android.hardware.wifi@1.0_hal",],out: ["android/hardware/wifi/1.0/types.cpp","android/hardware/wifi/1.0/WifiAll.cpp","android/hardware/wifi/1.0/WifiApIfaceAll.cpp","android/hardware/wifi/1.0/WifiChipAll.cpp","android/hardware/wifi/1.0/WifiChipEventCallbackAll.cpp","android/hardware/wifi/1.0/WifiEventCallbackAll.cpp","android/hardware/wifi/1.0/WifiIfaceAll.cpp","android/hardware/wifi/1.0/WifiNanIfaceAll.cpp","android/hardware/wifi/1.0/WifiNanIfaceEventCallbackAll.cpp","android/hardware/wifi/1.0/WifiP2pIfaceAll.cpp","android/hardware/wifi/1.0/WifiRttControllerAll.cpp","android/hardware/wifi/1.0/WifiRttControllerEventCallbackAll.cpp","android/hardware/wifi/1.0/WifiStaIfaceAll.cpp","android/hardware/wifi/1.0/WifiStaIfaceEventCallbackAll.cpp",],
}genrule {name: "android.hardware.wifi@1.0_genc++_headers",tools: ["hidl-gen"],cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi@1.0",srcs: [":android.hardware.wifi@1.0_hal",],out: ["android/hardware/wifi/1.0/types.h","android/hardware/wifi/1.0/hwtypes.h","android/hardware/wifi/1.0/IWifi.h","android/hardware/wifi/1.0/IHwWifi.h","android/hardware/wifi/1.0/BnHwWifi.h","android/hardware/wifi/1.0/BpHwWifi.h","android/hardware/wifi/1.0/BsWifi.h","android/hardware/wifi/1.0/IWifiApIface.h","android/hardware/wifi/1.0/IHwWifiApIface.h","android/hardware/wifi/1.0/BnHwWifiApIface.h","android/hardware/wifi/1.0/BpHwWifiApIface.h","android/hardware/wifi/1.0/BsWifiApIface.h","android/hardware/wifi/1.0/IWifiChip.h","android/hardware/wifi/1.0/IHwWifiChip.h","android/hardware/wifi/1.0/BnHwWifiChip.h","android/hardware/wifi/1.0/BpHwWifiChip.h","android/hardware/wifi/1.0/BsWifiChip.h","android/hardware/wifi/1.0/IWifiChipEventCallback.h","android/hardware/wifi/1.0/IHwWifiChipEventCallback.h","android/hardware/wifi/1.0/BnHwWifiChipEventCallback.h","android/hardware/wifi/1.0/BpHwWifiChipEventCallback.h","android/hardware/wifi/1.0/BsWifiChipEventCallback.h","android/hardware/wifi/1.0/IWifiEventCallback.h","android/hardware/wifi/1.0/IHwWifiEventCallback.h","android/hardware/wifi/1.0/BnHwWifiEventCallback.h","android/hardware/wifi/1.0/BpHwWifiEventCallback.h","android/hardware/wifi/1.0/BsWifiEventCallback.h","android/hardware/wifi/1.0/IWifiIface.h","android/hardware/wifi/1.0/IHwWifiIface.h","android/hardware/wifi/1.0/BnHwWifiIface.h","android/hardware/wifi/1.0/BpHwWifiIface.h","android/hardware/wifi/1.0/BsWifiIface.h","android/hardware/wifi/1.0/IWifiNanIface.h","android/hardware/wifi/1.0/IHwWifiNanIface.h","android/hardware/wifi/1.0/BnHwWifiNanIface.h","android/hardware/wifi/1.0/BpHwWifiNanIface.h","android/hardware/wifi/1.0/BsWifiNanIface.h","android/hardware/wifi/1.0/IWifiNanIfaceEventCallback.h","android/hardware/wifi/1.0/IHwWifiNanIfaceEventCallback.h","android/hardware/wifi/1.0/BnHwWifiNanIfaceEventCallback.h","android/hardware/wifi/1.0/BpHwWifiNanIfaceEventCallback.h","android/hardware/wifi/1.0/BsWifiNanIfaceEventCallback.h","android/hardware/wifi/1.0/IWifiP2pIface.h","android/hardware/wifi/1.0/IHwWifiP2pIface.h","android/hardware/wifi/1.0/BnHwWifiP2pIface.h","android/hardware/wifi/1.0/BpHwWifiP2pIface.h","android/hardware/wifi/1.0/BsWifiP2pIface.h","android/hardware/wifi/1.0/IWifiRttController.h","android/hardware/wifi/1.0/IHwWifiRttController.h","android/hardware/wifi/1.0/BnHwWifiRttController.h","android/hardware/wifi/1.0/BpHwWifiRttController.h","android/hardware/wifi/1.0/BsWifiRttController.h","android/hardware/wifi/1.0/IWifiRttControllerEventCallback.h","android/hardware/wifi/1.0/IHwWifiRttControllerEventCallback.h","android/hardware/wifi/1.0/BnHwWifiRttControllerEventCallback.h","android/hardware/wifi/1.0/BpHwWifiRttControllerEventCallback.h","android/hardware/wifi/1.0/BsWifiRttControllerEventCallback.h","android/hardware/wifi/1.0/IWifiStaIface.h","android/hardware/wifi/1.0/IHwWifiStaIface.h","android/hardware/wifi/1.0/BnHwWifiStaIface.h","android/hardware/wifi/1.0/BpHwWifiStaIface.h","android/hardware/wifi/1.0/BsWifiStaIface.h","android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.h","android/hardware/wifi/1.0/IHwWifiStaIfaceEventCallback.h","android/hardware/wifi/1.0/BnHwWifiStaIfaceEventCallback.h","android/hardware/wifi/1.0/BpHwWifiStaIfaceEventCallback.h","android/hardware/wifi/1.0/BsWifiStaIfaceEventCallback.h",],
}cc_library {name: "android.hardware.wifi@1.0",defaults: ["hidl-module-defaults"],generated_sources: ["android.hardware.wifi@1.0_genc++"],generated_headers: ["android.hardware.wifi@1.0_genc++_headers"],export_generated_headers: ["android.hardware.wifi@1.0_genc++_headers"],vendor_available: true,vndk: {enabled: true,},shared_libs: ["libhidlbase","libhidltransport","libhwbinder","liblog","libutils","libcutils",],export_shared_lib_headers: ["libhidlbase","libhidltransport","libhwbinder","libutils",],
}

简单地看下这个Android.bp文件:

filegroup-"android.hardware.wifi@1.0_hal":包含了该目录下所有的hal文件

genrule-"android.hardware.wifi@1.0_genc++":使用上面的filegroup作为src编译出对应的cpp文件

genrule-"android.hardware.wifi@1.0_genc++_headers":使用上面的filegroup作为src编译出对应的.h文件

之后下面的抬头“android.hardware.wifi@1.0”经常看到,调用到wifi hal的都会声明到这个。

cc_library {name: "android.hardware.wifi@1.0",defaults: ["hidl-module-defaults"],generated_sources: ["android.hardware.wifi@1.0_genc++"],generated_headers: ["android.hardware.wifi@1.0_genc++_headers"],export_generated_headers: ["android.hardware.wifi@1.0_genc++_headers"],vendor_available: true,vndk: {enabled: true,},shared_libs: ["libhidlbase","libhidltransport","libhwbinder","liblog","libutils","libcutils",],export_shared_lib_headers: ["libhidlbase","libhidltransport","libhwbinder","libutils",],
}

 

2.1 hidl-gen

注意到Android.bp文件中有如下命令是可以生成对应资源的,试一试。

cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi@1.0"

先期准备

1)source build/envsetup.sh2)lunch3)make hidl-gen -j4//[100% 460/460] Install: out/host/linux-x86/bin/hidl-gen

 

2.1.1 生成c++-sources

cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi@1.0"

 

2.1.2 生成c++-headers

cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi@1.0"

 

2.1.3 生成Android.bp

cmd: "$(location hidl-gen) -o $(genDir) -Landroidbp -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi@1.0"

生成的Android.bp文件是和之前一摸一样的。

2.1.4 生成Android.mk

 

2.1.5 生成androidbp-impl

 hidl-gen -o ./test_hidl_wifi/ -Landroidbp-impl -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi@1.0

cc_library_shared {name: "android.hardware.wifi@1.0-impl",relative_install_path: "hw",proprietary: true,srcs: ["Wifi.cpp","WifiApIface.cpp","WifiChip.cpp","WifiChipEventCallback.cpp","WifiEventCallback.cpp","WifiIface.cpp","WifiNanIface.cpp","WifiNanIfaceEventCallback.cpp","WifiP2pIface.cpp","WifiRttController.cpp","WifiRttControllerEventCallback.cpp","WifiStaIface.cpp","WifiStaIfaceEventCallback.cpp",],shared_libs: ["libhidlbase","libhidltransport","libutils","android.hardware.wifi@1.0",],
}

 

2.1.6 生成c++-impl

生成HIDL的默认实现。

看下Wifi.h和Wifi.cpp

#ifndef ANDROID_HARDWARE_WIFI_V1_0_WIFI_H
#define ANDROID_HARDWARE_WIFI_V1_0_WIFI_H#include <android/hardware/wifi/1.0/IWifi.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>namespace android {
namespace hardware {
namespace wifi {
namespace V1_0 {
namespace implementation {using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;struct Wifi : public IWifi {// Methods from IWifi follow.Return<void> registerEventCallback(const sp<IWifiEventCallback>& callback, registerEventCallback_cb _hidl_cb) override;Return<bool> isStarted() override;Return<void> start(start_cb _hidl_cb) override;Return<void> stop(stop_cb _hidl_cb) override;Return<void> getChipIds(getChipIds_cb _hidl_cb) override;Return<void> getChip(uint32_t chipId, getChip_cb _hidl_cb) override;// Methods from ::android::hidl::base::V1_0::IBase follow.};// FIXME: most likely delete, this is only for passthrough implementations
// extern "C" IWifi* HIDL_FETCH_IWifi(const char* name);}  // namespace implementation
}  // namespace V1_0
}  // namespace wifi
}  // namespace hardware
}  // namespace android#endif  // ANDROID_HARDWARE_WIFI_V1_0_WIFI_H

 

#include "Wifi.h"namespace android {
namespace hardware {
namespace wifi {
namespace V1_0 {
namespace implementation {// Methods from IWifi follow.
Return<void> Wifi::registerEventCallback(const sp<IWifiEventCallback>& callback, registerEventCallback_cb _hidl_cb) {// TODO implementreturn Void();
}Return<bool> Wifi::isStarted() {// TODO implementreturn bool {};
}Return<void> Wifi::start(start_cb _hidl_cb) {// TODO implementreturn Void();
}Return<void> Wifi::stop(stop_cb _hidl_cb) {// TODO implementreturn Void();
}Return<void> Wifi::getChipIds(getChipIds_cb _hidl_cb) {// TODO implementreturn Void();
}Return<void> Wifi::getChip(uint32_t chipId, getChip_cb _hidl_cb) {// TODO implementreturn Void();
}// Methods from ::android::hidl::base::V1_0::IBase follow.//IWifi* HIDL_FETCH_IWifi(const char* /* name */) {
//    return new Wifi();
//}}  // namespace implementation
}  // namespace V1_0
}  // namespace wifi
}  // namespace hardware
}  // namespace android

都是空实现,结合hidl是framework和vendor的桥梁,所以实现应该是由vendor实现的?1.1的wifi hal版本中有默认的实现。

/** Copyright (C) 2016 The Android Open Source Project** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/#include <android-base/logging.h>#include "hidl_return_util.h"
#include "wifi.h"
#include "wifi_status_util.h"namespace {
// Chip ID to use for the only supported chip.
static constexpr android::hardware::wifi::V1_0::ChipId kChipId = 0;
}  // namespacenamespace android {
namespace hardware {
namespace wifi {
namespace V1_1 {
namespace implementation {
using hidl_return_util::validateAndCall;
using hidl_return_util::validateAndCallWithLock;Wifi::Wifi(): legacy_hal_(new legacy_hal::WifiLegacyHal()),mode_controller_(new mode_controller::WifiModeController()),run_state_(RunState::STOPPED) {}bool Wifi::isValid() {// This object is always valid.return true;
}Return<void> Wifi::registerEventCallback(const sp<IWifiEventCallback>& event_callback,registerEventCallback_cb hidl_status_cb) {return validateAndCall(this,WifiStatusCode::ERROR_UNKNOWN,&Wifi::registerEventCallbackInternal,hidl_status_cb,event_callback);
}Return<bool> Wifi::isStarted() {return run_state_ != RunState::STOPPED;
}Return<void> Wifi::start(start_cb hidl_status_cb) {return validateAndCall(this,WifiStatusCode::ERROR_UNKNOWN,&Wifi::startInternal,hidl_status_cb);
}Return<void> Wifi::stop(stop_cb hidl_status_cb) {return validateAndCallWithLock(this, WifiStatusCode::ERROR_UNKNOWN,&Wifi::stopInternal, hidl_status_cb);
}Return<void> Wifi::getChipIds(getChipIds_cb hidl_status_cb) {return validateAndCall(this,WifiStatusCode::ERROR_UNKNOWN,&Wifi::getChipIdsInternal,hidl_status_cb);
}Return<void> Wifi::getChip(ChipId chip_id, getChip_cb hidl_status_cb) {return validateAndCall(this,WifiStatusCode::ERROR_UNKNOWN,&Wifi::getChipInternal,hidl_status_cb,chip_id);
}WifiStatus Wifi::registerEventCallbackInternal(const sp<IWifiEventCallback>& event_callback) {if (!event_cb_handler_.addCallback(event_callback)) {return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);}return createWifiStatus(WifiStatusCode::SUCCESS);
}WifiStatus Wifi::startInternal() {if (run_state_ == RunState::STARTED) {return createWifiStatus(WifiStatusCode::SUCCESS);} else if (run_state_ == RunState::STOPPING) {return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE,"HAL is stopping");}WifiStatus wifi_status = initializeLegacyHal();if (wifi_status.code == WifiStatusCode::SUCCESS) {// Create the chip instance once the HAL is started.chip_ = new WifiChip(kChipId, legacy_hal_, mode_controller_);run_state_ = RunState::STARTED;for (const auto& callback : event_cb_handler_.getCallbacks()) {if (!callback->onStart().isOk()) {LOG(ERROR) << "Failed to invoke onStart callback";};}LOG(INFO) << "Wifi HAL started";} else {for (const auto& callback : event_cb_handler_.getCallbacks()) {if (!callback->onFailure(wifi_status).isOk()) {LOG(ERROR) << "Failed to invoke onFailure callback";}}LOG(ERROR) << "Wifi HAL start failed";}return wifi_status;
}WifiStatus Wifi::stopInternal(/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock) {if (run_state_ == RunState::STOPPED) {return createWifiStatus(WifiStatusCode::SUCCESS);} else if (run_state_ == RunState::STOPPING) {return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE,"HAL is stopping");}// Clear the chip object and its child objects since the HAL is now// stopped.if (chip_.get()) {chip_->invalidate();chip_.clear();}WifiStatus wifi_status = stopLegacyHalAndDeinitializeModeController(lock);if (wifi_status.code == WifiStatusCode::SUCCESS) {for (const auto& callback : event_cb_handler_.getCallbacks()) {if (!callback->onStop().isOk()) {LOG(ERROR) << "Failed to invoke onStop callback";};}LOG(INFO) << "Wifi HAL stopped";} else {for (const auto& callback : event_cb_handler_.getCallbacks()) {if (!callback->onFailure(wifi_status).isOk()) {LOG(ERROR) << "Failed to invoke onFailure callback";}}LOG(ERROR) << "Wifi HAL stop failed";}return wifi_status;
}std::pair<WifiStatus, std::vector<ChipId>> Wifi::getChipIdsInternal() {std::vector<ChipId> chip_ids;if (chip_.get()) {chip_ids.emplace_back(kChipId);}return {createWifiStatus(WifiStatusCode::SUCCESS), std::move(chip_ids)};
}std::pair<WifiStatus, sp<IWifiChip>> Wifi::getChipInternal(ChipId chip_id) {if (!chip_.get()) {return {createWifiStatus(WifiStatusCode::ERROR_NOT_STARTED), nullptr};}if (chip_id != kChipId) {return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};}return {createWifiStatus(WifiStatusCode::SUCCESS), chip_};
}WifiStatus Wifi::initializeLegacyHal() {legacy_hal::wifi_error legacy_status = legacy_hal_->initialize();if (legacy_status != legacy_hal::WIFI_SUCCESS) {LOG(ERROR) << "Failed to initialize legacy HAL: "<< legacyErrorToString(legacy_status);return createWifiStatusFromLegacyError(legacy_status);}return createWifiStatus(WifiStatusCode::SUCCESS);
}WifiStatus Wifi::stopLegacyHalAndDeinitializeModeController(/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock) {run_state_ = RunState::STOPPING;legacy_hal::wifi_error legacy_status =legacy_hal_->stop(lock, [&]() { run_state_ = RunState::STOPPED; });if (legacy_status != legacy_hal::WIFI_SUCCESS) {LOG(ERROR) << "Failed to stop legacy HAL: "<< legacyErrorToString(legacy_status);return createWifiStatusFromLegacyError(legacy_status);}if (!mode_controller_->deinitialize()) {LOG(ERROR) << "Failed to deinitialize firmware mode controller";return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);}return createWifiStatus(WifiStatusCode::SUCCESS);
}
}  // namespace implementation
}  // namespace V1_1
}  // namespace wifi
}  // namespace hardware
}  // namespace android

2.1.7 生成hash

/aosp/android_aosp/hardware/interfaces$ vim current.txt

默认与WiFi相关的hash如下所示:

b9be36719a8ad534000a51ea07be91be94c405bf1e038ae825acf65087ffd378 android.hardware.wifi@1.0::IWifi
ee0224ee18813506d9d6f13d8c8e4679f053c290a443a52a7c52a5d3c852262b android.hardware.wifi@1.0::IWifiApIface
f3eecc489deb4c74892f59eb7adb769063bd5c354ac132b626a5f42b363d36bc android.hardware.wifi@1.0::IWifiChip
a1b988377645a58e5e2542ca2bad4e17c21a4a389213d05de2f0e32d57b7d339 android.hardware.wifi@1.0::IWifiChipEventCallback
5ed6760ce77e84bc6c49d1acb3f7d8117c9176b3f06514bc44ad3af84c80dcfe android.hardware.wifi@1.0::IWifiEventCallback
6b9ad43a5efbe6ca214f751e22ce43cf5cd4d5d5f2cba80f24ccd3755a72401c android.hardware.wifi@1.0::IWifiIface
ba5aa74f1ba714f0093864227923492808795bda6199c4ea0891322d27f8c931 android.hardware.wifi@1.0::IWifiNanIface
325c94f3e1a565b56bbc74faddbd0ba7cb824f263dccf9dfff2daf62b86ed774 android.hardware.wifi@1.0::IWifiNanIfaceEventCallback
c2c3f0372b41780fb6dfe83c022296806c2024d7046682fd201de5aa9b791c7a android.hardware.wifi@1.0::IWifiP2pIface
766e9765f5c9c759b2a763c2288353fb5deff3389c2cc28f81d79c939704ce8b android.hardware.wifi@1.0::IWifiRttController
72ab6f3e120cbf07aa6f8e87ca89112bdeb36b7fbb96bce5af3712323ab8b8e6 android.hardware.wifi@1.0::IWifiRttControllerEventCallback
3b8093d39ef1e10e43c5538afbf5ff6e39b8d8168ebbe1998d993e89e25f14a5 android.hardware.wifi@1.0::IWifiStaIface
7fbfc551c3e23c8b4398c3e16e452b516457e6921424a53474cbf373ca306fa9 android.hardware.wifi@1.0::IWifiStaIfaceEventCallback
e20d5132d6d23e072c15de065b5e2aa13ff965031246a2c82581732bae56bf6d android.hardware.wifi@1.0::types
f7e55c08187d8c855068a1ee3d0c8daeee7570292d96509c21a8756d4f5cfb9b android.hardware.wifi.supplicant@1.0::ISupplicant
56b5c7267cb3d3337f44eb8b0b38ff4c6260dcc70e07687fcab94b1ccea8d159 android.hardware.wifi.supplicant@1.0::ISupplicantCallback
35ba7bcdf18f24a866a7e5429548f06768bb20a257f75b10a397c4d825ef8438 android.hardware.wifi.supplicant@1.0::ISupplicantIface
cda01008c06922fa37c1213e9bb831a109b3174532805616fb7161edc403866f android.hardware.wifi.supplicant@1.0::ISupplicantNetwork
4907410338c5e8dbeec4b5edc2608ea323f5561945f8810af81810c47b019184 android.hardware.wifi.supplicant@1.0::ISupplicantP2pIface
8b63f5efa2e3be3a7cb8a428760d82285a4ab79bcbdea6ef90aa547555e582d4 android.hardware.wifi.supplicant@1.0::ISupplicantP2pIfaceCallback
56128f74560571b6777d59453f35c6b35693ee377e2a23c807708906928f09de android.hardware.wifi.supplicant@1.0::ISupplicantP2pNetwork
2067c22197bca9743dab66a6f561a8a8375c67b4f76aed05f776839499bd4c8f android.hardware.wifi.supplicant@1.0::ISupplicantP2pNetworkCallback
7752e1de93aaf5fed37011c219ac247069f6af320b0810daa98510584a10e7b4 android.hardware.wifi.supplicant@1.0::ISupplicantStaIface
d781c8d7e7b3fe5cca8cf6e1d8806e770982ae5358c7816ed51b0f0ec272e70d android.hardware.wifi.supplicant@1.0::ISupplicantStaIfaceCallback
b12ef0bdd8a4d247a8a6e960b227ed32383f2b0241f55d67fcea6eff6a6737fa android.hardware.wifi.supplicant@1.0::ISupplicantStaNetwork
d8f0877ae1d321c1d884c7631dfe36cab0ec8a4b2863d4b687f85d3549a63bcc android.hardware.wifi.supplicant@1.0::ISupplicantStaNetworkCallback
fe3c3c2f572b72f15f8594c538b0577bd5c28722c31879cfe6231330cddb6747 android.hardware.wifi.supplicant@1.0::types

试下如何生成:

对比下hidl-gen生成的和原来的IWifi是否一样:

原来:

b9be36719a8ad534000a51ea07be91be94c405bf1e038ae825acf65087ffd378 android.hardware.wifi@1.0::IWifi

现在:

b9be36719a8ad534000a51ea07be91be94c405bf1e038ae825acf65087ffd378 android.hardware.wifi@1.0::IWifi
 

啊哈,一样的,没毛病。

也可以加::制定具体hidl接口生成hash

 

3. 注册服务

1.1/default/service.cpp

/** Copyright (C) 2016 The Android Open Source Project** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include <utils/Looper.h>
#include <utils/StrongPointer.h>#include "wifi.h"using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;int main(int /*argc*/, char** argv) {android::base::InitLogging(argv,android::base::LogdLogger(android::base::SYSTEM));LOG(INFO) << "Wifi Hal is booting up...";configureRpcThreadpool(1, true /* callerWillJoin */);// Setup hwbinder serviceandroid::sp<android::hardware::wifi::V1_1::IWifi> service =new android::hardware::wifi::V1_1::implementation::Wifi();CHECK_EQ(service->registerAsService(), android::NO_ERROR)<< "Failed to register wifi HAL";joinRpcThreadpool();LOG(INFO) << "Wifi Hal is terminating...";return 0;
}

 

这篇关于(八十一)探索hidl-gen使用及IWifi.hal 实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/511427

相关文章

Linux使用fdisk进行磁盘的相关操作

《Linux使用fdisk进行磁盘的相关操作》fdisk命令是Linux中用于管理磁盘分区的强大文本实用程序,这篇文章主要为大家详细介绍了如何使用fdisk进行磁盘的相关操作,需要的可以了解下... 目录简介基本语法示例用法列出所有分区查看指定磁盘的区分管理指定的磁盘进入交互式模式创建一个新的分区删除一个存

C#使用HttpClient进行Post请求出现超时问题的解决及优化

《C#使用HttpClient进行Post请求出现超时问题的解决及优化》最近我的控制台程序发现有时候总是出现请求超时等问题,通常好几分钟最多只有3-4个请求,在使用apipost发现并发10个5分钟也... 目录优化结论单例HttpClient连接池耗尽和并发并发异步最终优化后优化结论我直接上优化结论吧,

windos server2022里的DFS配置的实现

《windosserver2022里的DFS配置的实现》DFS是WindowsServer操作系统提供的一种功能,用于在多台服务器上集中管理共享文件夹和文件的分布式存储解决方案,本文就来介绍一下wi... 目录什么是DFS?优势:应用场景:DFS配置步骤什么是DFS?DFS指的是分布式文件系统(Distr

NFS实现多服务器文件的共享的方法步骤

《NFS实现多服务器文件的共享的方法步骤》NFS允许网络中的计算机之间共享资源,客户端可以透明地读写远端NFS服务器上的文件,本文就来介绍一下NFS实现多服务器文件的共享的方法步骤,感兴趣的可以了解一... 目录一、简介二、部署1、准备1、服务端和客户端:安装nfs-utils2、服务端:创建共享目录3、服

SpringBoot使用Apache Tika检测敏感信息

《SpringBoot使用ApacheTika检测敏感信息》ApacheTika是一个功能强大的内容分析工具,它能够从多种文件格式中提取文本、元数据以及其他结构化信息,下面我们来看看如何使用Ap... 目录Tika 主要特性1. 多格式支持2. 自动文件类型检测3. 文本和元数据提取4. 支持 OCR(光学

JAVA系统中Spring Boot应用程序的配置文件application.yml使用详解

《JAVA系统中SpringBoot应用程序的配置文件application.yml使用详解》:本文主要介绍JAVA系统中SpringBoot应用程序的配置文件application.yml的... 目录文件路径文件内容解释1. Server 配置2. Spring 配置3. Logging 配置4. Ma

Linux使用dd命令来复制和转换数据的操作方法

《Linux使用dd命令来复制和转换数据的操作方法》Linux中的dd命令是一个功能强大的数据复制和转换实用程序,它以较低级别运行,通常用于创建可启动的USB驱动器、克隆磁盘和生成随机数据等任务,本文... 目录简介功能和能力语法常用选项示例用法基础用法创建可启动www.chinasem.cn的 USB 驱动

C#使用yield关键字实现提升迭代性能与效率

《C#使用yield关键字实现提升迭代性能与效率》yield关键字在C#中简化了数据迭代的方式,实现了按需生成数据,自动维护迭代状态,本文主要来聊聊如何使用yield关键字实现提升迭代性能与效率,感兴... 目录前言传统迭代和yield迭代方式对比yield延迟加载按需获取数据yield break显式示迭

Python实现高效地读写大型文件

《Python实现高效地读写大型文件》Python如何读写的是大型文件,有没有什么方法来提高效率呢,这篇文章就来和大家聊聊如何在Python中高效地读写大型文件,需要的可以了解下... 目录一、逐行读取大型文件二、分块读取大型文件三、使用 mmap 模块进行内存映射文件操作(适用于大文件)四、使用 pand

使用SQL语言查询多个Excel表格的操作方法

《使用SQL语言查询多个Excel表格的操作方法》本文介绍了如何使用SQL语言查询多个Excel表格,通过将所有Excel表格放入一个.xlsx文件中,并使用pandas和pandasql库进行读取和... 目录如何用SQL语言查询多个Excel表格如何使用sql查询excel内容1. 简介2. 实现思路3