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 #include <resource_manager/VtsResourceManager.h> 24 25 #include "driver_manager/VtsHalDriverManager.h" 26 27 namespace android { 28 namespace vts { 29 30 class VtsDriverHalSocketServer : public VtsDriverCommUtil { 31 public: VtsDriverHalSocketServer(VtsHalDriverManager * driver_manager,VtsResourceManager * resource_manager,const char * lib_path)32 VtsDriverHalSocketServer(VtsHalDriverManager* driver_manager, 33 VtsResourceManager* resource_manager, 34 const char* lib_path) 35 : VtsDriverCommUtil(), 36 driver_manager_(driver_manager), 37 resource_manager_(resource_manager), 38 lib_path_(lib_path) {} 39 40 // Start a session to handle a new request. 41 bool ProcessOneCommand(); 42 43 protected: 44 void Exit(); 45 46 // Load a Hal driver with the given info (package, version etc.), 47 // returns the loaded hal driver id if scuccess, -1 otherwise. 48 // Args: 49 // target_version_major: int, hal major version, e.g. 1.0 -> 1. 50 // target_version_minor: int, hal minor version, e.g. 1.0 -> 0. 51 int32_t LoadHal(const string& path, int target_class, int target_type, 52 int target_version_major, int target_version_minor, 53 const string& target_package, 54 const string& target_component_name, 55 const string& hw_binder_service_name, 56 const string& module_name); 57 // Args: 58 // target_version_major: int, hal major version, e.g. 1.0 -> 1. 59 // target_version_minor: int, hal minor version, e.g. 1.0 -> 0. 60 string ReadSpecification(const string& name, int target_class, 61 int target_type, int target_version_major, 62 int target_version_minor, 63 const string& target_package); 64 string Call(const string& arg); 65 string GetAttribute(const string& arg); 66 string ListFunctions() const; 67 68 private: 69 android::vts::VtsHalDriverManager* driver_manager_; 70 android::vts::VtsResourceManager* resource_manager_; 71 const char* lib_path_; 72 }; 73 74 extern int StartSocketServer(const string& socket_port_file, 75 VtsHalDriverManager* driver_manager, 76 VtsResourceManager* resource_manager, 77 const char* lib_path); 78 79 } // namespace vts 80 } // namespace android 81 82 #endif // __VTS_DRIVER_HAL_SOCKET_SERVER_ 83 84 #endif // VTS_AGENT_DRIVER_COMM_BINDER 85