Android automotive 框架

本文记录android automotive框架增加车辆属性的过程.

一.增加 一个车辆属性:

从客户给的表格中增加 主驾座椅按摩 DSM_DrSeatMassageSw 信号

1.1 将客户的信号 按照一对一的关系 从《车辆属性ID定义表》中找到ID ,如下表.

在hardware/interfaces/automotive/vehicle/2.0/types.hal 中 增加HVAC_SEAT_MASSAGE 的定义

在android编译过程中 ,hidl-gen 工具会解析 types.hal 文件,生成out/soong/.intermediates/hardware/interfaces/automotive/vehicle/2.0 目录, 这个目录下有生成的c++ 和java代码。

并更新

++++android10/out/soong/.intermediates/hardware/interfaces/automotive/vehicle/2.0/android.hardware.automotive.vehicle@2.0_genc++_headers/gen/android/hardware/automotive/vehicle/2.0++++ ++++/IVehicle.h++++ 头文件

1.2 修改 DefaultConfig.h

DefaultConfig.h 包含了

#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>

所以可以直接使用变量

1.3 修改代码逻辑 hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/HvacProtocolManager.cpp

增加业务逻辑

1.4 修改 VehicalPropetryIds.java

应用层通过这些 ID 向 Vehicle HAL 发送请求(如读取车速、控制空调),HAL 层根据 ID 识别具体需求并与车辆硬件(如 CAN 总线、传感器)交互。VehiclePropertyIds.java 确保了双方对 "属性" 的理解一致,避免因 ID 混乱导致通信错误。

编译

mmm hardware/interfaces/automotive/vehicle/2.0/

vi out/soong/.intermediates/hardware/interfaces/automotive/vehicle/2.0/android.hardware.automotive.vehicle-V2.0-java_gen_java/gen/srcs/android/hardware/automotive/vehicle/V2_0/VehicleProperty.java

找到新增的属性

/**

* 空挡开关信号

*/

public static final int IVI_NEUTRAL_STS = 557847178 /* (((0x128A | VehiclePropertyGroup:VENDOR) | VehiclePropertyType:INT32) | VehicleArea:GLOBAL) */;

拷贝到packages/services/Car/car-lib/src/android/car/VehiclePropertyIds.java

然后 编译: mmm packages/services/Car/car-lib/通过后 将\out\target\common\obj\JAVA_LIBRARIES\android.car_intermediates下的classes.jar 提供给应用。将其名字改为android.car.jar/

1.5 验证修改

如果是接收信号,参考文档

在can工具下,编辑发送信号

编译系统 ,注意编译系统前 make update-api 将VehicalPropertyIds.java 新增的属性加入current.txt 文件。

刷系统后 验证

可以看到 日志。判断验证是否通过。

相关推荐
ZFJ_张福杰1 小时前
【技术深度】金融 / 钱包级 Android 安全性架构(毒APP)
android·安全·金融·架构·签名证书
Bigger7 小时前
Flutter 开发实战:解决华为 HarmonyOS 任务列表不显示 App 名称的终极指南
android·flutter·华为
利剑 -~10 小时前
mysql面试题整理
android·数据库·mysql
梁同学与Android12 小时前
Android ---【经验篇】ArrayList vs CopyOnWriteArrayList 核心区别,怎么选择?
android·java·开发语言
沐怡旸12 小时前
【翻译】adb screenrecord 帮助文档
android
lienyin13 小时前
Android 简单的SFTP服务端+客户端通信传文件
android
fatiaozhang952719 小时前
中兴B860AV5.2-U_原机安卓4.4.2系统专用_晶晨S905L3SB处理器_线刷固件包
android·电视盒子·刷机固件·机顶盒刷机·中兴b860av5.2-u
儿歌八万首19 小时前
Android 自定义 View 实战:打造一个跟随滑动的丝滑指示器
android·kotlin
我有与与症19 小时前
Kuikly 实战:手把手撸一个跨平台 AI 聊天助手 (ChatDemo)
android
恋猫de小郭19 小时前
Flutter UI 设计库解耦重构进度,官方解答未来如何适配
android·前端·flutter