1 /*
2  * Copyright (C) 2022 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 #include "TracingServerImpl.h"
18 #include "vsockinfo.h"
19 
20 #include <iostream>
21 #include <string>
22 
23 using ::android::hardware::automotive::utils::VsockConnectionInfo;
24 using ::android::tools::automotive::tracing::TracingServerImpl;
25 
26 // This is used for testing purpose
27 static const std::string TRACING_SERVICE_ADDR = "vsock:1:50051";
28 
main(int argc,char * argv[])29 int main(int argc, char* argv[]) {
30     std::string server_addr;
31     const auto si = VsockConnectionInfo::fromRoPropertyStore(
32             {
33                     "ro.boot.vendor.tracing.server.cid",
34                     "ro.vendor.tracing.server.cid",
35             },
36             {
37                     "ro.boot.vendor.tracing.server.port",
38                     "ro.vendor.tracing.server.port",
39             });
40 
41     if (!si) {
42         std::cout << "Failed to get server connection cid/port from property file."
43                   << "The default address for testing purpose will be used." << std::endl;
44         server_addr = TRACING_SERVICE_ADDR;
45     } else {
46         server_addr = si->str();
47     }
48 
49     TracingServerImpl server(server_addr);
50     server.Start();
51     return 0;
52 }
53