尝试将AUDIO_VOLUME属性添加到/hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/中的演示车辆代码中
文件名:DefaultConfig.h尝试添加如下,但它崩溃了。
{.config =
{
.prop = toInt(VehicleProperty::AUDIO_VOLUME),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.configArray = { toInt(VehicleAudioContextFlag::MUSIC_FLAG), toInt(VehicleAudioVolumeCapabilityFlag::MASTER_VOLUME_ONLY),0,0,100 },
},
.initialValue = {.int32Values = { toInt(VehicleAudioContextFlag::MUSIC_FLAG), 80, toInt(VehicleAudioVolumeState::STATE_OK) } }
},
在/hardware/interfaces/automotive/vehicle/2.0/types.hal中定义的AUDIO_VOLUME属性* @change_mode VehiclePropertyChangeMode:ON_CHANGE * @access VehiclePropertyAccess:READ_WRITE * @config_flags支持所有音频上下文。 * / AUDIO_VOLUME =(0x0901 | VehiclePropertyGroup:SYSTEM | VehiclePropertyType:INT32_VEC | VehicleArea:GLOBAL),
参考OSP代码可在http://androidxref.com/8.0.0_r4/xref/获得
使用hidl_vec打包初始值。
例:
{.config =
{
.prop = toInt(VehicleProperty::AUDIO_VOLUME),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.configArray = { toInt(VehicleAudioContextFlag::MUSIC_FLAG), toInt(VehicleAudioVolumeCapabilityFlag::MASTER_VOLUME_ONLY),0,0,100 },
},
.initialValue = {.int32Values = hidl_vec<int32_t> {toInt(VehicleAudioContextFlag::MUSIC_FLAG), 80, toInt(VehicleAudioVolumeState::STATE_OK) }}
},
由于此属性需要INT32_VEC值。