• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 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 __VTS_FUZZER_TCP_CLIENT_H_
18 #define __VTS_FUZZER_TCP_CLIENT_H_
19 
20 #include <string>
21 #include <vector>
22 
23 #include <VtsDriverCommUtil.h>
24 #include "test/vts/proto/VtsDriverControlMessage.pb.h"
25 
26 using namespace std;
27 
28 namespace android {
29 namespace vts {
30 
31 // Socket client instance for an agent to control a driver.
32 class VtsDriverSocketClient : public VtsDriverCommUtil {
33  public:
VtsDriverSocketClient()34   explicit VtsDriverSocketClient() : VtsDriverCommUtil() {}
35 
36   // closes the socket.
37   void Close();
38 
39   // Sends a EXIT request;
40   bool Exit();
41 
42   // Sends a LOAD_HAL request.
43   int32_t LoadHal(const string& file_path, int target_class, int target_type,
44                   float target_version, const string& target_package,
45                   const string& target_component_name,
46                   const string& hw_binder_service_name,
47                   const string& module_name);
48 
49   // Sends a LIST_FUNCTIONS request.
50   const char* GetFunctions();
51 
52   // Sends a VTS_DRIVER_COMMAND_READ_SPECIFICATION request.
53   const char* ReadSpecification(
54           const string& component_name,
55           int target_class,
56           int target_type,
57           float target_version,
58           const string& target_package);
59 
60   // Sends a CALL_FUNCTION request.
61   const char* Call(const string& arg, const string& uid);
62 
63   // Sends a GET_ATTRIBUTE request.
64   const char* GetAttribute(const string& arg);
65 
66   // Sends a GET_STATUS request.
67   int32_t Status(int32_t type);
68 
69   // Sends a EXECUTE request.
70   VtsDriverControlResponseMessage* ExecuteShellCommand(
71       const ::google::protobuf::RepeatedPtrField<::std::string> shell_command);
72 };
73 
74 // returns the socket port file's path for the given service_name.
75 extern string GetSocketPortFilePath(const string& service_name);
76 
77 // returns true if the specified driver is running.
78 bool IsDriverRunning(const string& service_name, int retry_count);
79 
80 // creates and returns VtsDriverSocketClient of the given service_name.
81 extern VtsDriverSocketClient* GetDriverSocketClient(const string& service_name);
82 
83 }  // namespace vts
84 }  // namespace android
85 
86 #endif  // __VTS_FUZZER_TCP_CLIENT_H_
87