Keun Soo Yim | 14f2272 | 2016-06-29 09:49:38 -0700 | [diff] [blame] | 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 "specification_parser/SpecificationBuilder.h" |
| 23 | |
| 24 | namespace android { |
| 25 | namespace vts { |
| 26 | |
| 27 | class VtsDriverHalSocketServer { |
| 28 | public: |
| 29 | VtsDriverHalSocketServer(android::vts::SpecificationBuilder& spec_builder, |
| 30 | const char* lib_path) |
| 31 | : spec_builder_(spec_builder), |
| 32 | lib_path_(lib_path) {} |
| 33 | |
| 34 | // Starts to run a TCP server (foreground). |
| 35 | int Start(const string& socket_port_file); |
| 36 | |
| 37 | // Start a session to handle a new request. |
| 38 | bool StartSession(int sockfd); |
| 39 | |
| 40 | void Exit(); |
| 41 | int32_t LoadHal(const string& path, int target_class, |
| 42 | int target_type, float target_version, |
| 43 | const string& module_name); |
| 44 | int32_t Status(int32_t type); |
| 45 | const char* Call(const string& arg); |
| 46 | const char* GetFunctions(); |
| 47 | |
| 48 | protected: |
| 49 | bool Send(int sockfd, const string& message); |
| 50 | |
| 51 | private: |
| 52 | android::vts::SpecificationBuilder& spec_builder_; |
| 53 | const char* lib_path_; |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | extern void StartSocketServer(const string& socket_port_file, |
| 58 | android::vts::SpecificationBuilder& spec_builder, |
| 59 | const char* lib_path); |
| 60 | |
| 61 | } // namespace vts |
| 62 | } // namespace android |
| 63 | |
| 64 | #endif // __VTS_DRIVER_HAL_SOCKET_SERVER_ |
| 65 | |
| 66 | #endif // VTS_AGENT_DRIVER_COMM_BINDER |