Split vehicle client and server interface header
Since vehicle client may contains some Android-specific types/headers
that may not exist on AGL, we split the header into "client" and "server".
It won't change the logic of Android codes.
Bug: 148877226
Bug: 150791171
Test: build
Change-Id: I550034b071ca6a7ca322fb26b61d76ed4a7307ee
(cherry picked from commit 8dfac92fee
)
Merged-In: I550034b071ca6a7ca322fb26b61d76ed4a7307ee
This commit is contained in:
parent
d599096596
commit
2f2b3bbef6
3 changed files with 152 additions and 79 deletions
|
@ -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 <vector>
|
||||
|
||||
#include <android/hardware/automotive/vehicle/2.0/types.h>
|
||||
|
||||
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<VehiclePropConfig> 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<hidl_string>& /* options */) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace V2_0
|
||||
} // namespace vehicle
|
||||
} // namespace automotive
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
#include <android/hardware/automotive/vehicle/2.0/types.h>
|
||||
|
||||
#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<VehiclePropConfig> 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<hidl_string>& /* 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<VehiclePropConfig> 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<hidl_string>& /* 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
|
||||
|
|
|
@ -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 <vector>
|
||||
|
||||
#include <android/hardware/automotive/vehicle/2.0/types.h>
|
||||
|
||||
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<VehiclePropConfig> 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<hidl_string>& /* options */) {
|
||||
return true;
|
||||
}
|
||||
#endif // __ANDROID__
|
||||
};
|
||||
|
||||
} // namespace V2_0
|
||||
} // namespace vehicle
|
||||
} // namespace automotive
|
||||
} // namespace hardware
|
||||
} // namespace android
|
Loading…
Reference in a new issue