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  *  Server lives on the vehicle side to talk to Android HAL.
27  *  Note that the server may not be run on Android
28  */
29 class IVehicleServer {
30   public:
31     IVehicleServer() = default;
32 
33     IVehicleServer(const IVehicleServer&) = delete;
34 
35     IVehicleServer& operator=(const IVehicleServer&) = delete;
36 
37     IVehicleServer(IVehicleServer&&) = default;
38 
39     virtual ~IVehicleServer() = default;
40 
41     // Receive the get property configuration request from HAL.
42     // Return a list of all property config
43     virtual std::vector<VehiclePropConfig> onGetAllPropertyConfig() const = 0;
44 
45     // Receive the set property request from HAL.
46     // Process the setting and return the status code
47     // updateStatus indicate if VHal should change the status of the value
48     // it should be false except injecting values for e2e tests
49     virtual StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) = 0;
50 
51     // Receive a new property value from car (via direct connection to the car bus or the emulator)
52     // and forward the value to HAL
53     // updateStatus is true if and only if the value is
54     // generated by car (ECU/fake generator/injected)
55     virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0;
56 
57     // TODO (chenhaosjtuacm): fix this since there are no HIDL in non-Android OS
58 #ifdef __ANDROID__
59     // Dump method forwarded from HIDL's debug()
60     // If implemented, it must return whether the caller should dump its state.
onDump(const hidl_handle &,const hidl_vec<hidl_string> &)61     virtual bool onDump(const hidl_handle& /* handle */,
62                         const hidl_vec<hidl_string>& /* options */) {
63         return true;
64     }
65 #endif  // __ANDROID__
66 };
67 
68 }  // namespace android::hardware::automotive::vehicle::V2_0
69