(八十一)探索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

相关文章

分布式锁在Spring Boot应用中的实现过程

《分布式锁在SpringBoot应用中的实现过程》文章介绍在SpringBoot中通过自定义Lock注解、LockAspect切面和RedisLockUtils工具类实现分布式锁,确保多实例并发操作... 目录Lock注解LockASPect切面RedisLockUtils工具类总结在现代微服务架构中,分布

Java使用Thumbnailator库实现图片处理与压缩功能

《Java使用Thumbnailator库实现图片处理与压缩功能》Thumbnailator是高性能Java图像处理库,支持缩放、旋转、水印添加、裁剪及格式转换,提供易用API和性能优化,适合Web应... 目录1. 图片处理库Thumbnailator介绍2. 基本和指定大小图片缩放功能2.1 图片缩放的

Python使用Tenacity一行代码实现自动重试详解

《Python使用Tenacity一行代码实现自动重试详解》tenacity是一个专为Python设计的通用重试库,它的核心理念就是用简单、清晰的方式,为任何可能失败的操作添加重试能力,下面我们就来看... 目录一切始于一个简单的 API 调用Tenacity 入门:一行代码实现优雅重试精细控制:让重试按我

MySQL中EXISTS与IN用法使用与对比分析

《MySQL中EXISTS与IN用法使用与对比分析》在MySQL中,EXISTS和IN都用于子查询中根据另一个查询的结果来过滤主查询的记录,本文将基于工作原理、效率和应用场景进行全面对比... 目录一、基本用法详解1. IN 运算符2. EXISTS 运算符二、EXISTS 与 IN 的选择策略三、性能对比

Redis客户端连接机制的实现方案

《Redis客户端连接机制的实现方案》本文主要介绍了Redis客户端连接机制的实现方案,包括事件驱动模型、非阻塞I/O处理、连接池应用及配置优化,具有一定的参考价值,感兴趣的可以了解一下... 目录1. Redis连接模型概述2. 连接建立过程详解2.1 连php接初始化流程2.2 关键配置参数3. 最大连

Python实现网格交易策略的过程

《Python实现网格交易策略的过程》本文讲解Python网格交易策略,利用ccxt获取加密货币数据及backtrader回测,通过设定网格节点,低买高卖获利,适合震荡行情,下面跟我一起看看我们的第一... 网格交易是一种经典的量化交易策略,其核心思想是在价格上下预设多个“网格”,当价格触发特定网格时执行买

使用Python构建智能BAT文件生成器的完美解决方案

《使用Python构建智能BAT文件生成器的完美解决方案》这篇文章主要为大家详细介绍了如何使用wxPython构建一个智能的BAT文件生成器,它不仅能够为Python脚本生成启动脚本,还提供了完整的文... 目录引言运行效果图项目背景与需求分析核心需求技术选型核心功能实现1. 数据库设计2. 界面布局设计3

使用IDEA部署Docker应用指南分享

《使用IDEA部署Docker应用指南分享》本文介绍了使用IDEA部署Docker应用的四步流程:创建Dockerfile、配置IDEADocker连接、设置运行调试环境、构建运行镜像,并强调需准备本... 目录一、创建 dockerfile 配置文件二、配置 IDEA 的 Docker 连接三、配置 Do

Android Paging 分页加载库使用实践

《AndroidPaging分页加载库使用实践》AndroidPaging库是Jetpack组件的一部分,它提供了一套完整的解决方案来处理大型数据集的分页加载,本文将深入探讨Paging库... 目录前言一、Paging 库概述二、Paging 3 核心组件1. PagingSource2. Pager3.

python设置环境变量路径实现过程

《python设置环境变量路径实现过程》本文介绍设置Python路径的多种方法:临时设置(Windows用`set`,Linux/macOS用`export`)、永久设置(系统属性或shell配置文件... 目录设置python路径的方法临时设置环境变量(适用于当前会话)永久设置环境变量(Windows系统