Android-cuttlefish cvd tool
client.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 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#pragma once
18
19#include <optional>
20#include <string>
21
23
27#include "cuttlefish/host/commands/cvd/legacy/cvd_server.pb.h"
29
30namespace cuttlefish {
31
39class CvdClient {
40 public:
42 const std::string& server_socket_path = ServerSocketPath());
43
45
46 Result<void> StopCvdServer(bool clear);
47
49
50 private:
51 struct OverrideFd {
52 std::optional<SharedFD> stdin_override_fd;
53 std::optional<SharedFD> stdout_override_fd;
54 std::optional<SharedFD> stderr_override_fd;
55 };
56
57 Result<void> SetServer(const SharedFD& server);
58 Result<cvd::Response> SendRequest(const cvd::Request& request,
59 const OverrideFd& new_control_fds = {},
60 std::optional<SharedFD> extra_fd = {});
61 Result<void> CheckStatus(const cvd::Status& status, const std::string& rpc);
62
63 std::optional<UnixMessageSocket> server_;
66};
67
68} // end of namespace cuttlefish
Definition: expected.h:86
Definition: client.h:39
Result< void > ConnectToServer()
Definition: client.cpp:36
Result< void > CheckStatus(const cvd::Status &status, const std::string &rpc)
Definition: client.cpp:185
Result< void > RestartServerMatchClient()
Definition: client.cpp:108
Result< void > SetServer(const SharedFD &server)
Definition: client.cpp:136
Result< cvd::Response > SendRequest(const cvd::Request &request, const OverrideFd &new_control_fds={}, std::optional< SharedFD > extra_fd={})
Definition: client.cpp:145
Result< void > StopCvdServer(bool clear)
Definition: client.cpp:56
CvdClient(android::base::LogSeverity verbosity, const std::string &server_socket_path=ServerSocketPath())
Definition: client.cpp:195
std::optional< UnixMessageSocket > server_
Definition: client.h:63
android::base::LogSeverity verbosity_
Definition: client.h:65
std::string server_socket_path_
Definition: client.h:64
Definition: shared_fd.h:129
static void Status(const std::string &message)
Definition: fastboot.cpp:205
int status()
Definition: health.cpp:42
LogSeverity
Definition: logging.h:87
Definition: alloc_utils.cpp:23
std::string ServerSocketPath()
Definition: server_constants.cpp:26
Definition: client.h:51
std::optional< SharedFD > stderr_override_fd
Definition: client.h:54
std::optional< SharedFD > stdout_override_fd
Definition: client.h:53
std::optional< SharedFD > stdin_override_fd
Definition: client.h:52