Ran clang-format over vnc_server code
Change-Id: I084bebc11168b8e52a7946eb58c937bd711e4812
diff --git a/host/frontend/vnc_server/VirtualInputDevice.h b/host/frontend/vnc_server/VirtualInputDevice.h
index 02605a2..2d1b928 100644
--- a/host/frontend/vnc_server/VirtualInputDevice.h
+++ b/host/frontend/vnc_server/VirtualInputDevice.h
@@ -23,20 +23,22 @@
namespace avd {
// Base virtual input device class which contains a bunch of boiler-plate code.
class VirtualInputDevice {
-public:
+ public:
VirtualInputDevice(const char* name, uint16_t bus_type, uint16_t vendor,
uint16_t product, uint16_t version);
virtual ~VirtualInputDevice();
-protected:
+ protected:
bool Init(uint32_t* events, int num_events, uint32_t* keys, int num_keys,
uint32_t* abs, int num_abs, uint32_t* props, int num_props);
bool EmitEvent(uint16_t type, uint16_t code, uint32_t value);
- struct uinput_user_dev* uinput_user_dev() { return &uinput_user_dev_; }
+ struct uinput_user_dev* uinput_user_dev() {
+ return &uinput_user_dev_;
+ }
-private:
+ private:
bool EnableEventBits(uint32_t* events, int num_elements);
bool EnableKeyBits(uint32_t* keys, int num_elements);
bool EnableAbsBits(uint32_t* abs, int num_elements);
@@ -50,13 +52,13 @@
// Virtual touch-pad.
class VirtualTouchPad : public VirtualInputDevice {
-public:
+ public:
VirtualTouchPad(const char* name, int x_res, int y_res);
virtual ~VirtualTouchPad() {}
void HandlePointerEvent(bool touch_down, int x, int y);
-private:
+ private:
static uint32_t Senabled_events_[];
static uint32_t Senabled_keys_[];
static uint32_t Senabled_abs_[];
@@ -68,30 +70,29 @@
// Virtual button.
class VirtualButton : public VirtualInputDevice {
-public:
+ public:
VirtualButton(const char* name, uint32_t input_keycode);
virtual ~VirtualButton() {}
void HandleButtonPressEvent(bool button_down);
-private:
+ private:
static uint32_t Senabled_events_[];
uint32_t input_keycode_;
};
// Virtual keyboard.
class VirtualKeyboard : public VirtualInputDevice {
-public:
+ public:
VirtualKeyboard(const char* name);
virtual ~VirtualKeyboard() {}
void GenerateKeyPressEvent(int code, bool down);
-private:
+ private:
static uint32_t Senabled_events_[];
std::map<uint32_t, uint32_t> keymapping_;
};
} // namespace avd
#endif
-
diff --git a/host/frontend/vnc_server/blackboard.cpp b/host/frontend/vnc_server/blackboard.cpp
index ce4db8d..5f1a92c 100644
--- a/host/frontend/vnc_server/blackboard.cpp
+++ b/host/frontend/vnc_server/blackboard.cpp
@@ -1,7 +1,7 @@
#include "blackboard.h"
-#include "frame_buffer_watcher.h"
-#include <utility>
#include <algorithm>
+#include <utility>
+#include "frame_buffer_watcher.h"
#define LOG_TAG "GceVNCServer"
#include <cutils/log.h>
diff --git a/host/frontend/vnc_server/blackboard.h b/host/frontend/vnc_server/blackboard.h
index 49a169f..15b0cb9 100644
--- a/host/frontend/vnc_server/blackboard.h
+++ b/host/frontend/vnc_server/blackboard.h
@@ -5,10 +5,10 @@
#include <android-base/thread_annotations.h>
-#include <unordered_map>
-#include <mutex>
#include <condition_variable>
#include <memory>
+#include <mutex>
+#include <unordered_map>
namespace avd {
namespace vnc {
@@ -37,9 +37,7 @@
: bb_{bb}, conn_{conn} {
bb->Register(conn);
}
- ~Registerer() {
- bb_->Unregister(conn_);
- }
+ ~Registerer() { bb_->Unregister(conn_); }
Registerer(const Registerer&) = delete;
Registerer& operator=(const Registerer&) = delete;
diff --git a/host/frontend/vnc_server/frame_buffer_watcher.cpp b/host/frontend/vnc_server/frame_buffer_watcher.cpp
index c592765..b8e66b2 100644
--- a/host/frontend/vnc_server/frame_buffer_watcher.cpp
+++ b/host/frontend/vnc_server/frame_buffer_watcher.cpp
@@ -1,6 +1,6 @@
-#include "vnc_utils.h"
#include "frame_buffer_watcher.h"
#include <ThreadSafeQueue.hpp>
+#include "vnc_utils.h"
#include <algorithm>
#include <cstdint>
diff --git a/host/frontend/vnc_server/frame_buffer_watcher.h b/host/frontend/vnc_server/frame_buffer_watcher.h
index 540f3db..9c23f7e 100644
--- a/host/frontend/vnc_server/frame_buffer_watcher.h
+++ b/host/frontend/vnc_server/frame_buffer_watcher.h
@@ -5,11 +5,11 @@
#include "jpeg_compressor.h"
#include "simulated_hw_composer.h"
-#include <vector>
#include <memory>
#include <mutex>
#include <thread>
#include <utility>
+#include <vector>
namespace avd {
namespace vnc {
diff --git a/host/frontend/vnc_server/jpeg_compressor.cpp b/host/frontend/vnc_server/jpeg_compressor.cpp
index 3129184..c897380 100644
--- a/host/frontend/vnc_server/jpeg_compressor.cpp
+++ b/host/frontend/vnc_server/jpeg_compressor.cpp
@@ -1,8 +1,8 @@
#include "jpeg_compressor.h"
#include "vnc_utils.h"
-#include <stdio.h> // stdio.h must appear before jpeglib.h
#include <jpeglib.h>
+#include <stdio.h> // stdio.h must appear before jpeglib.h
#define LOG_TAG "GceVNCServer"
#include <cutils/log.h>
diff --git a/host/frontend/vnc_server/jpeg_compressor.h b/host/frontend/vnc_server/jpeg_compressor.h
index db93267..067c0cc 100644
--- a/host/frontend/vnc_server/jpeg_compressor.h
+++ b/host/frontend/vnc_server/jpeg_compressor.h
@@ -3,9 +3,9 @@
#include "vnc_utils.h"
-#include <memory>
-#include <cstdlib>
#include <cstdint>
+#include <cstdlib>
+#include <memory>
namespace avd {
namespace vnc {
@@ -26,9 +26,7 @@
void UpdateBuffer(std::uint8_t* compression_buffer,
unsigned long compression_buffer_size);
struct Freer {
- void operator()(void* p) const {
- std::free(p);
- }
+ void operator()(void* p) const { std::free(p); }
};
std::unique_ptr<std::uint8_t, Freer> buffer_;
diff --git a/host/frontend/vnc_server/keysyms.h b/host/frontend/vnc_server/keysyms.h
index 7973957..29e5c8d 100644
--- a/host/frontend/vnc_server/keysyms.h
+++ b/host/frontend/vnc_server/keysyms.h
@@ -4,90 +4,34 @@
namespace avd {
namespace xk {
-constexpr uint32_t BackSpace = 0xff08,
- Tab = 0xff09,
- Return = 0xff0d,
- Enter = Return,
- Escape = 0xff1b,
- MultiKey = 0xff20,
- Insert = 0xff63,
- Delete = 0xffff,
- Pause = 0xff13,
- Home = 0xff50,
- End = 0xff57,
- PageUp = 0xff55,
- PageDown = 0xff56,
- Left = 0xff51,
- Up = 0xff52,
- Right = 0xff53,
- Down = 0xff54,
- F1 = 0xffbe,
- F2 = 0xffbf,
- F3 = 0xffc0,
- F4 = 0xffc1,
- F5 = 0xffc2,
- F6 = 0xffc3,
- F7 = 0xffc4,
- F8 = 0xffc5,
- F9 = 0xffc6,
- F10 = 0xffc7,
- F11 = 0xffc8,
- F12 = 0xffc9,
- F13 = 0xffca,
- F14 = 0xffcb,
- F15 = 0xffcc,
- F16 = 0xffcd,
- F17 = 0xffce,
- F18 = 0xffcf,
- F19 = 0xffd0,
- F20 = 0xffd1,
- F21 = 0xffd2,
- F22 = 0xffd3,
- F23 = 0xffd4,
- F24 = 0xffd5,
- ShiftLeft = 0xffe1,
- ShiftRight = 0xffe2,
- ControlLeft = 0xffe3,
- ControlRight = 0xffe4,
- MetaLeft = 0xffe7,
- MetaRight = 0xffe8,
- AltLeft = 0xffe9,
- AltRight = 0xffea,
- CapsLock = 0xffe5,
- NumLock = 0xff7f,
- ScrollLock = 0xff14,
- Keypad0 = 0xffb0,
- Keypad1 = 0xffb1,
- Keypad2 = 0xffb2,
- Keypad3 = 0xffb3,
- Keypad4 = 0xffb4,
- Keypad5 = 0xffb5,
- Keypad6 = 0xffb6,
- Keypad7 = 0xffb7,
- Keypad8 = 0xffb8,
- Keypad9 = 0xffb9,
- KeypadMultiply = 0xffaa,
- KeypadSubtract = 0xffad,
- KeypadAdd = 0xffab,
- KeypadDecimal = 0xffae,
- KeypadEnter = 0xff8d,
- KeypadDivide = 0xffaf,
- KeypadEqual = 0xffbd,
- PlusMinus = 0xb1,
- SysReq = 0xff15,
- LineFeed = 0xff0a,
- KeypadSeparator = 0xffac,
- Yen = 0xa5,
- Cancel = 0xff69,
- Undo = 0xff65,
- Redo = 0xff66,
- Find = 0xff68,
- Print = 0xff61,
- VolumeDown = 0x1008ff11,
- Mute = 0x1008ff12,
- VolumeUp = 0x1008ff13,
- Menu = 0xff67,
- VNCMenu = 0xffed; // VNC seems to translate MENU to this
+constexpr uint32_t BackSpace = 0xff08, Tab = 0xff09, Return = 0xff0d,
+ Enter = Return, Escape = 0xff1b, MultiKey = 0xff20,
+ Insert = 0xff63, Delete = 0xffff, Pause = 0xff13,
+ Home = 0xff50, End = 0xff57, PageUp = 0xff55,
+ PageDown = 0xff56, Left = 0xff51, Up = 0xff52,
+ Right = 0xff53, Down = 0xff54, F1 = 0xffbe, F2 = 0xffbf,
+ F3 = 0xffc0, F4 = 0xffc1, F5 = 0xffc2, F6 = 0xffc3,
+ F7 = 0xffc4, F8 = 0xffc5, F9 = 0xffc6, F10 = 0xffc7,
+ F11 = 0xffc8, F12 = 0xffc9, F13 = 0xffca, F14 = 0xffcb,
+ F15 = 0xffcc, F16 = 0xffcd, F17 = 0xffce, F18 = 0xffcf,
+ F19 = 0xffd0, F20 = 0xffd1, F21 = 0xffd2, F22 = 0xffd3,
+ F23 = 0xffd4, F24 = 0xffd5, ShiftLeft = 0xffe1,
+ ShiftRight = 0xffe2, ControlLeft = 0xffe3,
+ ControlRight = 0xffe4, MetaLeft = 0xffe7, MetaRight = 0xffe8,
+ AltLeft = 0xffe9, AltRight = 0xffea, CapsLock = 0xffe5,
+ NumLock = 0xff7f, ScrollLock = 0xff14, Keypad0 = 0xffb0,
+ Keypad1 = 0xffb1, Keypad2 = 0xffb2, Keypad3 = 0xffb3,
+ Keypad4 = 0xffb4, Keypad5 = 0xffb5, Keypad6 = 0xffb6,
+ Keypad7 = 0xffb7, Keypad8 = 0xffb8, Keypad9 = 0xffb9,
+ KeypadMultiply = 0xffaa, KeypadSubtract = 0xffad,
+ KeypadAdd = 0xffab, KeypadDecimal = 0xffae,
+ KeypadEnter = 0xff8d, KeypadDivide = 0xffaf,
+ KeypadEqual = 0xffbd, PlusMinus = 0xb1, SysReq = 0xff15,
+ LineFeed = 0xff0a, KeypadSeparator = 0xffac, Yen = 0xa5,
+ Cancel = 0xff69, Undo = 0xff65, Redo = 0xff66, Find = 0xff68,
+ Print = 0xff61, VolumeDown = 0x1008ff11, Mute = 0x1008ff12,
+ VolumeUp = 0x1008ff13, Menu = 0xff67,
+ VNCMenu = 0xffed; // VNC seems to translate MENU to this
} // namespace xk
} // namespace avd
diff --git a/host/frontend/vnc_server/main.cpp b/host/frontend/vnc_server/main.cpp
index 5b51e6d..4b06cb0 100644
--- a/host/frontend/vnc_server/main.cpp
+++ b/host/frontend/vnc_server/main.cpp
@@ -1,7 +1,7 @@
#include "vnc_server.h"
-#include <string>
#include <algorithm>
+#include <string>
namespace {
constexpr int kVncServerPort = 6444;
@@ -18,4 +18,3 @@
avd::vnc::VncServer vnc_server(kVncServerPort, HasAggressiveFlag(argc, argv));
vnc_server.MainLoop();
}
-
diff --git a/host/frontend/vnc_server/simulated_hw_composer.cpp b/host/frontend/vnc_server/simulated_hw_composer.cpp
index 84a87d2..b4f80ce 100644
--- a/host/frontend/vnc_server/simulated_hw_composer.cpp
+++ b/host/frontend/vnc_server/simulated_hw_composer.cpp
@@ -101,6 +101,4 @@
}
}
-int SimulatedHWComposer::NumberOfStripes() {
- return kNumStripes;
-}
+int SimulatedHWComposer::NumberOfStripes() { return kNumStripes; }
diff --git a/host/frontend/vnc_server/tcp_socket.cpp b/host/frontend/vnc_server/tcp_socket.cpp
index 2ccdcf9..b18ad15 100644
--- a/host/frontend/vnc_server/tcp_socket.cpp
+++ b/host/frontend/vnc_server/tcp_socket.cpp
@@ -6,8 +6,8 @@
#include <cutils/log.h>
using avd::vnc::ClientSocket;
-using avd::vnc::ServerSocket;
using avd::vnc::Message;
+using avd::vnc::ServerSocket;
Message ClientSocket::Recv(size_t length) {
Message buf(length);
diff --git a/host/frontend/vnc_server/tcp_socket.h b/host/frontend/vnc_server/tcp_socket.h
index 701ea0e..8cbd217 100644
--- a/host/frontend/vnc_server/tcp_socket.h
+++ b/host/frontend/vnc_server/tcp_socket.h
@@ -3,9 +3,9 @@
#include "vnc_utils.h"
-#include <mutex>
-#include <cstdint>
#include <cstddef>
+#include <cstdint>
+#include <mutex>
#include <unistd.h>
@@ -18,9 +18,7 @@
// Send is thread safe in this regard, Recv is not.
class ClientSocket {
public:
- ClientSocket(ClientSocket&& other) : fd_{other.fd_} {
- other.fd_ = -1;
- }
+ ClientSocket(ClientSocket&& other) : fd_{other.fd_} { other.fd_ = -1; }
ClientSocket& operator=(ClientSocket&& other) {
if (fd_ >= 0) {
@@ -49,9 +47,7 @@
return Send(data, N);
}
- bool closed() const {
- return other_side_closed_;
- }
+ bool closed() const { return other_side_closed_; }
private:
friend ServerSocket;
diff --git a/host/frontend/vnc_server/virtual_inputs.h b/host/frontend/vnc_server/virtual_inputs.h
index fba9ede..604dc87 100644
--- a/host/frontend/vnc_server/virtual_inputs.h
+++ b/host/frontend/vnc_server/virtual_inputs.h
@@ -4,8 +4,8 @@
#include "VirtualInputDevice.h"
#include "vnc_utils.h"
-#include <linux/input.h>
#include <android-base/thread_annotations.h>
+#include <linux/input.h>
#include <mutex>
diff --git a/host/frontend/vnc_server/vnc_client_connection.cpp b/host/frontend/vnc_server/vnc_client_connection.cpp
index b751cf6..83ba5be 100644
--- a/host/frontend/vnc_server/vnc_client_connection.cpp
+++ b/host/frontend/vnc_server/vnc_client_connection.cpp
@@ -1,12 +1,12 @@
#include "vnc_client_connection.h"
-#include "vnc_utils.h"
-#include "tcp_socket.h"
#include "keysyms.h"
+#include "tcp_socket.h"
+#include "vnc_utils.h"
-#include "InitialMetadataReader.h"
#include <GceFrameBuffer.h>
#include <gce_sensors_message.h>
#include <sensors.h>
+#include "InitialMetadataReader.h"
#include <netinet/in.h>
#include <sys/time.h>
@@ -29,9 +29,9 @@
#include <cutils/log.h>
using avd::vnc::Message;
-using avd::vnc::VncClientConnection;
using avd::vnc::Stripe;
using avd::vnc::StripePtrVec;
+using avd::vnc::VncClientConnection;
namespace {
class BigEndianChecker {
@@ -40,9 +40,7 @@
uint32_t u = 1;
is_big_endian_ = *reinterpret_cast<const char*>(&u) == 0;
}
- bool operator()() const {
- return is_big_endian_;
- }
+ bool operator()() const { return is_big_endian_; }
private:
bool is_big_endian_{};
@@ -142,7 +140,7 @@
return (pixel >> GceFrameBuffer::kGreenShift) &
((0x1 << GceFrameBuffer::kGreenBits) - 1);
}
-}
+} // namespace
namespace avd {
namespace vnc {
bool operator==(const VncClientConnection::FrameBufferUpdateRequest& lhs,
@@ -156,7 +154,7 @@
return !(lhs == rhs);
}
} // namespace vnc
-} // namespace avd // namespace
+} // namespace avd
VncClientConnection::VncClientConnection(ClientSocket client,
VirtualInputs* virtual_inputs,
diff --git a/host/frontend/vnc_server/vnc_client_connection.h b/host/frontend/vnc_server/vnc_client_connection.h
index 09f7c94..749ebc4 100644
--- a/host/frontend/vnc_server/vnc_client_connection.h
+++ b/host/frontend/vnc_server/vnc_client_connection.h
@@ -2,12 +2,12 @@
#define DEVICE_GOOGLE_GCE_GCE_UTILS_GCE_VNC_SERVER_VNC_CLIENT_CONNECTION_H_
#include "blackboard.h"
+#include "tcp_socket.h"
#include "virtual_inputs.h"
#include "vnc_utils.h"
-#include "tcp_socket.h"
-#include <android-base/thread_annotations.h>
#include <SharedFD.h>
+#include <android-base/thread_annotations.h>
#include <cstdint>
#include <memory>
diff --git a/host/frontend/vnc_server/vnc_server.cpp b/host/frontend/vnc_server/vnc_server.cpp
index 50d2a02..6852b69 100644
--- a/host/frontend/vnc_server/vnc_server.cpp
+++ b/host/frontend/vnc_server/vnc_server.cpp
@@ -1,10 +1,10 @@
+#include "vnc_server.h"
#include "blackboard.h"
#include "frame_buffer_watcher.h"
#include "jpeg_compressor.h"
#include "tcp_socket.h"
#include "virtual_inputs.h"
#include "vnc_client_connection.h"
-#include "vnc_server.h"
#include "vnc_utils.h"
using avd::vnc::VncServer;
diff --git a/host/frontend/vnc_server/vnc_server.h b/host/frontend/vnc_server/vnc_server.h
index f80f692..d88457a 100644
--- a/host/frontend/vnc_server/vnc_server.h
+++ b/host/frontend/vnc_server/vnc_server.h
@@ -9,8 +9,8 @@
#include "vnc_client_connection.h"
#include "vnc_utils.h"
-#include <thread>
#include <string>
+#include <thread>
#include <utility>
namespace avd {
diff --git a/host/frontend/vnc_server/vnc_utils.h b/host/frontend/vnc_server/vnc_utils.h
index 54cf159..2782bbd 100644
--- a/host/frontend/vnc_server/vnc_utils.h
+++ b/host/frontend/vnc_server/vnc_utils.h
@@ -3,10 +3,10 @@
#include <GceFrameBuffer.h>
-#include <vector>
#include <array>
-#include <utility>
#include <cstdint>
+#include <utility>
+#include <vector>
#undef D
#ifdef GCE_VNC_DEBUG
@@ -25,13 +25,9 @@
public:
StripeSeqNumber() = default;
explicit StripeSeqNumber(std::uint64_t t) : t_{t} {}
- bool operator<(const StripeSeqNumber& other) const {
- return t_ < other.t_;
- }
+ bool operator<(const StripeSeqNumber& other) const { return t_ < other.t_; }
- bool operator<=(const StripeSeqNumber& other) const {
- return t_ <= other.t_;
- }
+ bool operator<=(const StripeSeqNumber& other) const { return t_ <= other.t_; }
private:
std::uint64_t t_{};
@@ -58,14 +54,10 @@
ScreenOrientation orientation{};
};
-inline constexpr int BytesPerPixel() {
- return sizeof(GceFrameBuffer::Pixel);
-}
+inline constexpr int BytesPerPixel() { return sizeof(GceFrameBuffer::Pixel); }
// The width of the screen regardless of orientation. Does not change.
-inline int ActualScreenWidth() {
- return GceFrameBuffer::getInstance().x_res();
-}
+inline int ActualScreenWidth() { return GceFrameBuffer::getInstance().x_res(); }
// The height of the screen regardless of orientation. Does not change.
inline int ActualScreenHeight() {