Adapted vnc server for cuttlefish
Test: build
Change-Id: I18ff2023c70089d4bd77150ee3752f4ebbf92e68
diff --git a/guest/frontend/vnc_server/Android.mk b/guest/frontend/vnc_server/Android.mk
index 587986a..b4cf9c7 100644
--- a/guest/frontend/vnc_server/Android.mk
+++ b/guest/frontend/vnc_server/Android.mk
@@ -28,14 +28,10 @@
endif
LOCAL_C_INCLUDES := \
- device/google/gce/sensors \
- device/google/gce/include \
+ device/google/cuttlefish_common \
external/libjpeg-turbo \
external/jsoncpp/include
-include device/google/gce/libs/base/libbase.mk
-LOCAL_C_INCLUDES += $(GCE_LIBBASE_INCLUDE_DIR)
-
LOCAL_MODULE := vnc_server
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_TAGS := optional
@@ -52,38 +48,27 @@
vnc_server.cpp \
LOCAL_CFLAGS := \
- $(GCE_VERSION_CFLAGS) \
+ $(VSOC_VERSION_CFLAGS) \
-std=gnu++11 \
-Wall -Werror \
-Wno-error-unused -Wno-error=unused-parameter \
- -Wno-attributes \
- -DGCE_32_BIT_GRAPHICS
+ -Wno-attributes
-ifeq (0, $(shell test $(PLATFORM_SDK_VERSION) -ge 18; echo $$?))
LOCAL_CFLAGS += -Wno-error=implicit-exception-spec-mismatch
-endif
-LOCAL_SHARED_LIBRARIES := $(LIBJPEG_TURBO_NAME)
-LOCAL_STATIC_LIBRARIES := libcutils liblog
-LOCAL_CLANG := true
+LOCAL_SHARED_LIBRARIES := \
+ $(LIBJPEG_TURBO_NAME) \
+ libbase \
+ liblog \
+ libutils \
+ libcutils \
+ libcuttlefish_auto_resources \
+ libcuttlefish_fs \
+ libvsoc \
+ libvsocframebuffer
-ifeq (0, $(shell test $(PLATFORM_SDK_VERSION) -le 22; echo $$?)) #lmp-mr1 and down
- LOCAL_STATIC_LIBRARIES += \
- libgceframebuffer_cxx \
- libgcemetadata_cxx \
- libjsoncpp_cxx \
- libgcecutils_cxx \
-
- include external/libcxx/libcxx.mk
-else
- LOCAL_STATIC_LIBRARIES += \
- libgcemetadata \
- libjsoncpp \
-
- LOCAL_SHARED_LIBRARIES += \
- libgceframebuffer \
- libgcecutils \
-
-endif
+LOCAL_STATIC_LIBRARIES := \
+ liblog \
+ libjsoncpp
include $(BUILD_EXECUTABLE)
diff --git a/guest/frontend/vnc_server/VirtualInputDevice.cpp b/guest/frontend/vnc_server/VirtualInputDevice.cpp
index badeb07..c757532 100644
--- a/guest/frontend/vnc_server/VirtualInputDevice.cpp
+++ b/guest/frontend/vnc_server/VirtualInputDevice.cpp
@@ -41,7 +41,7 @@
// VirtualButton Support
//////////////////////////
-namespace avd {
+namespace cvd {
uint32_t VirtualButton::Senabled_events_[] = {EV_KEY};
VirtualButton::VirtualButton(const char* name, uint32_t input_keycode)
@@ -425,4 +425,4 @@
return true;
}
-} // namespace avd
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/VirtualInputDevice.h b/guest/frontend/vnc_server/VirtualInputDevice.h
index 02605a2..d25f45c 100644
--- a/guest/frontend/vnc_server/VirtualInputDevice.h
+++ b/guest/frontend/vnc_server/VirtualInputDevice.h
@@ -1,3 +1,4 @@
+#pragma once
/*
* Copyright (C) 2014 The Android Open Source Project
*
@@ -14,13 +15,10 @@
* limitations under the License.
*/
-#ifndef VIRTUAL_INPUT_DEVICE_H_
-#define VIRTUAL_INPUT_DEVICE_H_
-
#include <linux/uinput.h>
#include <map>
-namespace avd {
+namespace cvd {
// Base virtual input device class which contains a bunch of boiler-plate code.
class VirtualInputDevice {
public:
@@ -92,6 +90,4 @@
std::map<uint32_t, uint32_t> keymapping_;
};
-} // namespace avd
-#endif
-
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/blackboard.cpp b/guest/frontend/vnc_server/blackboard.cpp
index ce4db8d..b28e399 100644
--- a/guest/frontend/vnc_server/blackboard.cpp
+++ b/guest/frontend/vnc_server/blackboard.cpp
@@ -1,15 +1,31 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "blackboard.h"
#include "frame_buffer_watcher.h"
#include <utility>
#include <algorithm>
-#define LOG_TAG "GceVNCServer"
+#define LOG_TAG ""
#include <cutils/log.h>
-using avd::vnc::BlackBoard;
-using avd::vnc::Stripe;
+using cvd::vnc::BlackBoard;
+using cvd::vnc::Stripe;
-avd::vnc::SeqNumberVec avd::vnc::MakeSeqNumberVec() {
+cvd::vnc::SeqNumberVec cvd::vnc::MakeSeqNumberVec() {
return SeqNumberVec(FrameBufferWatcher::StripesPerFrame());
}
@@ -52,7 +68,7 @@
return true;
}
-avd::vnc::StripePtrVec BlackBoard::WaitForSenderWork(
+cvd::vnc::StripePtrVec BlackBoard::WaitForSenderWork(
const VncClientConnection* conn) {
std::unique_lock<std::mutex> guard(m_);
auto& state = GetStateForClient(conn);
@@ -116,7 +132,7 @@
}
void BlackBoard::set_frame_buffer_watcher(
- avd::vnc::FrameBufferWatcher* frame_buffer_watcher) {
+ cvd::vnc::FrameBufferWatcher* frame_buffer_watcher) {
std::lock_guard<std::mutex> guard(m_);
frame_buffer_watcher_ = frame_buffer_watcher;
}
diff --git a/guest/frontend/vnc_server/blackboard.h b/guest/frontend/vnc_server/blackboard.h
index 49a169f..dfd9257 100644
--- a/guest/frontend/vnc_server/blackboard.h
+++ b/guest/frontend/vnc_server/blackboard.h
@@ -1,5 +1,19 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_BLACKBOARD_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_BLACKBOARD_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "vnc_utils.h"
@@ -10,7 +24,7 @@
#include <condition_variable>
#include <memory>
-namespace avd {
+namespace cvd {
namespace vnc {
class VncClientConnection;
@@ -97,6 +111,4 @@
};
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/frame_buffer_watcher.cpp b/guest/frontend/vnc_server/frame_buffer_watcher.cpp
index c592765..5f68748 100644
--- a/guest/frontend/vnc_server/frame_buffer_watcher.cpp
+++ b/guest/frontend/vnc_server/frame_buffer_watcher.cpp
@@ -1,6 +1,22 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "vnc_utils.h"
#include "frame_buffer_watcher.h"
-#include <ThreadSafeQueue.hpp>
+#include <common/libs/thread_safe_queue/thread_safe_queue.h>
#include <algorithm>
#include <cstdint>
@@ -11,10 +27,10 @@
#include <thread>
#include <utility>
-#define LOG_TAG "GceVNCServer"
+#define LOG_TAG ""
#include <cutils/log.h>
-using avd::vnc::FrameBufferWatcher;
+using cvd::vnc::FrameBufferWatcher;
FrameBufferWatcher::FrameBufferWatcher(BlackBoard* bb)
: bb_{bb}, hwcomposer{bb_} {
@@ -45,7 +61,7 @@
return closed_;
}
-avd::vnc::Stripe FrameBufferWatcher::Rotated(Stripe stripe) {
+cvd::vnc::Stripe FrameBufferWatcher::Rotated(Stripe stripe) {
LOG_ALWAYS_FATAL_IF(stripe.orientation == ScreenOrientation::Landscape,
"Rotating a landscape stripe, this is a mistake");
auto w = stripe.width;
@@ -73,7 +89,7 @@
return Stripes(stripe.orientation)[stripe.index]->raw_data != stripe.raw_data;
}
-avd::vnc::StripePtrVec FrameBufferWatcher::StripesNewerThan(
+cvd::vnc::StripePtrVec FrameBufferWatcher::StripesNewerThan(
ScreenOrientation orientation, const SeqNumberVec& seq_numbers) const {
std::lock_guard<std::mutex> guard(stripes_lock_);
const auto& stripes = Stripes(orientation);
@@ -87,12 +103,12 @@
return new_stripes;
}
-avd::vnc::StripePtrVec& FrameBufferWatcher::Stripes(
+cvd::vnc::StripePtrVec& FrameBufferWatcher::Stripes(
ScreenOrientation orientation) {
return stripes_[static_cast<int>(orientation)];
}
-const avd::vnc::StripePtrVec& FrameBufferWatcher::Stripes(
+const cvd::vnc::StripePtrVec& FrameBufferWatcher::Stripes(
ScreenOrientation orientation) const {
return stripes_[static_cast<int>(orientation)];
}
diff --git a/guest/frontend/vnc_server/frame_buffer_watcher.h b/guest/frontend/vnc_server/frame_buffer_watcher.h
index 540f3db..b678b8f 100644
--- a/guest/frontend/vnc_server/frame_buffer_watcher.h
+++ b/guest/frontend/vnc_server/frame_buffer_watcher.h
@@ -1,5 +1,19 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_FRAME_BUFFER_WATCHER_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_FRAME_BUFFER_WATCHER_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "blackboard.h"
#include "jpeg_compressor.h"
@@ -11,7 +25,7 @@
#include <thread>
#include <utility>
-namespace avd {
+namespace cvd {
namespace vnc {
class FrameBufferWatcher {
public:
@@ -57,6 +71,4 @@
};
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/jpeg_compressor.cpp b/guest/frontend/vnc_server/jpeg_compressor.cpp
index 3129184..560f9d8 100644
--- a/guest/frontend/vnc_server/jpeg_compressor.cpp
+++ b/guest/frontend/vnc_server/jpeg_compressor.cpp
@@ -1,13 +1,29 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "jpeg_compressor.h"
#include "vnc_utils.h"
#include <stdio.h> // stdio.h must appear before jpeglib.h
#include <jpeglib.h>
-#define LOG_TAG "GceVNCServer"
+#define LOG_TAG ""
#include <cutils/log.h>
-using avd::vnc::JpegCompressor;
+using cvd::vnc::JpegCompressor;
namespace {
void InitCinfo(jpeg_compress_struct* cinfo, jpeg_error_mgr* err,
@@ -17,7 +33,7 @@
cinfo->image_width = width;
cinfo->image_height = height;
- cinfo->input_components = avd::vnc::BytesPerPixel();
+ cinfo->input_components = cvd::vnc::BytesPerPixel();
cinfo->in_color_space = JCS_EXT_RGBX;
jpeg_set_defaults(cinfo);
@@ -25,7 +41,7 @@
}
} // namespace
-avd::vnc::Message JpegCompressor::Compress(const Message& frame,
+cvd::vnc::Message JpegCompressor::Compress(const Message& frame,
int jpeg_quality, std::uint16_t x,
std::uint16_t y, std::uint16_t width,
std::uint16_t height,
diff --git a/guest/frontend/vnc_server/jpeg_compressor.h b/guest/frontend/vnc_server/jpeg_compressor.h
index db93267..d9c40ee 100644
--- a/guest/frontend/vnc_server/jpeg_compressor.h
+++ b/guest/frontend/vnc_server/jpeg_compressor.h
@@ -1,5 +1,19 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_JPEG_COMPRESSOR_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_JPEG_COMPRESSOR_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "vnc_utils.h"
@@ -7,7 +21,7 @@
#include <cstdlib>
#include <cstdint>
-namespace avd {
+namespace cvd {
namespace vnc {
// libjpeg-turbo with jpeg_mem_dest (using memory as a destination) is funky.
@@ -36,6 +50,4 @@
};
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/keysyms.h b/guest/frontend/vnc_server/keysyms.h
index 7973957..8da0117 100644
--- a/guest/frontend/vnc_server/keysyms.h
+++ b/guest/frontend/vnc_server/keysyms.h
@@ -1,7 +1,21 @@
-#ifndef DEVICE_GOOGLE_GCE_KEYSYMS_H_
-#define DEVICE_GOOGLE_GCE_KEYSYMS_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-namespace avd {
+namespace cvd {
namespace xk {
constexpr uint32_t BackSpace = 0xff08,
@@ -90,5 +104,4 @@
VNCMenu = 0xffed; // VNC seems to translate MENU to this
} // namespace xk
-} // namespace avd
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/main.cpp b/guest/frontend/vnc_server/main.cpp
index 2436a65..f03fdcb 100644
--- a/guest/frontend/vnc_server/main.cpp
+++ b/guest/frontend/vnc_server/main.cpp
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "vnc_server.h"
#include <signal.h>
@@ -20,6 +36,6 @@
memset(&new_action, 0, sizeof(new_action));
new_action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &new_action, &old_action);
- avd::vnc::VncServer vnc_server(kVncServerPort, HasAggressiveFlag(argc, argv));
+ cvd::vnc::VncServer vnc_server(kVncServerPort, HasAggressiveFlag(argc, argv));
vnc_server.MainLoop();
}
diff --git a/guest/frontend/vnc_server/simulated_hw_composer.cpp b/guest/frontend/vnc_server/simulated_hw_composer.cpp
index 84a87d2..473a6f9 100644
--- a/guest/frontend/vnc_server/simulated_hw_composer.cpp
+++ b/guest/frontend/vnc_server/simulated_hw_composer.cpp
@@ -1,17 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "simulated_hw_composer.h"
-using avd::vnc::SimulatedHWComposer;
+using cvd::vnc::SimulatedHWComposer;
SimulatedHWComposer::SimulatedHWComposer(BlackBoard* bb)
:
#ifdef FUZZ_TEST_VNC
engine_{std::random_device{}()},
#endif
- control_{GceFrameBufferControl::getInstance()},
+ control_{VSoCFrameBufferControl::getInstance()},
bb_{bb},
stripes_(kMaxQueueElements, &SimulatedHWComposer::EraseHalfOfElements) {
void* p{};
- GceFrameBuffer::OpenAndMapFrameBuffer(&p, &frame_buffer_fd_);
+ VSoCFrameBuffer::OpenAndMapFrameBuffer(&p, &frame_buffer_fd_);
frame_buffer_memory_ = static_cast<char*>(p);
stripe_maker_ = std::thread(&SimulatedHWComposer::MakeStripes, this);
}
@@ -19,11 +35,11 @@
SimulatedHWComposer::~SimulatedHWComposer() {
close();
stripe_maker_.join();
- GceFrameBuffer::UnmapAndCloseFrameBuffer(frame_buffer_memory_,
+ VSoCFrameBuffer::UnmapAndCloseFrameBuffer(frame_buffer_memory_,
frame_buffer_fd_);
}
-avd::vnc::Stripe SimulatedHWComposer::GetNewStripe() {
+cvd::vnc::Stripe SimulatedHWComposer::GetNewStripe() {
auto s = stripes_.Pop();
#ifdef FUZZ_TEST_VNC
if (random_(engine_)) {
diff --git a/guest/frontend/vnc_server/simulated_hw_composer.h b/guest/frontend/vnc_server/simulated_hw_composer.h
index 3b68548..c8a8320 100644
--- a/guest/frontend/vnc_server/simulated_hw_composer.h
+++ b/guest/frontend/vnc_server/simulated_hw_composer.h
@@ -1,11 +1,25 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_SIMULATED_HW_COMPOSER_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_SIMULATED_HW_COMPOSER_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "blackboard.h"
-#include <GceFrameBuffer.h>
-#include <GceFrameBufferControl.h>
-#include <ThreadSafeQueue.hpp>
+#include <guest/libs/legacy_framebuffer/vsoc_framebuffer.h>
+#include <guest/libs/legacy_framebuffer/vsoc_framebuffer_control.h>
+#include <common/libs/thread_safe_queue/thread_safe_queue.h>
#include <mutex>
#include <thread>
@@ -15,7 +29,7 @@
#include <random>
#endif
-namespace avd {
+namespace cvd {
namespace vnc {
class SimulatedHWComposer {
public:
@@ -44,7 +58,7 @@
constexpr static std::size_t kMaxQueueElements = 64;
bool closed_ GUARDED_BY(m_){};
std::mutex m_;
- GceFrameBufferControl& control_;
+ VSoCFrameBufferControl& control_;
BlackBoard* bb_{};
ThreadSafeQueue<Stripe> stripes_;
std::thread stripe_maker_;
@@ -52,6 +66,4 @@
int frame_buffer_fd_{};
};
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/tcp_socket.cpp b/guest/frontend/vnc_server/tcp_socket.cpp
index 2ccdcf9..c83559b 100644
--- a/guest/frontend/vnc_server/tcp_socket.cpp
+++ b/guest/frontend/vnc_server/tcp_socket.cpp
@@ -1,13 +1,29 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "tcp_socket.h"
#include <cerrno>
#include <cutils/sockets.h>
-#define LOG_TAG "GceVNCServer"
+#define LOG_TAG ""
#include <cutils/log.h>
-using avd::vnc::ClientSocket;
-using avd::vnc::ServerSocket;
-using avd::vnc::Message;
+using cvd::vnc::ClientSocket;
+using cvd::vnc::ServerSocket;
+using cvd::vnc::Message;
Message ClientSocket::Recv(size_t length) {
Message buf(length);
diff --git a/guest/frontend/vnc_server/tcp_socket.h b/guest/frontend/vnc_server/tcp_socket.h
index 701ea0e..c8c1b32 100644
--- a/guest/frontend/vnc_server/tcp_socket.h
+++ b/guest/frontend/vnc_server/tcp_socket.h
@@ -1,5 +1,19 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_TCPSOCKET_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_TCPSOCKET_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "vnc_utils.h"
@@ -9,7 +23,7 @@
#include <unistd.h>
-namespace avd {
+namespace cvd {
namespace vnc {
class ServerSocket;
@@ -82,6 +96,4 @@
};
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/virtual_inputs.cpp b/guest/frontend/vnc_server/virtual_inputs.cpp
index c946d57..ab4bb7a 100644
--- a/guest/frontend/vnc_server/virtual_inputs.cpp
+++ b/guest/frontend/vnc_server/virtual_inputs.cpp
@@ -1,7 +1,23 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "virtual_inputs.h"
#include <mutex>
-using avd::vnc::VirtualInputs;
+using cvd::vnc::VirtualInputs;
void VirtualInputs::GenerateKeyPressEvent(int code, bool down) {
std::lock_guard<std::mutex> guard(m_);
diff --git a/guest/frontend/vnc_server/virtual_inputs.h b/guest/frontend/vnc_server/virtual_inputs.h
index fba9ede..4b24d39 100644
--- a/guest/frontend/vnc_server/virtual_inputs.h
+++ b/guest/frontend/vnc_server/virtual_inputs.h
@@ -1,5 +1,19 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VIRTUAL_INPUTS_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VIRTUAL_INPUTS_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "VirtualInputDevice.h"
#include "vnc_utils.h"
@@ -9,7 +23,7 @@
#include <mutex>
-namespace avd {
+namespace cvd {
namespace vnc {
class VirtualInputs {
@@ -27,6 +41,4 @@
};
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/vnc_client_connection.cpp b/guest/frontend/vnc_server/vnc_client_connection.cpp
index b751cf6..f6b4669 100644
--- a/guest/frontend/vnc_server/vnc_client_connection.cpp
+++ b/guest/frontend/vnc_server/vnc_client_connection.cpp
@@ -1,12 +1,25 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "vnc_client_connection.h"
#include "vnc_utils.h"
#include "tcp_socket.h"
#include "keysyms.h"
-#include "InitialMetadataReader.h"
-#include <GceFrameBuffer.h>
-#include <gce_sensors_message.h>
-#include <sensors.h>
+#include <guest/libs/legacy_framebuffer/vsoc_framebuffer.h>
#include <netinet/in.h>
#include <sys/time.h>
@@ -25,13 +38,14 @@
#ifdef LOG_TAG
#undef LOG_TAG
#endif
-#define LOG_TAG "GceVNCServer"
+#define LOG_TAG ""
#include <cutils/log.h>
+#include <cutils/sockets.h>
-using avd::vnc::Message;
-using avd::vnc::VncClientConnection;
-using avd::vnc::Stripe;
-using avd::vnc::StripePtrVec;
+using cvd::vnc::Message;
+using cvd::vnc::VncClientConnection;
+using cvd::vnc::Stripe;
+using cvd::vnc::StripePtrVec;
namespace {
class BigEndianChecker {
@@ -104,7 +118,7 @@
}
std::string HostName() {
- return avd::InitialMetadataReader::getInstance()->GetInstanceHostname();
+ return "Cuttlefish";
}
std::uint16_t uint16_tAt(const void* p) {
@@ -129,21 +143,21 @@
}
std::uint32_t RedVal(std::uint32_t pixel) {
- return (pixel >> GceFrameBuffer::kRedShift) &
- ((0x1 << GceFrameBuffer::kRedBits) - 1);
+ return (pixel >> VSoCFrameBuffer::kRedShift) &
+ ((0x1 << VSoCFrameBuffer::kRedBits) - 1);
}
std::uint32_t BlueVal(std::uint32_t pixel) {
- return (pixel >> GceFrameBuffer::kBlueShift) &
- ((0x1 << GceFrameBuffer::kBlueBits) - 1);
+ return (pixel >> VSoCFrameBuffer::kBlueShift) &
+ ((0x1 << VSoCFrameBuffer::kBlueBits) - 1);
}
std::uint32_t GreenVal(std::uint32_t pixel) {
- return (pixel >> GceFrameBuffer::kGreenShift) &
- ((0x1 << GceFrameBuffer::kGreenBits) - 1);
+ return (pixel >> VSoCFrameBuffer::kGreenShift) &
+ ((0x1 << VSoCFrameBuffer::kGreenBits) - 1);
}
}
-namespace avd {
+namespace cvd {
namespace vnc {
bool operator==(const VncClientConnection::FrameBufferUpdateRequest& lhs,
const VncClientConnection::FrameBufferUpdateRequest& rhs) {
@@ -156,14 +170,12 @@
return !(lhs == rhs);
}
} // namespace vnc
-} // namespace avd // namespace
+} // namespace cvd // namespace
VncClientConnection::VncClientConnection(ClientSocket client,
VirtualInputs* virtual_inputs,
BlackBoard* bb, bool aggressive)
: client_{std::move(client)},
- sensor_event_hal_{avd::SharedFD::SocketSeqPacketClient(
- gce_sensors_message::kSensorsHALSocketName)},
virtual_inputs_{virtual_inputs},
bb_{bb} {
frame_buffer_request_handler_tid_ = std::thread(
@@ -297,7 +309,7 @@
void VncClientConnection::AppendRawStripe(Message* frame_buffer_update,
const Stripe& stripe) const {
- using Pixel = GceFrameBuffer::Pixel;
+ using Pixel = VSoCFrameBuffer::Pixel;
auto& fbu = *frame_buffer_update;
AppendRawStripeHeader(&fbu, stripe);
auto init_size = fbu.size();
@@ -492,40 +504,7 @@
}
void VncClientConnection::UpdateAccelerometer(float x, float y, float z) {
- // Discard the event if we don't have a connection to the HAL.
- if (!sensor_event_hal_->IsOpen()) {
- ALOGE("sensor event client not open");
- return;
- }
- timespec current_time{};
- clock_gettime(CLOCK_MONOTONIC, ¤t_time);
- // Construct the sensor message.
- gce_sensors_message message{};
- message.version = sizeof message;
- message.sensor = avd::sensors_constants::kAccelerometerHandle;
- message.type = SENSOR_TYPE_ACCELEROMETER;
- message.timestamp = current_time.tv_sec * static_cast<int64_t>(1000000000) +
- current_time.tv_nsec;
- message.data[0] = x;
- message.data[1] = y;
- message.data[2] = z;
-
- std::array<iovec, 1> msg_iov{};
- msg_iov[0].iov_base = &message;
- msg_iov[0].iov_len = sizeof(sensors_event_t);
-
- msghdr msg;
- msg.msg_name = nullptr;
- msg.msg_namelen = 0;
- msg.msg_iov = msg_iov.data();
- msg.msg_iovlen = msg_iov.size();
- msg.msg_control = nullptr;
- msg.msg_controllen = 0;
- msg.msg_flags = 0;
- if (sensor_event_hal_->SendMsg(&msg, 0) == -1) {
- ALOGE("%s: Could not send sensor data. (%s).", __FUNCTION__,
- sensor_event_hal_->StrError());
- }
+ // TODO(jemoreira): Implement when vsoc sensor hal is updated
}
VncClientConnection::Coordinates VncClientConnection::CoordinatesForOrientation(
@@ -587,13 +566,13 @@
return false;
}
switch (key) {
- case avd::xk::Right:
- case avd::xk::F12:
+ case cvd::xk::Right:
+ case cvd::xk::F12:
D("switching to portrait");
SetScreenOrientation(ScreenOrientation::Portrait);
break;
- case avd::xk::Left:
- case avd::xk::F11:
+ case cvd::xk::Left:
+ case cvd::xk::F11:
D("switching to landscape");
SetScreenOrientation(ScreenOrientation::Landscape);
break;
@@ -612,18 +591,18 @@
auto key = uint32_tAt(&msg[3]);
bool key_down = msg[0];
switch (key) {
- case avd::xk::ControlLeft:
- case avd::xk::ControlRight:
+ case cvd::xk::ControlLeft:
+ case cvd::xk::ControlRight:
control_key_down_ = key_down;
break;
- case avd::xk::MetaLeft:
- case avd::xk::MetaRight:
+ case cvd::xk::MetaLeft:
+ case cvd::xk::MetaRight:
meta_key_down_ = key_down;
break;
- case avd::xk::F5:
- key = avd::xk::Menu;
+ case cvd::xk::F5:
+ key = cvd::xk::Menu;
break;
- case avd::xk::F7:
+ case cvd::xk::F7:
virtual_inputs_->PressPowerButton(key_down);
return;
default:
diff --git a/guest/frontend/vnc_server/vnc_client_connection.h b/guest/frontend/vnc_server/vnc_client_connection.h
index 09f7c94..b2fe6e7 100644
--- a/guest/frontend/vnc_server/vnc_client_connection.h
+++ b/guest/frontend/vnc_server/vnc_client_connection.h
@@ -1,5 +1,19 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VNC_CLIENT_CONNECTION_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VNC_CLIENT_CONNECTION_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "blackboard.h"
#include "virtual_inputs.h"
@@ -7,7 +21,7 @@
#include "tcp_socket.h"
#include <android-base/thread_annotations.h>
-#include <SharedFD.h>
+#include <common/libs/fs/shared_fd.h>
#include <cstdint>
#include <memory>
@@ -15,7 +29,7 @@
#include <thread>
#include <vector>
-namespace avd {
+namespace cvd {
namespace vnc {
class VncClientConnection {
@@ -122,7 +136,6 @@
mutable std::mutex m_;
ClientSocket client_;
- avd::SharedFD sensor_event_hal_;
bool control_key_down_ = false;
bool meta_key_down_ = false;
VirtualInputs* virtual_inputs_{};
@@ -153,6 +166,4 @@
};
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/vnc_server.cpp b/guest/frontend/vnc_server/vnc_server.cpp
index 50d2a02..4b1ce89 100644
--- a/guest/frontend/vnc_server/vnc_server.cpp
+++ b/guest/frontend/vnc_server/vnc_server.cpp
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "blackboard.h"
#include "frame_buffer_watcher.h"
#include "jpeg_compressor.h"
@@ -7,7 +23,7 @@
#include "vnc_server.h"
#include "vnc_utils.h"
-using avd::vnc::VncServer;
+using cvd::vnc::VncServer;
VncServer::VncServer(int port, bool aggressive)
: server_(port), frame_buffer_watcher_{&bb_}, aggressive_{aggressive} {}
diff --git a/guest/frontend/vnc_server/vnc_server.h b/guest/frontend/vnc_server/vnc_server.h
index f80f692..f50947e 100644
--- a/guest/frontend/vnc_server/vnc_server.h
+++ b/guest/frontend/vnc_server/vnc_server.h
@@ -1,5 +1,19 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VNC_SERVER_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VNC_SERVER_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "blackboard.h"
#include "frame_buffer_watcher.h"
@@ -13,7 +27,7 @@
#include <string>
#include <utility>
-namespace avd {
+namespace cvd {
namespace vnc {
class VncServer {
@@ -38,6 +52,4 @@
};
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd
diff --git a/guest/frontend/vnc_server/vnc_utils.h b/guest/frontend/vnc_server/vnc_utils.h
index 54cf159..5a996a9 100644
--- a/guest/frontend/vnc_server/vnc_utils.h
+++ b/guest/frontend/vnc_server/vnc_utils.h
@@ -1,7 +1,21 @@
-#ifndef DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VNC_UTILS_H_
-#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VNC_UTILS_H_
+#pragma once
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-#include <GceFrameBuffer.h>
+#include <guest/libs/legacy_framebuffer/vsoc_framebuffer.h>
#include <vector>
#include <array>
@@ -9,13 +23,13 @@
#include <cstdint>
#undef D
-#ifdef GCE_VNC_DEBUG
+#ifdef VSOC_VNC_DEBUG
#define D(...) ALOGD(__VA_ARGS__)
#else
#define D(...) ((void)0)
#endif
-namespace avd {
+namespace cvd {
namespace vnc {
// TODO(haining) when the hwcomposer gives a sequence number type, use that
@@ -59,17 +73,17 @@
};
inline constexpr int BytesPerPixel() {
- return sizeof(GceFrameBuffer::Pixel);
+ return sizeof(VSoCFrameBuffer::Pixel);
}
// The width of the screen regardless of orientation. Does not change.
inline int ActualScreenWidth() {
- return GceFrameBuffer::getInstance().x_res();
+ return VSoCFrameBuffer::getInstance().x_res();
}
// The height of the screen regardless of orientation. Does not change.
inline int ActualScreenHeight() {
- return GceFrameBuffer::getInstance().y_res();
+ return VSoCFrameBuffer::getInstance().y_res();
}
inline int ScreenSizeInBytes() {
@@ -77,6 +91,4 @@
}
} // namespace vnc
-} // namespace avd
-
-#endif
+} // namespace cvd