summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot2018-08-02 17:21:43 -0500
committerGerrit Code Review2018-08-02 17:21:43 -0500
commit9c16700e36f17517ee25fca258f75bb0095323bb (patch)
treee301d8265db8b7e80558dfd89b8abc412db38136
parentd52b17ff0a559334dd6791e5a9533e4cfdac9446 (diff)
parent6fb946110312a47ea2b0f639d8b3e135a7481dca (diff)
downloadplatform-system-core-9c16700e36f17517ee25fca258f75bb0095323bb.tar.gz
platform-system-core-9c16700e36f17517ee25fca258f75bb0095323bb.tar.xz
platform-system-core-9c16700e36f17517ee25fca258f75bb0095323bb.zip
Merge "adbd: when rebooting, don't close socket before pausing."
-rw-r--r--adb/daemon/services.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/adb/daemon/services.cpp b/adb/daemon/services.cpp
index 1f59d6446..dfcc52d95 100644
--- a/adb/daemon/services.cpp
+++ b/adb/daemon/services.cpp
@@ -94,7 +94,7 @@ void restart_usb_service(unique_fd fd) {
94 WriteFdExactly(fd.get(), "restarting in USB mode\n"); 94 WriteFdExactly(fd.get(), "restarting in USB mode\n");
95} 95}
96 96
97bool reboot_service_impl(unique_fd fd, const std::string& arg) { 97void reboot_service(unique_fd fd, const std::string& arg) {
98 std::string reboot_arg = arg; 98 std::string reboot_arg = arg;
99 bool auto_reboot = false; 99 bool auto_reboot = false;
100 100
@@ -108,7 +108,7 @@ bool reboot_service_impl(unique_fd fd, const std::string& arg) {
108 if (reboot_arg == "sideload") { 108 if (reboot_arg == "sideload") {
109 if (getuid() != 0) { 109 if (getuid() != 0) {
110 WriteFdExactly(fd.get(), "'adb root' is required for 'adb reboot sideload'.\n"); 110 WriteFdExactly(fd.get(), "'adb root' is required for 'adb reboot sideload'.\n");
111 return false; 111 return;
112 } 112 }
113 113
114 const std::vector<std::string> options = {auto_reboot ? "--sideload_auto_reboot" 114 const std::vector<std::string> options = {auto_reboot ? "--sideload_auto_reboot"
@@ -116,7 +116,7 @@ bool reboot_service_impl(unique_fd fd, const std::string& arg) {
116 std::string err; 116 std::string err;
117 if (!write_bootloader_message(options, &err)) { 117 if (!write_bootloader_message(options, &err)) {
118 D("Failed to set bootloader message: %s", err.c_str()); 118 D("Failed to set bootloader message: %s", err.c_str());
119 return false; 119 return;
120 } 120 }
121 121
122 reboot_arg = "recovery"; 122 reboot_arg = "recovery";
@@ -128,16 +128,9 @@ bool reboot_service_impl(unique_fd fd, const std::string& arg) {
128 std::string reboot_string = android::base::StringPrintf("reboot,%s", reboot_arg.c_str()); 128 std::string reboot_string = android::base::StringPrintf("reboot,%s", reboot_arg.c_str());
129 if (!android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_string)) { 129 if (!android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_string)) {
130 WriteFdFmt(fd.get(), "reboot (%s) failed\n", reboot_string.c_str()); 130 WriteFdFmt(fd.get(), "reboot (%s) failed\n", reboot_string.c_str());
131 return false;
132 }
133
134 return true;
135}
136
137void reboot_service(unique_fd fd, const std::string& arg) {
138 if (!reboot_service_impl(std::move(fd), arg)) {
139 return; 131 return;
140 } 132 }
133
141 // Don't return early. Give the reboot command time to take effect 134 // Don't return early. Give the reboot command time to take effect
142 // to avoid messing up scripts which do "adb reboot && adb wait-for-device" 135 // to avoid messing up scripts which do "adb reboot && adb wait-for-device"
143 while (true) { 136 while (true) {