1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <vector>
20 
21 #include <android/hardware/automotive/vehicle/2.0/types.h>
22 
23 namespace android::hardware::automotive::vehicle::V2_0 {
24 
25 /**
26  *  Vehicle HAL talks to the vehicle through a client, instead of accessing
27  *  the car bus directly, to give us more flexibility on the implementation.
28  *  Android OS do not need direct access to the vehicle, and the communication
29  *  channel is also customizable.
30  *
31  *  Client lives on the Android (HAL) side to talk to the vehicle
32  */
33 class IVehicleClient {
34   public:
35     IVehicleClient() = default;
36 
37     IVehicleClient(const IVehicleClient&) = delete;
38 
39     IVehicleClient& operator=(const IVehicleClient&) = delete;
40 
41     IVehicleClient(IVehicleClient&&) = default;
42 
43     virtual ~IVehicleClient() = default;
44 
45     // Get configuration of all properties from server
46     virtual std::vector<VehiclePropConfig> getAllPropertyConfig() const = 0;
47 
48     // Send the set property request to server
49     // updateStatus indicate if VHal should change the status of the value
50     // it should be false except injecting values for e2e tests
51     virtual StatusCode setProperty(const VehiclePropValue& value, bool updateStatus) = 0;
52 
53     // Receive a new property value from server
54     // updateStatus is true if and only if the value is
55     // generated by car (ECU/fake generator/injected)
56     virtual void onPropertyValue(const VehiclePropValue& value, bool updateStatus) = 0;
57 
58     // Dump method forwarded from HIDL's debug()
59     // If implemented, it must return whether the caller should dump its state.
dump(const hidl_handle &,const hidl_vec<hidl_string> &)60     virtual bool dump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) {
61         return true;
62     }
63 };
64 
65 }  // namespace android::hardware::automotive::vehicle::V2_0
66