adb: use adb's unique_fd instead of android::base.
Replace all usages of android::base::unique_fd with the unique_fd from
adb_unique_fd.h, which calls adb_close instead of close on Windows.
Most of these changes are no-ops, except for the ones to
create_service_thread, which was probably pretty broken on Windows.
Test: python test_device.py
Test: adb_test
Test: wine adb_test.exe
Change-Id: Ia4d03f9e2e7ddc88c97dc64172d721f93f3bf853
diff --git a/daemon/file_sync_service.cpp b/daemon/file_sync_service.cpp
index 7ae806a..8c39a20 100644
--- a/daemon/file_sync_service.cpp
+++ b/daemon/file_sync_service.cpp
@@ -527,7 +527,7 @@
return true;
}
-void file_sync_service(android::base::unique_fd fd) {
+void file_sync_service(unique_fd fd) {
std::vector<char> buffer(SYNC_DATA_MAX);
while (handle_sync_command(fd.get(), buffer)) {
diff --git a/daemon/file_sync_service.h b/daemon/file_sync_service.h
index 01081d2..f300e7b 100644
--- a/daemon/file_sync_service.h
+++ b/daemon/file_sync_service.h
@@ -1,5 +1,3 @@
-#pragma once
-
/*
* Copyright (C) 2018 The Android Open Source Project
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
-#include <android-base/unique_fd.h>
+#pragma once
-void file_sync_service(android::base::unique_fd fd);
+#include "adb_unique_fd.h"
+
+void file_sync_service(unique_fd fd);
diff --git a/daemon/framebuffer_service.cpp b/daemon/framebuffer_service.cpp
index 9a620ab..8d28c49 100644
--- a/daemon/framebuffer_service.cpp
+++ b/daemon/framebuffer_service.cpp
@@ -57,7 +57,7 @@
unsigned int alpha_length;
} __attribute__((packed));
-void framebuffer_service(android::base::unique_fd fd) {
+void framebuffer_service(unique_fd fd) {
struct fbinfo fbinfo;
unsigned int i, bsize;
char buf[640];
diff --git a/daemon/framebuffer_service.h b/daemon/framebuffer_service.h
index d99c6fe..264da59 100644
--- a/daemon/framebuffer_service.h
+++ b/daemon/framebuffer_service.h
@@ -14,11 +14,8 @@
* limitations under the License.
*/
-#ifndef _DAEMON_FRAMEBUFFER_SERVICE_H_
-#define _DAEMON_FRAMEBUFFER_SERVICE_H_
+#pragma once
-#include <android-base/unique_fd.h>
+#include "adb_unique_fd.h"
-void framebuffer_service(android::base::unique_fd fd);
-
-#endif // _DAEMON_FRAMEBUFFER_SERVICE_H_
+void framebuffer_service(unique_fd fd);
diff --git a/daemon/remount_service.cpp b/daemon/remount_service.cpp
index 1bb2fbb..76a1452 100644
--- a/daemon/remount_service.cpp
+++ b/daemon/remount_service.cpp
@@ -215,7 +215,7 @@
android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_cmd.c_str());
}
-void remount_service(android::base::unique_fd fd, const std::string& cmd) {
+void remount_service(unique_fd fd, const std::string& cmd) {
bool user_requested_reboot = cmd != "-R";
if (getuid() != 0) {
@@ -251,7 +251,7 @@
if (user_requested_reboot) {
if (!dedup.empty() || verity_enabled) {
if (verity_enabled) {
- set_verity_enabled_state_service(android::base::unique_fd(dup(fd.get())), false);
+ set_verity_enabled_state_service(unique_fd(dup(fd.get())), false);
}
reboot_for_remount(fd.get(), !dedup.empty());
return;
diff --git a/daemon/remount_service.h b/daemon/remount_service.h
index 45821ee..e4e2550 100644
--- a/daemon/remount_service.h
+++ b/daemon/remount_service.h
@@ -14,14 +14,11 @@
* limitations under the License.
*/
-#ifndef _REMOUNT_SERVICE_H_
-#define _REMOUNT_SERVICE_H_
+#pragma once
#include <string>
-#include <android-base/unique_fd.h>
+#include "adb_unique_fd.h"
bool make_block_device_writable(const std::string&);
-void remount_service(android::base::unique_fd, const std::string&);
-
-#endif
+void remount_service(unique_fd, const std::string&);
diff --git a/daemon/set_verity_enable_state_service.cpp b/daemon/set_verity_enable_state_service.cpp
index 0f804e9..8c98c2d 100644
--- a/daemon/set_verity_enable_state_service.cpp
+++ b/daemon/set_verity_enable_state_service.cpp
@@ -132,7 +132,7 @@
return true;
}
-void set_verity_enabled_state_service(android::base::unique_fd fd, bool enable) {
+void set_verity_enabled_state_service(unique_fd fd, bool enable) {
bool any_changed = false;
// Figure out if we're using VB1.0 or VB2.0 (aka AVB) - by
diff --git a/daemon/set_verity_enable_state_service.h b/daemon/set_verity_enable_state_service.h
index 9f84f35..c1413c8 100644
--- a/daemon/set_verity_enable_state_service.h
+++ b/daemon/set_verity_enable_state_service.h
@@ -14,11 +14,8 @@
* limitations under the License.
*/
-#ifndef _DAEMON_SET_VERITY_ENABLED_STATE_SERVICE_H_
-#define _DAEMON_SET_VERITY_ENABLED_STATE_SERVICE_H_
+#pragma once
-#include <android-base/unique_fd.h>
+#include "adb_unique_fd.h"
-void set_verity_enabled_state_service(android::base::unique_fd fd, bool enable);
-
-#endif // _DAEMON_SET_VERITY_ENABLED_STATE_SERVICE_H_
+void set_verity_enabled_state_service(unique_fd fd, bool enable);