You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Automotive 14自定义VHAL属性添加后未生效,求排查

自定义VHAL属性添加后无法在模拟器中识别的问题

已执行的操作

我已在以下路径添加自定义VHAL属性:

1. hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h

const ConfigDeclaration kVehicleProperties[]{
{
.config = {
.prop = VENDOR_WRITE_PROP,
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE
},
.initialValue = {.int32Values = {123}}},
//other props
}

2. hardware/interfaces/automotive/vehicle/aidl/impl/utils/test_vendor_properties/android/hardware/automotive/vehicle/TestVendorProperty.aidl

VENDOR_WRITE_PROP = 0x105 + 0x20000000 + 0x03000000 + 0x00400000,

3. hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v_2_0/PropertyUtils.h

constexpr int VENDOR_WRITE_PROP = (int)(0x105 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::STRING | VehicleArea::GLOBAL);

4. hardware/interfaces/automotive/vehicle/aidl/impl/utils/test_vendor_properties/android/hardware/automotive/vehicle/TestVendorProperties.json

{ "property": "TestVendorProperty::VENDOR_WRITE_PROP", "defaultValue": { "stringValue": "Vendor Property" }, "access": "VehiclePropertyAccess::READ_WRITE", "changeMode": "VehiclePropertyChangeMode::ON_CHANGE"},

完成编译验证后,该属性在Android模拟器中不可用,执行命令adb shell dumpsys car_service get-property-value也无法找到该新增VHAL属性,请问我遗漏了哪些步骤?


遗漏的关键步骤排查

  • 确认VHAL版本匹配:Android 12及以上版本默认使用AIDL版本的VHAL,你同时修改了2.0 HIDL版本和AIDL版本的文件,若当前编译的是AIDL VHAL,2.0版本的DefaultConfig.h和PropertyUtils.h修改不会生效,需聚焦AIDL版本的实现配置。

  • AIDL VHAL属性注册:TestVendorProperties.json仅为测试工具所用,正式AIDL VHAL需将属性配置添加到核心实现中。需确保自定义属性被注册到hardware/interfaces/automotive/vehicle/aidl/impl/VehicleHalAidlImpl.cpp的属性列表,或通过正确的配置加载逻辑引入。

  • 属性类型与初始值匹配:你在PropertyUtils.h中定义属性类型为STRING,但DefaultConfig.h里的initialValue用了int32Values,类型不匹配会导致属性初始化失败。需将初始值改为对应STRING类型的写法:

    .initialValue = {.stringValue = "Vendor Property"}
    
  • 确保模块编译正确:编译模拟器镜像时,需确认AIDL VHAL模块android.hardware.automotive.vehicle@aidl-service被包含在编译目标中,可执行m android.hardware.automotive.vehicle@aidl-service单独编译该模块,再重新生成模拟器镜像。

  • 重启服务/模拟器:编译完成后,需重启模拟器,或执行adb shell stop car_service && adb shell start car_service重启相关服务,确保新的VHAL配置被加载。

  • 先检查VHAL本身的属性列表:不要直接查car_service,先执行adb shell dumpsys vehicle查看VHAL注册的属性。如果VHAL列表里没有该属性,说明是VHAL配置问题;如果有,再排查car_service的同步逻辑。

  • 验证属性ID一致性:虽然你计算的属性ID在两种写法下结果一致,但需确保所有引用VENDOR_WRITE_PROP的地方使用的是同一个ID值,避免因定义不一致导致无法识别。


内容的提问来源于stack exchange,提问作者Star

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 23:53:17