diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleClient.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleClient.h new file mode 100644 index 0000000000..1e2f3add17 --- /dev/null +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleClient.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2020 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. + */ + +#pragma once + +#include + +#include + +namespace android { +namespace hardware { +namespace automotive { +namespace vehicle { +namespace V2_0 { + +/** + * Vehicle HAL talks to the vehicle through a client, instead of accessing + * the car bus directly, to give us more flexibility on the implementation. + * Android OS do not need direct access to the vehicle, and the communication + * channel is also customizable. + * + * Client lives on the Android (HAL) side to talk to the vehicle + */ +class IVehicleClient { + public: + IVehicleClient() = default; + + IVehicleClient(const IVehicleClient&) = delete; + + IVehicleClient& operator=(const IVehicleClient&) = delete; + + IVehicleClient(IVehicleClient&&) = default; + + virtual ~IVehicleClient() = default; + + // Get configuration of all properties from server + virtual std::vector getAllPropertyConfig() const = 0; + + // Send the set property request to server + // updateStatus indicate if VHal should change the status of the value + // it should be false except injecting values for e2e tests + virtual StatusCode setProperty(const VehiclePropValue& value, bool updateStatus) = 0; + + // Receive a new property value from server + // updateStatus is true if and only if the value is + // generated by car (ECU/fake generator/injected) + virtual void onPropertyValue(const VehiclePropValue& value, bool updateStatus) = 0; + + // Dump method forwarded from HIDL's debug() + // If implemented, it must return whether the caller should dump its state. + virtual bool dump(const hidl_handle& /* handle */, const hidl_vec& /* options */) { + return true; + } +}; + +} // namespace V2_0 +} // namespace vehicle +} // namespace automotive +} // namespace hardware +} // namespace android diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleConnector.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleConnector.h index 00b5afe217..2908a55c25 100644 --- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleConnector.h +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleConnector.h @@ -21,6 +21,9 @@ #include +#include "VehicleClient.h" +#include "VehicleServer.h" + namespace android { namespace hardware { namespace automotive { @@ -33,85 +36,6 @@ namespace V2_0 { * regardless of the underlying communication channels. */ -/** - * Vehicle HAL talks to the vehicle through a client, instead of accessing - * the car bus directly, to give us more flexibility on the implementation. - * Android OS do not need direct access to the vehicle, and the communication - * channel is also customizable. - * - * Client lives on the Android (HAL) side to talk to the vehicle - */ -class IVehicleClient { - public: - IVehicleClient() = default; - - IVehicleClient(const IVehicleClient&) = delete; - - IVehicleClient& operator=(const IVehicleClient&) = delete; - - IVehicleClient(IVehicleClient&&) = default; - - virtual ~IVehicleClient() = default; - - // Get configuration of all properties from server - virtual std::vector getAllPropertyConfig() const = 0; - - // Send the set property request to server - // updateStatus indicate if VHal should change the status of the value - // it should be false except injecting values for e2e tests - virtual StatusCode setProperty(const VehiclePropValue& value, bool updateStatus) = 0; - - // Receive a new property value from server - // updateStatus is true if and only if the value is - // generated by car (ECU/fake generator/injected) - virtual void onPropertyValue(const VehiclePropValue& value, bool updateStatus) = 0; - - // Dump method forwarded from HIDL's debug() - // If implemented, it must return whether the caller should dump its state. - virtual bool dump(const hidl_handle& /* handle */, const hidl_vec& /* options */) { - return true; - } -}; - -/** - * Server lives on the vehicle side to talk to Android HAL - */ -class IVehicleServer { - public: - IVehicleServer() = default; - - IVehicleServer(const IVehicleServer&) = delete; - - IVehicleServer& operator=(const IVehicleServer&) = delete; - - IVehicleServer(IVehicleServer&&) = default; - - virtual ~IVehicleServer() = default; - - // Receive the get property configuration request from HAL. - // Return a list of all property config - virtual std::vector onGetAllPropertyConfig() const = 0; - - // Receive the set property request from HAL. - // Process the setting and return the status code - // updateStatus indicate if VHal should change the status of the value - // it should be false except injecting values for e2e tests - virtual StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) = 0; - - // Receive a new property value from car (via direct connection to the car bus or the emulator) - // and forward the value to HAL - // updateStatus is true if and only if the value is - // generated by car (ECU/fake generator/injected) - virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0; - - // Dump method forwarded from HIDL's debug() - // If implemented, it must return whether the caller should dump its state. - virtual bool onDump(const hidl_handle& /* handle */, - const hidl_vec& /* options */) { - return true; - } -}; - /** * If Android has direct access to the vehicle, then the client and * the server may act in passthrough mode to avoid extra IPC diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleServer.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleServer.h new file mode 100644 index 0000000000..27ebbeef55 --- /dev/null +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleServer.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2020 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. + */ + +#pragma once + +#include + +#include + +namespace android { +namespace hardware { +namespace automotive { +namespace vehicle { +namespace V2_0 { + +/** + * Server lives on the vehicle side to talk to Android HAL. + * Note that the server may not be run on Android + */ +class IVehicleServer { + public: + IVehicleServer() = default; + + IVehicleServer(const IVehicleServer&) = delete; + + IVehicleServer& operator=(const IVehicleServer&) = delete; + + IVehicleServer(IVehicleServer&&) = default; + + virtual ~IVehicleServer() = default; + + // Receive the get property configuration request from HAL. + // Return a list of all property config + virtual std::vector onGetAllPropertyConfig() const = 0; + + // Receive the set property request from HAL. + // Process the setting and return the status code + // updateStatus indicate if VHal should change the status of the value + // it should be false except injecting values for e2e tests + virtual StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) = 0; + + // Receive a new property value from car (via direct connection to the car bus or the emulator) + // and forward the value to HAL + // updateStatus is true if and only if the value is + // generated by car (ECU/fake generator/injected) + virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0; + + // TODO (chenhaosjtuacm): fix this since there are no HIDL in non-Android OS +#ifdef __ANDROID__ + // Dump method forwarded from HIDL's debug() + // If implemented, it must return whether the caller should dump its state. + virtual bool onDump(const hidl_handle& /* handle */, + const hidl_vec& /* options */) { + return true; + } +#endif // __ANDROID__ +}; + +} // namespace V2_0 +} // namespace vehicle +} // namespace automotive +} // namespace hardware +} // namespace android