当前位置:网站首页>binder hwbinder vndbinder
binder hwbinder vndbinder
2022-06-27 16:54:00 【菜鸟xiaowang】
一直以来,供应商进程都使用 Binder 进程间通信 (IPC) 技术进行通信。在 Android 8 中,/dev/binder 设备节点成为框架进程的专有节点,这意味着供应商进程无法再访问此节点。供应商进程可以访问 /dev/hwbinder,但必须将其 AIDL 接口转为 HIDL接口。对于想要继续在供应商进程之间使用 AIDL 接口的供应商,Android 会按以下方式支持 Binder IPC。
Android 8 支持供 供应商服务使用的新 Binder 域,访问此域需要使用 /dev/vndbinder(而非 /dev/binder)。添加 /dev/vndbinder 后,Android 现在拥有以下 3 个 IPC 域:

dev/binder
这个是我们最熟悉的Binder,App开发中,ActivityManagerService用的都是这个,Java继承Binder,C++中继承Bbbinder,然后通过servicemanager进程注册实名Binder,然后通过已经创建好的Binder接口传递匿名Binder对象,拿到BinderProxy或者BpBinder以后,就可以Binder通信了。
dev/vndbinder
其实dev/vndbinde和dev/binder使用方式基本一样而且是共用一套Binder SDK,也是Java继承Binder,C++中继承Bbbinder,通过vndservicemanager进程注册实名Binder,然后通过已经创建好的Binder接口传递匿名Binder对象,拿到BinderProxy或者BpBinder以后,就可以Binder通信了。如何在使用同一套Binder SDK的代码,最后访问的设备节点变成dev/vndbinder,servicemanager变成vndservicemanager。
其实只要在你这个进程初始化的时候执行下面这个代码即可
ProcessState::initWithDriver("/dev/vndbinder");dev/binder和dev/vndbinder无法在一个进程中同时使用
dev/hwbinder
硬件接口binder
为什么会引入 HwBinder?
HwBinder 引入的本质还是 Treble 机制的使用,这使得 system 和 vendor 分区相互隔离。在 Android 8.0 之前,Android HAL 与系统框架是紧耦合的,它们打包在一个镜像里。HAL只是一个个的so库,framework 通过打开动态库来调用 HAL。 为了适配 HwBinder,Android 8.0 同时引入了 HIDL,用于建立 framework 和 HAL 间的通信。
经过这个改变后,HAL 可以同时服务于 system 和 vendor。而 HAL 的实现位于 vendor 分区,通过 HwBinder 可以确保 system 和 vendor 独立升级,而不会影响 HAL 的调用。
HIDL是什么
假如Android官方定义了一个ILight.hal的HAL层接口
Interface ILight {
void turnOn();
void turnOff();
}通过编译会自动生成如下两个类LightServer和LightClient的java对象和c++对象。
供应商只需要简单的继承LightServer,并实现turnOn和turnOff的抽象方法,就可以完成Light接口的实现,以及Light服务注册到hwservicemanager。
需要使用ILight接口的进程,只需要调用LightClient的turnOn和turnOff接口,就可以完成从hwservicemanager获得Light服务的Proxy对象,以及ILight的接口调用。
边栏推荐
- 技术分享 | kubernetes pod 简介
- SQL update batch update
- MFS distributed file system
- Solution to Maxwell error (MySQL 8.x connection)
- 新中大冲刺科创板:年营收2.84亿 拟募资5.57亿
- MySQL读取Binlog日志常见错误和解决方法
- Galaxy Kirin V10 system activation
- 阅文、中文在线等网文平台如何布局数字藏品?未来是否会推出“Read/Write-to-Earn”产品?
- [elt.zip] openharmony paper Club - witness file compression system erofs
- Redis 原理 - String
猜你喜欢

Application of tdengine in monitoring of CNC machine tools

Camera calibration with OpenCV

Open source summer 2022 | opengauss project selected and announced

Hikvision tools manager Hikvision tools collection (including sadp, video capacity calculation and other tools) a practical tool for millions of security practitioners

国产数据库认证考试指南汇总(2022年6月16日更新)

Win10 LTSC 2021 wsappx CPU 占用高

Comprehensively analyze the zero knowledge proof: resolve the expansion problem and redefine "privacy security"

Galaxy Kirin V10 system activation

Contest3182 - the 39th individual training match for 2021 freshmen_ F: ss

SQL update batch update
随机推荐
技术分享 | kubernetes pod 简介
数据同步工具 DataX 已经正式支持读写 TDengine
[elt.zip] openharmony paper Club - witness file compression system erofs
[webinar] mongodb and Google cloud accelerate enterprise digital innovation
实施MES管理系统前,要对哪些问题进行评估
网上期货开户安全么?
深度学习和神经网络的介绍
Redis Series 2: data persistence improves availability
Two methods of MySQL database login and logout
PostgreSQL之存储过程篇
推荐几个开源的物联网平台
阅文、中文在线等网文平台如何布局数字藏品?未来是否会推出“Read/Write-to-Earn”产品?
The computer voice is blurry, the video is also out of the card, and the sound cannot be played. It is normal to insert the headset
Don't worry. This is the truth about wages in all industries in China
DFS and BFS simple principle
广发期货开户安全吗?
Keras deep learning practice (12) -- facial feature point detection
The incluxdb cluster function is no longer open source, and the tdengine cluster function is even better
利用OpenCV执行相机校准
Current market situation and development prospect forecast of the global ductless heating, ventilation and air conditioning system industry in 2022