More adb buffer fixes.
This patch factors out a lot of the basic protocol code: sending OKAY,
sending FAIL, and sending a length-prefixed string.
ADB_TRACE has been non-optional for a long time, so let's just remove
the #ifs.
Also actually build the device tracker test tool (and remove its duplicate).
Bug: http://b/20666660
Change-Id: I6c7d59f18707bdc62ca69dea45547617f9f31fc6
(cherry picked from commit e67f1f87d9b1188ec8617035db7006c37ee7b21e)
diff --git a/adb/remount_service.cpp b/adb/remount_service.cpp
index 1eaee73..3fb2fcb 100644
--- a/adb/remount_service.cpp
+++ b/adb/remount_service.cpp
@@ -92,7 +92,7 @@
if (remount(partition, ro)) {
char buf[200];
snprintf(buf, sizeof(buf), "remount of %s failed: %s\n", partition, strerror(errno));
- WriteStringFully(fd, buf);
+ WriteFdExactly(fd, buf);
return false;
}
return true;
@@ -102,7 +102,7 @@
char prop_buf[PROPERTY_VALUE_MAX];
if (getuid() != 0) {
- WriteStringFully(fd, "Not running as root. Try \"adb root\" first.\n");
+ WriteFdExactly(fd, "Not running as root. Try \"adb root\" first.\n");
adb_close(fd);
return;
}
@@ -128,12 +128,11 @@
both ? " and " : "",
vendor_verified ? "vendor" : "",
both ? "s" : "");
- WriteStringFully(fd, buffer);
- snprintf(buffer, sizeof(buffer),
- "Use \"adb disable-verity\" to disable verity.\n"
- "If you do not, remount may succeed, however, you will still "
- "not be able to write to these volumes.\n");
- WriteStringFully(fd, buffer);
+ WriteFdExactly(fd, buffer);
+ WriteFdExactly(fd,
+ "Use \"adb disable-verity\" to disable verity.\n"
+ "If you do not, remount may succeed, however, you will still "
+ "not be able to write to these volumes.\n");
}
bool success = true;
@@ -141,7 +140,7 @@
success &= remount_partition(fd, "/vendor", &vendor_ro);
success &= remount_partition(fd, "/oem", &oem_ro);
- WriteStringFully(fd, success ? "remount succeeded\n" : "remount failed\n");
+ WriteFdExactly(fd, success ? "remount succeeded\n" : "remount failed\n");
adb_close(fd);
}