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_AGENT_DRIVER_COMM_BINDER // socket 18 19 #ifndef __VTS_DRIVER_HAL_SOCKET_SERVER_ 20 #define __VTS_DRIVER_HAL_SOCKET_SERVER_ 21 22 #include <VtsDriverCommUtil.h> 23 24 #include "driver_manager/VtsHalDriverManager.h" 25 26 namespace android { 27 namespace vts { 28 29 class VtsDriverHalSocketServer : public VtsDriverCommUtil { 30 public: 31 VtsDriverHalSocketServer(VtsHalDriverManager* driver_manager, 32 const char* lib_path) 33 : VtsDriverCommUtil(), 34 driver_manager_(driver_manager), 35 lib_path_(lib_path) {} 36 37 // Start a session to handle a new request. 38 bool ProcessOneCommand(); 39 40 protected: 41 void Exit(); 42 43 // Load a Hal driver with the given info (package, version etc.), 44 // returns the loaded hal driver id if scuccess, -1 otherwise. 45 int32_t LoadHal(const string& path, int target_class, int target_type, 46 float target_version, const string& target_package, 47 const string& target_component_name, 48 const string& hw_binder_service_name, 49 const string& module_name); 50 string ReadSpecification(const string& name, int target_class, 51 int target_type, float target_version, 52 const string& target_package); 53 string Call(const string& arg); 54 string GetAttribute(const string& arg); 55 string ListFunctions() const; 56 57 private: 58 android::vts::VtsHalDriverManager* driver_manager_; 59 const char* lib_path_; 60 }; 61 62 extern int StartSocketServer(const string& socket_port_file, 63 VtsHalDriverManager* driver_manager, 64 const char* lib_path); 65 66 } // namespace vts 67 } // namespace android 68 69 #endif // __VTS_DRIVER_HAL_SOCKET_SERVER_ 70 71 #endif // VTS_AGENT_DRIVER_COMM_BINDER 72