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: 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 string GetFunctions(); 51 52 // Sends a VTS_DRIVER_COMMAND_READ_SPECIFICATION request. 53 string ReadSpecification(const string& component_name, int target_class, 54 int target_type, float target_version, 55 const string& target_package); 56 57 // Sends a CALL_FUNCTION request. 58 string Call(const string& arg, const string& uid); 59 60 // Sends a GET_ATTRIBUTE request. 61 string GetAttribute(const string& arg); 62 63 // Sends a GET_STATUS request. 64 int32_t Status(int32_t type); 65 66 // Sends a EXECUTE request. 67 unique_ptr<VtsDriverControlResponseMessage> ExecuteShellCommand( 68 const ::google::protobuf::RepeatedPtrField<::std::string> shell_command); 69 }; 70 71 // returns the socket port file's path for the given service_name. 72 extern string GetSocketPortFilePath(const string& service_name); 73 74 // returns true if the specified driver is running. 75 bool IsDriverRunning(const string& service_name, int retry_count); 76 77 // creates and returns VtsDriverSocketClient of the given service_name. 78 extern VtsDriverSocketClient* GetDriverSocketClient(const string& service_name); 79 80 } // namespace vts 81 } // namespace android 82 83 #endif // __VTS_FUZZER_TCP_CLIENT_H_ 84