minadbd: daemon_service_to_fd takes std::string_view.

The caller of daemon_service_to_fd() in core adb has switched to
std::string_view in [1]. The mismatch breaks the sideload service, as it
picks up the wrong daemon_service_to_fd() when serving sideload.

[1] https://android-review.googlesource.com/c/platform/system/core/+/850392

Bug: 122171762
Test: `adb sideload` on taimen.
Change-Id: Ie828400768523c35c5576e2c029e38fc0ad0aff9
This commit is contained in:
Tao Bao 2019-01-02 09:35:59 -08:00
parent fc0665c701
commit 5de19e2e02
2 changed files with 9 additions and 7 deletions

View file

@ -21,6 +21,8 @@ cc_defaults {
"-Werror",
],
cpp_std: "experimental",
include_dirs: [
"system/core/adb",
],

View file

@ -23,6 +23,7 @@
#include <functional>
#include <string>
#include <string_view>
#include <thread>
#include "adb.h"
@ -49,14 +50,13 @@ static void sideload_host_service(unique_fd sfd, const std::string& args) {
exit(result == 0 ? 0 : 1);
}
unique_fd daemon_service_to_fd(const char* name, atransport* /* transport */) {
if (!strncmp(name, "sideload:", 9)) {
// this exit status causes recovery to print a special error
// message saying to use a newer adb (that supports
// sideload-host).
unique_fd daemon_service_to_fd(std::string_view name, atransport* /* transport */) {
if (name.starts_with("sideload:")) {
// This exit status causes recovery to print a special error message saying to use a newer adb
// (that supports sideload-host).
exit(3);
} else if (!strncmp(name, "sideload-host:", 14)) {
std::string arg(name + 14);
} else if (name.starts_with("sideload-host:")) {
std::string arg(name.substr(strlen("sideload-host:")));
return create_service_thread("sideload-host",
std::bind(sideload_host_service, std::placeholders::_1, arg));
}