1 /*
2  * Copyright (C) 2019 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 #ifndef android_hardware_automotive_vehicle_V2_0_impl_virtialization_GrpcVehicleServer_H_
18 #define android_hardware_automotive_vehicle_V2_0_impl_virtialization_GrpcVehicleServer_H_
19 
20 #include "Utils.h"
21 
22 // TODO(chenjaosjtuacm,egranata): remove this hack during AIDL migration
23 // If building for Android, use the VHAL server definition coming from
24 // hardware/interfaces; if building for a host environment use the older
25 // hardcoded header file coming from our own source code
26 // These two versions export slightly incompatible C++ interfaces but this
27 // only affects building the server, whereas the communication happens over
28 // the VHAL protocol which is stable across Android releases
29 #if defined(ANDROID) || defined(__ANDROID__)
30 #include "vhal_v2_0/DefaultVehicleHalServer.h"
31 #else
32 #include "DefaultVehicleHalServer.h"
33 #endif
34 
35 namespace android {
36 namespace hardware {
37 namespace automotive {
38 namespace vehicle {
39 namespace V2_0 {
40 
41 namespace impl {
42 
43 // Connect to the Vehicle Client via GRPC
44 class GrpcVehicleServer : public DefaultVehicleHalServer {
45   public:
46     // Start listening incoming calls
47     virtual GrpcVehicleServer& Start() = 0;
48 
49     // Wait until error or Stop is called
50     virtual void Wait() = 0;
51 
52     // Stop the server
53     virtual GrpcVehicleServer& Stop() = 0;
54 
55     // Methods for unit tests
56     virtual uint32_t NumOfActivePropertyValueStream() = 0;
57 };
58 
59 using GrpcVehicleServerPtr = std::unique_ptr<GrpcVehicleServer>;
60 
61 GrpcVehicleServerPtr makeGrpcVehicleServer(const VirtualizedVhalServerInfo& serverInfo);
62 
63 }  // namespace impl
64 
65 }  // namespace V2_0
66 }  // namespace vehicle
67 }  // namespace automotive
68 }  // namespace hardware
69 }  // namespace android
70 
71 #endif  // android_hardware_automotive_vehicle_V2_0_impl_virtialization_GrpcVehicleServer_H_
72