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_virtualization_Utils_H_
18 #define android_hardware_automotive_vehicle_V2_0_impl_virtualization_Utils_H_
19 
20 #include <optional>
21 #include <string>
22 
23 #ifdef __BIONIC__
24 #include <android-base/logging.h>
25 
26 #include <vsockinfo.h>
27 #endif  // __BIONIC__
28 
29 namespace android {
30 namespace hardware {
31 namespace automotive {
32 namespace vehicle {
33 namespace V2_0 {
34 namespace impl {
35 
36 struct VirtualizedVhalServerInfo {
37 #ifdef __BIONIC__
38     android::hardware::automotive::utils::VsockConnectionInfo vsock;
39 #else
40     struct {
41         unsigned cid = 0;
42         unsigned port = 0;
43     } vsock;
44 #endif
45 
46     std::string powerStateMarkerFilePath;
47     std::string powerStateSocket;
48 
49     static std::optional<VirtualizedVhalServerInfo> fromCommandLine(int argc, char* argv[],
50                                                                     std::string* error);
51 
52 #ifdef __BIONIC__
53     static std::optional<VirtualizedVhalServerInfo> fromRoPropertyStore();
54 #endif
55 
56     std::string getServerUri() const;
57 };
58 
59 }  // namespace impl
60 }  // namespace V2_0
61 }  // namespace vehicle
62 }  // namespace automotive
63 }  // namespace hardware
64 }  // namespace android
65 
66 #endif  // android_hardware_automotive_vehicle_V2_0_impl_virtualization_Utils_H_
67