Migrate proto_message_converter to AIDL vhal.

Migrate proto_message_converter to AIDL vhal. This would be used
in grpc vehicleClient/vehiclServer. This CL also creates the
required proto files.

Test: unit tests.
Bug: 199337732
Change-Id: Iac69a8c1578d4aba374ee0d9716da8b6b18ccace
This commit is contained in:
Yu Shan
2021-09-09 18:06:03 -07:00
parent 5e000b8ac8
commit a2bbcd26bd
17 changed files with 1296 additions and 595 deletions

View File

@@ -22,17 +22,19 @@ namespace android {
namespace hardware {
namespace automotive {
namespace vehicle {
namespace defaultconfig {
namespace test {
TEST(DefaultConfigTest, loadDefaultConfigs) {
for (ConfigDeclaration config : kVehicleProperties) {
for (ConfigDeclaration config : getDefaultConfigs()) {
ASSERT_NE(0, config.config.prop);
}
}
} // namespace test
} // namespace defaultconfig
} // namespace vehicle
} // namespace automotive
} // namespace hardware

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
cc_library {
name: "VehicleHalProtoMessageConverter",
srcs: [
"src/*.cpp",
],
vendor: true,
local_include_dirs: ["include"],
export_include_dirs: ["include"],
shared_libs: ["libprotobuf-cpp-full"],
static_libs: [
"VehicleHalProtos",
"VehicleHalUtils",
],
defaults: ["VehicleHalDefaults"],
export_static_lib_headers: ["VehicleHalUtils"],
}
cc_test {
name: "VehicleHalProtoMessageConverterTest",
srcs: [
"test/*.cpp",
],
vendor: true,
defaults: ["VehicleHalDefaults"],
shared_libs: ["libprotobuf-cpp-full"],
static_libs: [
"VehicleHalProtoMessageConverter",
"VehicleHalProtos",
"VehicleHalUtils",
"libgtest",
],
header_libs: ["VehicleHalDefaultConfig"],
test_suites: ["device-tests"],
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef android_hardware_automotive_vehicle_aidl_impl_grpc_utils_proto_message_converter_include_ProtoMessageConverter_H_
#define android_hardware_automotive_vehicle_aidl_impl_grpc_utils_proto_message_converter_include_ProtoMessageConverter_H_
#include <VehicleHalTypes.h>
#include <android/hardware/automotive/vehicle/VehicleAreaConfig.pb.h>
#include <android/hardware/automotive/vehicle/VehiclePropConfig.pb.h>
#include <android/hardware/automotive/vehicle/VehiclePropValue.pb.h>
#include <android/hardware/automotive/vehicle/VehiclePropertyAccess.pb.h>
#include <android/hardware/automotive/vehicle/VehiclePropertyChangeMode.pb.h>
#include <android/hardware/automotive/vehicle/VehiclePropertyStatus.pb.h>
namespace android {
namespace hardware {
namespace automotive {
namespace vehicle {
namespace proto_msg_converter {
// Convert AIDL VehiclePropConfig to Protobuf VehiclePropConfig.
void aidlToProto(
const ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig& inAidlConfig,
::android::hardware::automotive::vehicle::proto::VehiclePropConfig* outProtoConfig);
// Convert Protobuf VehiclePropConfig to AIDL VehiclePropConfig.
void protoToAidl(
const ::android::hardware::automotive::vehicle::proto::VehiclePropConfig& inProtoConfig,
::aidl::android::hardware::automotive::vehicle::VehiclePropConfig* outAidlConfig);
// Convert AIDL VehiclePropValue to Protobuf VehiclePropValue.
void aidlToProto(const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& inAidlVal,
::android::hardware::automotive::vehicle::proto::VehiclePropValue* outProtoVal);
// Convert Protobuf VehiclePropValue to AIDL VehiclePropValue.
void protoToAidl(
const ::android::hardware::automotive::vehicle::proto::VehiclePropValue& inProtoVal,
::aidl::android::hardware::automotive::vehicle::VehiclePropValue* outAidlVal);
} // namespace proto_msg_converter
} // namespace vehicle
} // namespace automotive
} // namespace hardware
} // namespace android
#endif // android_hardware_automotive_vehicle_aidl_impl_grpc_utils_proto_message_converter_include_ProtoMessageConverter_H_

View File

@@ -0,0 +1,146 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "ProtoMsgConverter"
#include "ProtoMessageConverter.h"
#include <VehicleUtils.h>
#include <memory>
#include <vector>
namespace android {
namespace hardware {
namespace automotive {
namespace vehicle {
namespace proto_msg_converter {
namespace aidl_vehicle = ::aidl::android::hardware::automotive::vehicle;
namespace proto = ::android::hardware::automotive::vehicle::proto;
// Copy the vector PROTO_VECNAME of protobuf class PROTO_VALUE to
// VHAL_TYPE_VALUE->VHAL_TYPE_VECNAME, every element of PROTO_VECNAME is casted by CAST.
#define CAST_COPY_PROTOBUF_VEC_TO_VHAL_TYPE(PROTO_VALUE, PROTO_VECNAME, VHAL_TYPE_VALUE, \
VHAL_TYPE_VECNAME, CAST) \
do { \
(VHAL_TYPE_VALUE)->VHAL_TYPE_VECNAME.resize(PROTO_VALUE.PROTO_VECNAME##_size()); \
size_t idx = 0; \
for (auto& value : PROTO_VALUE.PROTO_VECNAME()) { \
VHAL_TYPE_VALUE->VHAL_TYPE_VECNAME[idx++] = CAST(value); \
} \
} while (0)
// Copying the vector PROTO_VECNAME of protobuf class PROTO_VALUE to
// VHAL_TYPE_VALUE->VHAL_TYPE_VECNAME.
#define COPY_PROTOBUF_VEC_TO_VHAL_TYPE(PROTO_VALUE, PROTO_VECNAME, VHAL_TYPE_VALUE, \
VHAL_TYPE_VECNAME) \
CAST_COPY_PROTOBUF_VEC_TO_VHAL_TYPE( \
PROTO_VALUE, PROTO_VECNAME, VHAL_TYPE_VALUE, VHAL_TYPE_VECNAME, /*NO CAST*/)
void aidlToProto(const aidl_vehicle::VehiclePropConfig& in, proto::VehiclePropConfig* out) {
out->set_prop(in.prop);
out->set_access(static_cast<proto::VehiclePropertyAccess>(toInt(in.access)));
out->set_change_mode(static_cast<proto::VehiclePropertyChangeMode>(toInt(in.changeMode)));
out->set_config_string(in.configString.c_str(), in.configString.size());
out->set_min_sample_rate(in.minSampleRate);
out->set_max_sample_rate(in.maxSampleRate);
for (auto& configElement : in.configArray) {
out->add_config_array(configElement);
}
out->clear_area_configs();
for (auto& areaConfig : in.areaConfigs) {
auto* protoACfg = out->add_area_configs();
protoACfg->set_area_id(areaConfig.areaId);
protoACfg->set_min_int64_value(areaConfig.minInt64Value);
protoACfg->set_max_int64_value(areaConfig.maxInt64Value);
protoACfg->set_min_float_value(areaConfig.minFloatValue);
protoACfg->set_max_float_value(areaConfig.maxFloatValue);
protoACfg->set_min_int32_value(areaConfig.minInt32Value);
protoACfg->set_max_int32_value(areaConfig.maxInt32Value);
}
}
void protoToAidl(const proto::VehiclePropConfig& in, aidl_vehicle::VehiclePropConfig* out) {
out->prop = in.prop();
out->access = static_cast<aidl_vehicle::VehiclePropertyAccess>(in.access());
out->changeMode = static_cast<aidl_vehicle::VehiclePropertyChangeMode>(in.change_mode());
out->configString = in.config_string();
out->minSampleRate = in.min_sample_rate();
out->maxSampleRate = in.max_sample_rate();
COPY_PROTOBUF_VEC_TO_VHAL_TYPE(in, config_array, out, configArray);
auto cast_to_acfg = [](const proto::VehicleAreaConfig& protoAcfg) {
return aidl_vehicle::VehicleAreaConfig{
.areaId = protoAcfg.area_id(),
.minInt32Value = protoAcfg.min_int32_value(),
.maxInt32Value = protoAcfg.max_int32_value(),
.minInt64Value = protoAcfg.min_int64_value(),
.maxInt64Value = protoAcfg.max_int64_value(),
.minFloatValue = protoAcfg.min_float_value(),
.maxFloatValue = protoAcfg.max_float_value(),
};
};
CAST_COPY_PROTOBUF_VEC_TO_VHAL_TYPE(in, area_configs, out, areaConfigs, cast_to_acfg);
}
void aidlToProto(const aidl_vehicle::VehiclePropValue& in, proto::VehiclePropValue* out) {
out->set_prop(in.prop);
out->set_timestamp(in.timestamp);
out->set_status(static_cast<proto::VehiclePropertyStatus>(in.status));
out->set_area_id(in.areaId);
out->set_string_value(in.value.stringValue);
out->set_byte_values(in.value.byteValues.data(), in.value.byteValues.size());
for (auto& int32Value : in.value.int32Values) {
out->add_int32_values(int32Value);
}
for (auto& int64Value : in.value.int64Values) {
out->add_int64_values(int64Value);
}
for (auto& floatValue : in.value.floatValues) {
out->add_float_values(floatValue);
}
}
void protoToAidl(const proto::VehiclePropValue& in, aidl_vehicle::VehiclePropValue* out) {
out->prop = in.prop();
out->timestamp = in.timestamp();
out->status = static_cast<aidl_vehicle::VehiclePropertyStatus>(in.status());
out->areaId = in.area_id();
out->value.stringValue = in.string_value();
for (const char& byte : in.byte_values()) {
out->value.byteValues.push_back(byte);
}
COPY_PROTOBUF_VEC_TO_VHAL_TYPE(in, int32_values, out, value.int32Values);
COPY_PROTOBUF_VEC_TO_VHAL_TYPE(in, int64_values, out, value.int64Values);
COPY_PROTOBUF_VEC_TO_VHAL_TYPE(in, float_values, out, value.floatValues);
}
#undef COPY_PROTOBUF_VEC_TO_VHAL_TYPE
#undef CAST_COPY_PROTOBUF_VEC_TO_VHAL_TYPE
} // namespace proto_msg_converter
} // namespace vehicle
} // namespace automotive
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,103 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vector>
#include <DefaultConfig.h>
#include <ProtoMessageConverter.h>
#include <VehicleHalTypes.h>
#include <android-base/format.h>
#include <android/hardware/automotive/vehicle/VehiclePropConfig.pb.h>
#include <android/hardware/automotive/vehicle/VehiclePropValue.pb.h>
#include <gtest/gtest.h>
namespace android {
namespace hardware {
namespace automotive {
namespace vehicle {
namespace proto_msg_converter {
namespace {
namespace proto = ::android::hardware::automotive::vehicle::proto;
namespace aidl_vehicle = ::aidl::android::hardware::automotive::vehicle;
std::vector<aidl_vehicle::VehiclePropConfig> prepareTestConfigs() {
std::vector<aidl_vehicle::VehiclePropConfig> configs;
for (auto& property : defaultconfig::getDefaultConfigs()) {
configs.push_back(property.config);
}
return configs;
}
std::vector<aidl_vehicle::VehiclePropValue> prepareTestValues() {
std::vector<aidl_vehicle::VehiclePropValue> values;
long timestamp = 1;
for (auto& property : defaultconfig::getDefaultConfigs()) {
values.push_back({
.timestamp = timestamp,
.areaId = 123,
.prop = property.config.prop,
.value = property.initialValue,
.status = aidl_vehicle::VehiclePropertyStatus::ERROR,
});
}
return values;
}
class PropConfigConversionTest : public testing::TestWithParam<aidl_vehicle::VehiclePropConfig> {};
class PropValueConversionTest : public testing::TestWithParam<aidl_vehicle::VehiclePropValue> {};
} // namespace
TEST_P(PropConfigConversionTest, testConversion) {
proto::VehiclePropConfig protoCfg;
aidl_vehicle::VehiclePropConfig aidlCfg;
aidlToProto(GetParam(), &protoCfg);
protoToAidl(protoCfg, &aidlCfg);
EXPECT_EQ(aidlCfg, GetParam());
}
TEST_P(PropValueConversionTest, testConversion) {
proto::VehiclePropValue protoVal;
aidl_vehicle::VehiclePropValue aidlVal;
aidlToProto(GetParam(), &protoVal);
protoToAidl(protoVal, &aidlVal);
EXPECT_EQ(aidlVal, GetParam());
}
INSTANTIATE_TEST_SUITE_P(DefaultConfigs, PropConfigConversionTest,
::testing::ValuesIn(prepareTestConfigs()),
[](const ::testing::TestParamInfo<aidl_vehicle::VehiclePropConfig>& info) {
return ::fmt::format("property_{:d}", info.param.prop);
});
INSTANTIATE_TEST_SUITE_P(TestValues, PropValueConversionTest,
::testing::ValuesIn(prepareTestValues()),
[](const ::testing::TestParamInfo<aidl_vehicle::VehiclePropValue>& info) {
return ::fmt::format("property_{:d}", info.param.prop);
});
} // namespace proto_msg_converter
} // namespace vehicle
} // namespace automotive
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,91 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
filegroup {
name: "VehicleHalProtoFiles",
srcs: ["**/*.proto"],
visibility: ["//hardware/interfaces/automotive/vehicle:__subpackages__"],
}
genrule {
name: "VehicleProtoStub_h",
tools: [
"aprotoc",
"protoc-gen-grpc-cpp-plugin",
],
cmd: "$(location aprotoc) -Ihardware/interfaces/automotive/vehicle/aidl/impl/proto -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)",
srcs: [
":VehicleHalProtoFiles",
],
out: [
"android/hardware/automotive/vehicle/DumpResult.pb.h",
"android/hardware/automotive/vehicle/StatusCode.pb.h",
"android/hardware/automotive/vehicle/VehicleAreaConfig.pb.h",
"android/hardware/automotive/vehicle/VehiclePropConfig.pb.h",
"android/hardware/automotive/vehicle/VehiclePropertyAccess.pb.h",
"android/hardware/automotive/vehicle/VehiclePropertyChangeMode.pb.h",
"android/hardware/automotive/vehicle/VehiclePropertyStatus.pb.h",
"android/hardware/automotive/vehicle/VehiclePropValue.pb.h",
"android/hardware/automotive/vehicle/VehiclePropValueRequest.pb.h",
],
}
genrule {
name: "VehicleProtoStub_cc",
tools: [
"aprotoc",
"protoc-gen-grpc-cpp-plugin",
],
cmd: "$(location aprotoc) -Ihardware/interfaces/automotive/vehicle/aidl/impl/proto -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)",
srcs: [
":VehicleHalProtoFiles",
],
out: [
"android/hardware/automotive/vehicle/DumpResult.pb.cc",
"android/hardware/automotive/vehicle/StatusCode.pb.cc",
"android/hardware/automotive/vehicle/VehicleAreaConfig.pb.cc",
"android/hardware/automotive/vehicle/VehiclePropConfig.pb.cc",
"android/hardware/automotive/vehicle/VehiclePropertyAccess.pb.cc",
"android/hardware/automotive/vehicle/VehiclePropertyChangeMode.pb.cc",
"android/hardware/automotive/vehicle/VehiclePropertyStatus.pb.cc",
"android/hardware/automotive/vehicle/VehiclePropValue.pb.cc",
"android/hardware/automotive/vehicle/VehiclePropValueRequest.pb.cc",
],
}
cc_library_static {
name: "VehicleHalProtos",
vendor: true,
host_supported: true,
include_dirs: [
"external/protobuf/src",
],
generated_headers: [
"VehicleProtoStub_h",
],
export_generated_headers: [
"VehicleProtoStub_h",
],
generated_sources: [
"VehicleProtoStub_cc",
],
shared_libs: [
"libgrpc++_unsecure",
],
cflags: [
"-Wno-unused-parameter",
],
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
message DumpResult {
/* If callerShouldDumpState is true, caller would print the information in buffer and
* continue to dump its state, otherwise would just dump the buffer and skip its own
* dumping logic. */
bool caller_should_dump_state = 1;
/* The dumped information for the caller to print. */
string buffer = 2;
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
/* Must be in sync with StatusCode.aidl. */
enum StatusCode {
OK = 0;
/* Try again. */
TRY_AGAIN = 1;
/* Invalid argument provided. */
INVALID_ARG = 2;
/* This code must be returned when device that associated with the vehicle
* property is not available. For example, when client tries to set HVAC
* temperature when the whole HVAC unit is turned OFF. */
NOT_AVAILABLE = 3;
/* Access denied */
ACCESS_DENIED = 4;
/* Something unexpected has happened in Vehicle HAL */
INTERNAL_ERROR = 5;
};

View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
/* Must be in sync with VehicleAreaConfig.aidl. */
message VehicleAreaConfig {
/* Area id is ignored for VehiclePropertyGroup:GLOBAL properties. */
int32 area_id = 1;
/* If the property has @data_enum, leave the range to zero.
*
* Range will be ignored in the following cases:
* - The VehiclePropertyType is not INT32, INT64 or FLOAT.
* - Both of min value and max value are zero. */
int32 min_int32_value = 2;
int32 max_int32_value = 3;
int64 min_int64_value = 4;
int64 max_int64_value = 5;
float min_float_value = 6;
float max_float_value = 7;
};

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
import "android/hardware/automotive/vehicle/VehicleAreaConfig.proto";
import "android/hardware/automotive/vehicle/VehiclePropertyAccess.proto";
import "android/hardware/automotive/vehicle/VehiclePropertyChangeMode.proto";
/* Must be in sync with VehiclePropConfig.aidl. */
message VehiclePropConfig {
/* Property identifier */
int32 prop = 1;
/* Defines if the property is read or write or both. */
VehiclePropertyAccess access = 2;
/* Defines the change mode of the property. */
VehiclePropertyChangeMode change_mode = 3;
/* Contains per-area configuration. */
repeated VehicleAreaConfig area_configs = 4;
/* Contains additional configuration parameters */
repeated int32 config_array = 5;
/* Some properties may require additional information passed over this
* string. Most properties do not need to set this. */
bytes config_string = 6;
/* Min sample rate in Hz.
* Must be defined for VehiclePropertyChangeMode::CONTINUOUS */
float min_sample_rate = 7;
/* Must be defined for VehiclePropertyChangeMode::CONTINUOUS
* Max sample rate in Hz. */
float max_sample_rate = 8;
};

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
import "android/hardware/automotive/vehicle/VehiclePropertyStatus.proto";
/* Must be in sync with VehiclePropValue.aidl. */
message VehiclePropValue {
/* Time is elapsed nanoseconds since boot */
int64 timestamp = 1;
/* Area type(s) for non-global property it must be one of the value from
* VehicleArea* enums or 0 for global properties. */
int32 area_id = 2;
/* Property identifier */
int32 prop = 3;
/* Status of the property */
VehiclePropertyStatus status = 4;
/* This is used for properties of types VehiclePropertyType#INT
* and VehiclePropertyType#INT_VEC */
repeated int32 int32_values = 5;
/* This is used for properties of types VehiclePropertyType#FLOAT
* and VehiclePropertyType#FLOAT_VEC */
repeated float float_values = 6;
/* This is used for properties of type VehiclePropertyType#INT64 */
repeated int64 int64_values = 7;
/* This is used for properties of type VehiclePropertyType#BYTES */
bytes byte_values = 8;
/* This is used for properties of type VehiclePropertyType#STRING */
string string_value = 9;
};

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
import "android/hardware/automotive/vehicle/VehiclePropValue.proto";
message VehiclePropValueRequest {
int32 request_id = 1;
VehiclePropValue value = 2;
};

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
/* Must be in sync with VehiclePropertyAccess.aidl. */
enum VehiclePropertyAccess {
NONE = 0;
READ = 1;
WRITE = 2;
READ_WRITE = 3;
};

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
/* Must be in sync with VehiclePropertyChangeMode.aidl. */
enum VehiclePropertyChangeMode {
/* Property of this type must never be changed. Subscription is not supported
* for these properties. */
STATIC = 0;
/* Properties of this type must report when there is a change.
* IVehicle#get call must return the current value.
* Set operation for this property is assumed to be asynchronous. When the
* property is read (using IVehicle#get) after IVehicle#set, it may still
* return old value until underlying H/W backing this property has actually
* changed the state. Once state is changed, the property must dispatch
* changed value as event. */
ON_CHANGE = 1;
/* Properties of this type change continuously and require a fixed rate of
* sampling to retrieve the data. Implementers may choose to send extra
* notifications on significant value changes. */
CONTINUOUS = 2;
};

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package android.hardware.automotive.vehicle.proto;
/* Must be in sync with VehiclePropertyStatus.aidl. */
enum VehiclePropertyStatus {
/* Property is available and behaving normally */
AVAILABLE = 0;
/* A property in this state is not available for reading and writing. This
* is a transient state that depends on the availability of the underlying
* implementation (e.g. hardware or driver). It MUST NOT be used to
* represent features that this vehicle is always incapable of. A get() of
* a property in this state MAY return an undefined value, but MUST
* correctly describe its status as UNAVAILABLE A set() of a property in
* this state MAY return NOT_AVAILABLE. The HAL implementation MUST ignore
* the value of the status field when writing a property value coming from
* Android. */
UNAVAILABLE = 1;
/* There is an error with this property. */
ERROR = 2;
};

View File

@@ -20,9 +20,7 @@ package {
cc_library {
name: "VehicleHalUtils",
srcs: [
"src/*.cpp",
],
srcs: ["src/*.cpp"],
vendor: true,
local_include_dirs: ["include"],
export_include_dirs: ["include"],