Remove header dependencies on vsoc_lib
Bug: 144111429
Test: Run launch_cvd -vm_manager=qemu_cli
Change-Id: I7cc03d824c5f74792129351c3dde89dbdabde4d5
diff --git a/common/frontend/socket_vsock_proxy/main.cpp b/common/frontend/socket_vsock_proxy/main.cpp
index ac421a3..31cff0b 100644
--- a/common/frontend/socket_vsock_proxy/main.cpp
+++ b/common/frontend/socket_vsock_proxy/main.cpp
@@ -20,13 +20,103 @@
#include <gflags/gflags.h>
#include "common/libs/fs/shared_fd.h"
-#include "common/vsoc/lib/socket_forward_region_view.h"
#ifdef CUTTLEFISH_HOST
#include "host/libs/config/cuttlefish_config.h"
#endif
-using vsoc::socket_forward::Packet;
+struct Header {
+ std::uint32_t payload_length;
+ enum MessageType : std::uint32_t {
+ DATA = 0,
+ BEGIN,
+ END,
+ RECV_CLOSED, // indicate that this side's receive end is closed
+ RESTART,
+ };
+ MessageType message_type;
+};
+
+constexpr std::size_t kMaxPacketSize = 8192;
+constexpr std::size_t kMaxPayloadSize = kMaxPacketSize - sizeof(Header);
+
+struct Packet {
+ private:
+ Header header_;
+ using Payload = char[kMaxPayloadSize];
+ Payload payload_data_;
+
+ static constexpr Packet MakePacket(Header::MessageType type) {
+ Packet packet{};
+ packet.header_.message_type = type;
+ return packet;
+ }
+
+ public:
+ // port is only revelant on the host-side.
+ static Packet MakeBegin(std::uint16_t port);
+
+ static constexpr Packet MakeEnd() { return MakePacket(Header::END); }
+
+ static constexpr Packet MakeRecvClosed() {
+ return MakePacket(Header::RECV_CLOSED);
+ }
+
+ static constexpr Packet MakeRestart() { return MakePacket(Header::RESTART); }
+
+ // NOTE payload and payload_length must still be set.
+ static constexpr Packet MakeData() { return MakePacket(Header::DATA); }
+
+ bool empty() const { return IsData() && header_.payload_length == 0; }
+
+ void set_payload_length(std::uint32_t length) {
+ CHECK_LE(length, sizeof payload_data_);
+ header_.payload_length = length;
+ }
+
+ Payload& payload() { return payload_data_; }
+
+ const Payload& payload() const { return payload_data_; }
+
+ constexpr std::uint32_t payload_length() const {
+ return header_.payload_length;
+ }
+
+ constexpr bool IsBegin() const {
+ return header_.message_type == Header::BEGIN;
+ }
+
+ constexpr bool IsEnd() const { return header_.message_type == Header::END; }
+
+ constexpr bool IsData() const { return header_.message_type == Header::DATA; }
+
+ constexpr bool IsRecvClosed() const {
+ return header_.message_type == Header::RECV_CLOSED;
+ }
+
+ constexpr bool IsRestart() const {
+ return header_.message_type == Header::RESTART;
+ }
+
+ constexpr std::uint16_t port() const {
+ CHECK(IsBegin());
+ std::uint16_t port_number{};
+ CHECK_EQ(payload_length(), sizeof port_number);
+ std::memcpy(&port_number, payload(), sizeof port_number);
+ return port_number;
+ }
+
+ char* raw_data() { return reinterpret_cast<char*>(this); }
+
+ const char* raw_data() const { return reinterpret_cast<const char*>(this); }
+
+ constexpr size_t raw_data_length() const {
+ return payload_length() + sizeof header_;
+ }
+};
+
+static_assert(sizeof(Packet) == kMaxPacketSize, "");
+static_assert(std::is_pod<Packet>{}, "");
DEFINE_uint32(tcp_port, 0, "TCP port (server on host, client on guest)");
DEFINE_uint32(vsock_port, 0, "vsock port (client on host, server on guest");
diff --git a/host/commands/run_cvd/launch.cc b/host/commands/run_cvd/launch.cc
index dae835a..e4eb858 100644
--- a/host/commands/run_cvd/launch.cc
+++ b/host/commands/run_cvd/launch.cc
@@ -8,7 +8,6 @@
#include "common/libs/fs/shared_fd.h"
#include "common/libs/utils/files.h"
#include "common/libs/utils/size_utils.h"
-#include "common/vsoc/shm/screen_layout.h"
#include "host/commands/run_cvd/runner_defs.h"
#include "host/commands/run_cvd/pre_launch_initializers.h"
#include "host/libs/vm_manager/crosvm_manager.h"
diff --git a/host/commands/run_cvd/main.cc b/host/commands/run_cvd/main.cc
index a3c458f..a4ed8cc 100644
--- a/host/commands/run_cvd/main.cc
+++ b/host/commands/run_cvd/main.cc
@@ -46,8 +46,6 @@
#include "common/libs/utils/files.h"
#include "common/libs/utils/subprocess.h"
#include "common/libs/utils/size_utils.h"
-#include "common/vsoc/lib/vsoc_memory.h"
-#include "common/vsoc/shm/screen_layout.h"
#include "host/commands/run_cvd/launch.h"
#include "host/commands/run_cvd/runner_defs.h"
#include "host/commands/run_cvd/process_monitor.h"
diff --git a/host/frontend/vnc_server/screen_connector.cpp b/host/frontend/vnc_server/screen_connector.cpp
index ed05178..35cf22f 100644
--- a/host/frontend/vnc_server/screen_connector.cpp
+++ b/host/frontend/vnc_server/screen_connector.cpp
@@ -18,7 +18,9 @@
#include <atomic>
#include <condition_variable>
+#include <thread>
+#include <glog/logging.h>
#include <gflags/gflags.h>
#include "host/frontend/vnc_server/vnc_utils.h"
diff --git a/host/frontend/vnc_server/simulated_hw_composer.cpp b/host/frontend/vnc_server/simulated_hw_composer.cpp
index 7a94454..96702e8 100644
--- a/host/frontend/vnc_server/simulated_hw_composer.cpp
+++ b/host/frontend/vnc_server/simulated_hw_composer.cpp
@@ -20,7 +20,6 @@
#include "host/libs/config/cuttlefish_config.h"
using cvd::vnc::SimulatedHWComposer;
-using vsoc::screen::ScreenRegionView;
SimulatedHWComposer::SimulatedHWComposer(BlackBoard* bb)
:
diff --git a/host/frontend/vnc_server/virtual_inputs.cpp b/host/frontend/vnc_server/virtual_inputs.cpp
index 31c0328..fb91409 100644
--- a/host/frontend/vnc_server/virtual_inputs.cpp
+++ b/host/frontend/vnc_server/virtual_inputs.cpp
@@ -16,18 +16,19 @@
#include "host/frontend/vnc_server/virtual_inputs.h"
#include <gflags/gflags.h>
+#include <glog/logging.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include <cstdint>
#include <mutex>
+#include <thread>
#include "keysyms.h"
#include <common/libs/fs/shared_select.h>
#include <host/libs/config/cuttlefish_config.h>
using cvd::vnc::VirtualInputs;
-using vsoc::input_events::InputEventsRegionView;
DEFINE_int32(touch_fd, -1,
"A fd for a socket where to accept touch connections");
@@ -245,37 +246,6 @@
} // namespace
-class VSoCVirtualInputs : public VirtualInputs {
- public:
- VSoCVirtualInputs()
- : input_events_region_view_{
- vsoc::input_events::InputEventsRegionView::GetInstance(
- vsoc::GetDomain().c_str())} {
- if (!input_events_region_view_) {
- LOG(FATAL) << "Failed to open Input events region view";
- }
- }
-
- void GenerateKeyPressEvent(int code, bool down) override {
- if (keymapping_.count(code)) {
- input_events_region_view_->HandleKeyboardEvent(down, keymapping_[code]);
- } else {
- LOG(ERROR) << "Unknown keycode" << code;
- }
- }
-
- void PressPowerButton(bool down) override {
- input_events_region_view_->HandlePowerButtonEvent(down);
- }
-
- void HandlePointerEvent(bool touch_down, int x, int y) override {
- input_events_region_view_->HandleSingleTouchEvent(touch_down, x, y);
- }
-
- private:
- vsoc::input_events::InputEventsRegionView* input_events_region_view_{};
-};
-
class SocketVirtualInputs : public VirtualInputs {
public:
SocketVirtualInputs()
diff --git a/host/frontend/vnc_server/virtual_inputs.h b/host/frontend/vnc_server/virtual_inputs.h
index f92693b..7aca3eb 100644
--- a/host/frontend/vnc_server/virtual_inputs.h
+++ b/host/frontend/vnc_server/virtual_inputs.h
@@ -21,8 +21,6 @@
#include <map>
#include <mutex>
-#include "common/vsoc/lib/input_events_region_view.h"
-
namespace cvd {
namespace vnc {
diff --git a/host/frontend/vnc_server/vnc_client_connection.cpp b/host/frontend/vnc_server/vnc_client_connection.cpp
index a8faf47..b81bb88 100644
--- a/host/frontend/vnc_server/vnc_client_connection.cpp
+++ b/host/frontend/vnc_server/vnc_client_connection.cpp
@@ -42,7 +42,17 @@
using cvd::vnc::Stripe;
using cvd::vnc::StripePtrVec;
using cvd::vnc::VncClientConnection;
-using vsoc::screen::ScreenRegionView;
+
+struct ScreenRegionView {
+ using Pixel = uint32_t;
+ static constexpr int kSwiftShaderPadding = 4;
+ static constexpr int kRedShift = 0;
+ static constexpr int kGreenShift = 8;
+ static constexpr int kBlueShift = 16;
+ static constexpr int kRedBits = 8;
+ static constexpr int kGreenBits = 8;
+ static constexpr int kBlueBits = 8;
+};
DEFINE_bool(debug_client, false, "Turn on detailed logging for the client");
diff --git a/host/frontend/vnc_server/vnc_utils.h b/host/frontend/vnc_server/vnc_utils.h
index 0953c4e..db88131 100644
--- a/host/frontend/vnc_server/vnc_utils.h
+++ b/host/frontend/vnc_server/vnc_utils.h
@@ -23,7 +23,6 @@
#include "common/libs/utils/size_utils.h"
#include "common/libs/tcp_socket/tcp_socket.h"
-#include "common/vsoc/lib/screen_region_view.h"
#include "host/libs/config/cuttlefish_config.h"
namespace cvd {
@@ -65,7 +64,7 @@
};
inline constexpr int BytesPerPixel() {
- return sizeof(vsoc::screen::ScreenRegionView::Pixel);
+ return sizeof(uint32_t);
}
// The width of the screen regardless of orientation. Does not change.