Revert deleting vsoc
Bug: 144973127
Test: git diff 698c8df9e00602c8cd82bbcc872693509a169fe9
Change-Id: I19d15f093a69e18f6fafa00e4808620297d37df8
diff --git a/host/frontend/vnc_server/screen_connector.cpp b/host/frontend/vnc_server/screen_connector.cpp
index 35cf22f..53cb389 100644
--- a/host/frontend/vnc_server/screen_connector.cpp
+++ b/host/frontend/vnc_server/screen_connector.cpp
@@ -18,11 +18,11 @@
#include <atomic>
#include <condition_variable>
-#include <thread>
-#include <glog/logging.h>
#include <gflags/gflags.h>
+#include <common/vsoc/lib/screen_region_view.h>
+#include <host/libs/config/cuttlefish_config.h>
#include "host/frontend/vnc_server/vnc_utils.h"
DEFINE_int32(frame_server_fd, -1, "");
@@ -31,6 +31,23 @@
namespace vnc {
namespace {
+class VSoCScreenConnector : public ScreenConnector {
+ public:
+ int WaitForNewFrameSince(std::uint32_t* seq_num) override {
+ if (!screen_view_) return -1;
+ return screen_view_->WaitForNewFrameSince(seq_num);
+ }
+
+ void* GetBuffer(int buffer_idx) override {
+ if (!screen_view_) return nullptr;
+ return screen_view_->GetBuffer(buffer_idx);
+ }
+
+ private:
+ vsoc::screen::ScreenRegionView* screen_view_ =
+ vsoc::screen::ScreenRegionView::GetInstance(vsoc::GetDomain().c_str());
+};
+
// TODO(b/128852363): Substitute with one based on memory shared with the
// wayland mock
class SocketBasedScreenConnector : public ScreenConnector {
@@ -123,7 +140,12 @@
} // namespace
ScreenConnector* ScreenConnector::Get() {
- return new SocketBasedScreenConnector();
+ auto config = vsoc::CuttlefishConfig::Get();
+ if (config->enable_ivserver()) {
+ return new VSoCScreenConnector();
+ } else {
+ return new SocketBasedScreenConnector();
+ }
}
} // namespace vnc