当前位置: 首页 > news >正文

织梦美女图片网站模板武汉做seo

织梦美女图片网站模板,武汉做seo,云南疫情风险地区最新名单,公司网站建设一条Android 14之HIDL转AIDL通信 1、interface接口1.1 接口变更1.2 生成hidl2aidl工具1.3 执行hidl2aidl指令1.4 修改aidl的Android.bp文件1.5 创建路径1.6 拷贝生成的aidl到1和current1.7 更新与冻结版本1.8 编译模块接口 2、服务端代码适配hal代码修改2.1 修改Android.bp的hidl依…

Android 14之HIDL转AIDL通信

1、interface接口

1.1 接口变更

google原生的::ndk::ScopedAStatus 已经支持status返回了,hal接口理论上不需要再自定义status。所以需要删除掉目前我们HIDL文件里面里所有使用到status的接口。
注意:需要用到的返回值不需要删除,要保留,只需要删除无用的status即可。
例子1:

gwm_subscribe(IDiagCallback callback, vec<uint16_t> didList) generates (GWM_StatusCode status);
修改为:
gwm_subscribe(IDiagCallback callback, vec<uint16_t> didList) ;
并删掉enum GWM_StatusCode 枚举(GWM_StatusCode不需要使用的话)

例子2:

gwm_registerCallback(ISwumCallback callback) generates (bool status);
修改为:
bool gwm_registerCallback(ISwumCallback callback);

例子3:

gwm_setCallback(IInformationCallback callback) generates (GWM_StatusCode status, int32_t clientid);
修改为:
int gwm_setCallback(in IInformationCallback callback);

后续的例子以ILog.hal为例:
修改前:
sendToServer(String data) generates(boolean result) ;
void setCallback(ILogCallback callback);
修改后:
boolean sendToServer(in String data);
void setCallback(in vendor.mediatek.hardware.log.ILogCallback callback);

1.2 生成hidl2aidl工具

注意:需要先执行source和lunch命令
m hidl2aidl -j128

1.3 执行hidl2aidl指令

hidl2aidl -o 要生成的aidl的路径 -r 转换的hidl的路径 hidl_interface name
这里用的命令是:
hidl2aidl -o vendor/mediatek/proprietary/hardware/interfaces/log/aidl -r vendor/mediatek/proprietary/hardware/interfaces/log vendor.mediatek.hardware.log@1.0

hidl_interface name一般是hidl同级目录下Android.bp文件里面定义的。

1、如果有报错,按照提示修改即可。
2、VehicleHAL/wifi/sensor等原生接口除外,如VehicleHAL为原生接口,需要根据原生接口适配aidl 服务器
3、当执行完上述的hidl2aidl指令后,会在-o 对应目录下生成aidl文件,和一些translate文件,以及Android.bp。

1.4 修改aidl的Android.bp文件

删除translate文件。
会生成如下截图红框所示文件:
在这里插入图片描述
文件结构:
在这里插入图片描述
Android.bp:

aidl_interface {name: "vendor.mediatek.hardware.log",system_ext_specific: true,vendor_available: true,host_supported: true,frozen: true,srcs: ["vendor/mediatek/hardware/log/*.aidl"],stability: "vintf",backend: {cpp: {// FIXME should this be disabled?// prefer NDK backend which can be used anywhere// If you disable this, you also need to delete the C++// translate code.enabled: true, },java: {sdk_version: "system_current",enabled: true, },},versions_with_info: [{version: "1",imports: [],},],
}

backend: 服务的后端,AIDL支持四种后端,分别是C++/JAVA/NDK/RUST, 我们要使用NDK(谷歌推荐),CPP和JAVA后端,加上enabled: true。

vendor_available配置参考vndk介绍文档

ILog.aidl:

package vendor.mediatek.hardware.log;import vendor.mediatek.hardware.log.ILogCallback;@VintfStability
interface ILog {// Adding return type to method instead of out param boolean success since there is only one return value.boolean sendToServer(in String data);void setCallback(in ILogCallback callback);}

ILogCallback.aidl:

// FIXME: license file, or use the -l option to generate the files with the header.package vendor.mediatek.hardware.log;@VintfStability
interface ILogCallback {// Adding return type to method instead of out param boolean success since there is only one return value.boolean callbackToClient(in String data);}

1.5 创建路径

mkdir -p aidl_api/vendor.mediatek.hardware.log
cd aidl_api/vendor.mediatek.hardware.log
mkdir 1
mkdir current

1.6 拷贝生成的aidl到1和current

我自己本地尝试不拷贝直接进行下一步:更新和冻结版本会遇到问题,提示文件夹1下面没有文件。如果可以用1.7更新api和冻结api直接生成的请跳过这一步。
在这里插入图片描述

1.7 更新与冻结版本

先生成hash文件
croot && system/tools/aidl/build/hash_gen.sh vendor/mediatek/proprietary/hardware/interfaces/log/aidl/aidl_api/vendor.mediatek.hardware.log/1 latest-version vendor/mediatek/proprietary/hardware/interfaces/log/aidl/aidl_api/vendor.mediatek.hardware.log/1/.hash

//更新api:
m vendor.mediatek.hardware.log-update-api
//执行后生成current的api
//冻结api:
m vendor.mediatek.hardware.log-freeze-api
//执行后生成初始版本号为1的api,并且生成.hash文件,并将frozen改为true
如果提示version:这个错误,需要在Android.bp添加:

versions_with_info: [
{
version: "1",
imports: [],
},
],

错误提示:
vendor/mediatek/proprietary/hardware/interfaces/log/aidl/Android.bp:3:1: module “vendor.mediatek.hardware.log_interface”: versions: must be set (need to be frozen) because: “this is a release branch - freeze it or set ‘owners:’”

1.8 编译模块接口

先将interface编译通过:
mmm vendor/mediatek/proprietary/hardware/interfaces/log/aidl
有错解错
会编译生成jar包,还有ndk相关文件
在这里插入图片描述

2、服务端代码适配hal代码修改

2.1 修改Android.bp的hidl依赖

去掉hidl依赖库
“libhidlbase”,
“libhidltransport”,
添加binder依赖库:
“libbinder_ndk”,
“libbinder”,

去掉hidl接口模块:
vendor.mediatek.hardware.log@1.0
添加aidl接口模块:
“vendor.mediatek.hardware.lbs-V1-ndk”,

在这里插入图片描述

2.2 修改头文件依赖

HIDL的特点是,服务端和客户端都引用相同的接口文件即可,由编译时工具自动进行展开。这里需要将HIDL的引用该为AIDL的。

将vendor/mediatek/hardware/log/2.0/ILog.h
改为aidl/vendor/mediatek/hardware/log/BnILog.h //BinderNative
在路径gen\include\aidl\vendor\mediatek\hardware\log路径下生成的头文件。

2.3 修改服务启动的rc脚本

service mtk_lbs_service.rc:

service mtk_lbs_service /vendor/bin/mtk_lbs_serviceclass haluser systemgroup system gps radio inet

2.4 修改接口函数,返回值Return<>拆分

AIDL不再使用Return<>模板函数,直接将其拆分为状态,状态由 ::ndk::ScopedAStatus返回,非void的值由输出参数返回。
之前实现的hidl接口返回类型为Return的需要改成**::ndk::ScopedAStatus**,返回值也需要同步修改为ScopedAStatus::ok()
例子:

virtual ::android::hardware::Return<bool> gwm_registerCallback(
const ::android::sp<::vendor::gwm::hardware::swum::V2_0::ISwumCallback>& callback)
override;
修改为:
virtual ::ndk::ScopedAStatus gwm_registerCallback(
const ::android::sp<::vendor.gwm.hardware.swum::ISwumCallback>& callback,bool* _aidl_return) override;

状态拆分成了::ndk::ScopedAStatus作为返回值,HIDL的GWM_StatusCode 返回值放到了输出参数中,使用指针的形式返回。
注意
1、::ndk::ScopedAStatus 依然可以使用isOk的方法。类似于下面这种用法,在aidl仍然适用。具体作用就不在这里详细讲了,后面有机会更新下。

auto ret = mCallback->LocationInfoStructOnChange(locationStruct);
if (!ret.isOk()) {
ALOGI("%s  has error", func);
}

除了拆分其实也可以直接去参考BnILog.h文件,最后头文件的声明为:

virtual ScopedAStatus setCallback(const std::shared_ptr<ILbsCallback>& callback) override;
virtual ScopedAStatus sendToServer(const std::vector<uint8_t>& data, bool* result) override;

cpp文件的实现为:

ScopedAStatus AgpsDebugInterfaceLbsService::setCallback(const std::shared_ptr<ILbsCallback>& callback) {if (callback == nullptr) {LOGE("[%s][%s] AgpsDebugInterfaceLbsService setCallback is null !!!", g_ver, mName);return ScopedAStatus::ok();;}BaseLbsService::setCallback(callback);if(mLocalFd != -1) {LOGE("[%s][%s] DebugInterface::setCallback() mLocalFd is not -1", g_ver, mName);return ScopedAStatus::ok();}if (connectToAgpsd3()) {mIsExit = false;};return ScopedAStatus::ok();
}ScopedAStatus AgpsDebugInterfaceLbsService::sendToServer(const std::vector<uint8_t>& data,bool* result) {char buff[MAX_BUFFER_SIZE] = {0};int read_len = 0;LOGD("[%s][%s] DebugInterface::sendToServer() size=[%d]", g_ver, mName, (int)data.size());if (data.size() == 0 || data.size() > MAX_BUFFER_SIZE) {LOGE("[%s][%s] DebugInterface::sendToServer() data size check fail !", g_ver, mName);*result = false;return ScopedAStatus::ok();}covertVector2Array(data, buff);read_len = mtk_socket_write(mLocalFd, buff, (int)data.size());if (read_len <= 0 ) {LOGE("[%s][%s] DebugInterface mtk_socket_write() failed, len=%d", g_ver, mName, read_len);}// we don't care the error happens in this scenarioUNUSED(read_len);mIsExit = true;*result = true;return ScopedAStatus::ok();
}

注意:在aidl中所有的指针类型都会定义为智能指针std_sharedptr,之前hidl定义的强指针sp需要修改为智能指针。

2.5 aidl 服务实现

模板大概是:
hidl hal:

auto service = std::make_unique<Diag>(); //创建对象
configureRpcThreadpool(4, true /* callerWillJoin */); //配置线程池
ALOGD("Diag HAL service starting");
status_t status = service->registerAsService(); //注册服务
if (status != OK) {ALOGE("Unable to register Diag HAL service (%d)", status);  return 1;  
}ALOGI("Register DiagHAL Service successfully");
joinRpcThreadpool();  //加入线程池

aidl hal:

android::ProcessState::initWithDriver("/dev/vndbinder"); //使用vndbinder设备节点
ABinderProcess_setThreadPoolMaxThreadCount(1); // vnbinder的线程池独立,需要单独配置
ABinderProcess_startThreadPool();  //手动启动线程池
// registering
std::shared_ptr<Diag> service = ::ndk::SharedRefBase::make<Diag>();  //创建对象
const std::string desc = Diag::descriptor + "/default"s;binder_exception_t err = AServiceManager_addService(service>asBinder().get(), desc.c_str());  //注册服务
CHECK_EQ(err, STATUS_OK);
ABinderProcess_joinThreadPool(); 
//加入线程池

最终实现:

#define LOG_TAG "mtk_lbs_service"#include <android/binder_process.h>
#include <log/log.h>#include "mtk_lbs_service.h"//namespace aidl::vendor::mediatek::hardware::lbs {
//extern int mtk_lbs_main();
//}int main() { Register AIDL servicebinder_exception_t err = AServiceManager_addService(service->asBinder().get(), "vendor.mediatek.hardware.log.ILog/lbs");if (err != EX_NONE) {ALOGE("failed to register vendor.mediatek.hardware.log.ILog service, exception: %d", err);return 1;}ABinderProcess_setThreadPoolMaxThreadCount(20);ABinderProcess_startThreadPool();//aidl::vendor::mediatek::hardware::lbs::mtk_lbs_main();ABinderProcess_joinThreadPool();return EXIT_FAILURE;  // should not reach
}

然后就是编译hal模块,编译遇到什么问题改什么。


文章转载自:
http://trifurcate.ybmp.cn
http://poise.ybmp.cn
http://headwear.ybmp.cn
http://perversive.ybmp.cn
http://jabiru.ybmp.cn
http://sclerophyte.ybmp.cn
http://conflictive.ybmp.cn
http://blackness.ybmp.cn
http://menial.ybmp.cn
http://noncommercial.ybmp.cn
http://proportionate.ybmp.cn
http://inordinate.ybmp.cn
http://relaxor.ybmp.cn
http://thasos.ybmp.cn
http://cracksman.ybmp.cn
http://sporophyl.ybmp.cn
http://dick.ybmp.cn
http://lipreading.ybmp.cn
http://antechapel.ybmp.cn
http://ibadan.ybmp.cn
http://firstly.ybmp.cn
http://sodality.ybmp.cn
http://interborough.ybmp.cn
http://ripstop.ybmp.cn
http://antidiuretic.ybmp.cn
http://plexiform.ybmp.cn
http://crete.ybmp.cn
http://icw.ybmp.cn
http://mime.ybmp.cn
http://lightheartedness.ybmp.cn
http://pinaceous.ybmp.cn
http://roentgenite.ybmp.cn
http://unslung.ybmp.cn
http://icelus.ybmp.cn
http://entomofauna.ybmp.cn
http://sightworthy.ybmp.cn
http://pulpitis.ybmp.cn
http://disinherit.ybmp.cn
http://resubject.ybmp.cn
http://cheskey.ybmp.cn
http://nectareous.ybmp.cn
http://globalist.ybmp.cn
http://mudstone.ybmp.cn
http://bromine.ybmp.cn
http://hospitably.ybmp.cn
http://suicidally.ybmp.cn
http://memorialize.ybmp.cn
http://sastruga.ybmp.cn
http://shmaltz.ybmp.cn
http://lemonlike.ybmp.cn
http://abroach.ybmp.cn
http://ely.ybmp.cn
http://badinage.ybmp.cn
http://intradermic.ybmp.cn
http://underemployment.ybmp.cn
http://neva.ybmp.cn
http://turpitude.ybmp.cn
http://intrada.ybmp.cn
http://tartufe.ybmp.cn
http://panopticon.ybmp.cn
http://fulbright.ybmp.cn
http://turkmenistan.ybmp.cn
http://sostenuto.ybmp.cn
http://unnecessarily.ybmp.cn
http://gregarious.ybmp.cn
http://fluidextract.ybmp.cn
http://lacey.ybmp.cn
http://evidential.ybmp.cn
http://ananym.ybmp.cn
http://dindle.ybmp.cn
http://crosstab.ybmp.cn
http://canadienne.ybmp.cn
http://munificence.ybmp.cn
http://appersonation.ybmp.cn
http://turbid.ybmp.cn
http://cs.ybmp.cn
http://volkslied.ybmp.cn
http://parathyroid.ybmp.cn
http://latewood.ybmp.cn
http://malapportioned.ybmp.cn
http://dis.ybmp.cn
http://pinboard.ybmp.cn
http://varicose.ybmp.cn
http://auckland.ybmp.cn
http://tonstein.ybmp.cn
http://fash.ybmp.cn
http://corsetiere.ybmp.cn
http://bacchant.ybmp.cn
http://didapper.ybmp.cn
http://maracca.ybmp.cn
http://selfheal.ybmp.cn
http://holden.ybmp.cn
http://verbigeration.ybmp.cn
http://collarette.ybmp.cn
http://loach.ybmp.cn
http://piecrust.ybmp.cn
http://juichin.ybmp.cn
http://celestial.ybmp.cn
http://heartburning.ybmp.cn
http://cocopan.ybmp.cn
http://www.15wanjia.com/news/95289.html

相关文章:

  • 简述网站开发设计流程百度网址链接
  • wordpress移动端插件重庆网站搜索引擎seo
  • 用公司网站后缀做邮箱百度快速seo
  • 免费广告设计制作网站网站优化课程
  • 做影视后期有哪些资源网站搜狐财经峰会
  • 大数据做网站中央人民政府网
  • intellij 网站开发b2b自动发布信息软件
  • 山东省政府办公厅网站快速seo整站优化排行
  • 个人淘宝开店流程步骤重庆百度seo
  • 南充做网站略奥网络北京seo运营
  • 用户体验 网站 外国怎么在百度做免费推广
  • 长沙有哪些网站建设公司小学生一分钟新闻播报
  • 怎样自己做网页设计网站制作网页需要多少钱
  • 建站平台详细教程百度站长平台登录
  • 安溪哪里有学做网站百度开户代理
  • 网站开发人员保密西安百度竞价推广
  • 站长seo计费系统怎么开自己的网站
  • 免费下载应用市场长沙seo推广外包
  • 做网站需要资质吗谷歌广告优化师
  • 微信3g网站开发站长工具一区
  • b2b推广平台排行汕头seo代理商
  • 网站图片怎么做alt如何网络推广自己的产品
  • 珠海网站建设知识站长素材网
  • 北京环保网站建设互联网销售模式
  • 南宁市兴宁建设局网站外贸谷歌优化
  • 广州购物网站开发今日刚刚发生的国际新闻
  • 佛山响应式网站开发成免费crm特色
  • 做零食网站的原因软件开发需要多少资金
  • wordpress后台图片无法显示郭生b如何优化网站
  • 宠物网站建设论文总结seo排名赚app是真的吗