blob: 027357cf83e78eaae115e66965afdc455315942c [file] [log] [blame]
Keun Soo Yima4a6d532016-06-08 09:11:40 -07001/*
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
Keun Soo Yim6d8a16b2016-06-30 19:29:02 -070017#ifndef __VTS_AGENT_SOCKET_SERVER_FOR_DRIVER_H_
18#define __VTS_AGENT_SOCKET_SERVER_FOR_DRIVER_H_
Keun Soo Yima4a6d532016-06-08 09:11:40 -070019
Keun Soo Yim8f3ca752016-07-18 14:37:04 -070020#include <VtsDriverCommUtil.h>
21
Keun Soo Yima35b7272016-07-20 10:11:04 -070022#include "test/vts/proto/AndroidSystemControlMessage.pb.h"
23
Keun Soo Yima4a6d532016-06-08 09:11:40 -070024namespace android {
25namespace vts {
26
Keun Soo Yim8f3ca752016-07-18 14:37:04 -070027// Launches a server which accepts connection requests from drivers.
Keun Soo Yim1f340b92016-07-09 12:42:33 -070028extern int StartSocketServerForDriver(const string& callback_socket_name,
29 int runner_port);
Keun Soo Yima4a6d532016-06-08 09:11:40 -070030
Keun Soo Yim8f3ca752016-07-18 14:37:04 -070031// Class which contains actual methods to handle the callback requests.
32class SocketServerForDriver : public VtsDriverCommUtil {
33 public:
34 SocketServerForDriver(int sock, int runner_port)
35 : runner_port_(runner_port),
Keun Soo Yima35b7272016-07-20 10:11:04 -070036 VtsDriverCommUtil(sock) {}
Keun Soo Yim8f3ca752016-07-18 14:37:04 -070037
38 // Starts to process requests.
39 void Start();
40
41 // Sends a RPC call to the runner.
Keun Soo Yima35b7272016-07-20 10:11:04 -070042 void RpcCallToRunner(const AndroidSystemCallbackRequestMessage& message);
Keun Soo Yim8f3ca752016-07-18 14:37:04 -070043
44 private:
Keun Soo Yim8f3ca752016-07-18 14:37:04 -070045 // TCP port number of a runner's callback server.
46 int runner_port_;
47};
48
Keun Soo Yima4a6d532016-06-08 09:11:40 -070049} // namespace vts
50} // namespace android
51
Keun Soo Yim6d8a16b2016-06-30 19:29:02 -070052#endif // __VTS_AGENT_SOCKET_SERVER_FOR_DRIVER_H_