• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     // The return structure for onDump function.
32     struct DumpResult {
33         // If callerShouldDumpState is true, caller would print the information in buffer and
34         // continue to dump its state, otherwise would just dump the buffer and skip its own
35         // dumping logic.
36         bool callerShouldDumpState;
37         // The dumped information for the caller to print.
38         std::string buffer;
39     };
40 
41     IVehicleServer() = default;
42 
43     IVehicleServer(const IVehicleServer&) = delete;
44 
45     IVehicleServer& operator=(const IVehicleServer&) = delete;
46 
47     IVehicleServer(IVehicleServer&&) = default;
48 
49     virtual ~IVehicleServer() = default;
50 
51     // Receive the get property configuration request from HAL.
52     // Return a list of all property config
53     virtual std::vector<VehiclePropConfig> onGetAllPropertyConfig() const = 0;
54 
55     // Receive the set property request from HAL.
56     // Process the setting and return the status code
57     // updateStatus indicate if VHal should change the status of the value
58     // it should be false except injecting values for e2e tests
59     virtual StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) = 0;
60 
61     // Receive a new property value from car (via direct connection to the car bus or the emulator)
62     // and forward the value to HAL
63     // updateStatus is true if and only if the value is
64     // generated by car (ECU/fake generator/injected)
65     virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0;
66 
67     // Dump method forwarded from HIDL's debug()
68     // If implemented, it must return whether the caller should dump its state.
69     virtual DumpResult onDump(const std::vector<std::string>& options) = 0;
70 };
71 
72 }  // namespace android::hardware::automotive::vehicle::V2_0
73