#include "chrome/test/chromedriver/chrome/adb_impl.h"
#include <string_view>
#include "base/environment.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/string_escape.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/current_thread.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/constants/version.h"
#include "chrome/test/chromedriver/net/adb_client_socket.h"
#include "net/base/net_errors.h"
namespace {
class ResponseBuffer : public base::RefCountedThreadSafe<ResponseBuffer> { … };
void ExecuteCommandOnIOThread(
const std::string& command, scoped_refptr<ResponseBuffer> response_buffer,
int port) { … }
void SendFileOnIOThread(const std::string& device_serial,
const std::string& filename,
const std::string& content,
scoped_refptr<ResponseBuffer> response_buffer,
int port) { … }
std::string GetSerialFromEnvironment() { … }
}
AdbImpl::AdbImpl(
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
int port)
: … { … }
AdbImpl::~AdbImpl() { … }
Status AdbImpl::GetDevices(std::vector<std::string>* devices) { … }
Status AdbImpl::ForwardPort(const std::string& device_serial,
const std::string& remote_abstract,
int* local_port) { … }
Status AdbImpl::KillForwardPort(const std::string& device_serial,
int port) { … }
Status AdbImpl::SetCommandLineFile(const std::string& device_serial,
const std::string& command_line_file,
const std::string& exec_name,
const std::string& args) { … }
Status AdbImpl::CheckAppInstalled(
const std::string& device_serial, const std::string& package) { … }
Status AdbImpl::ClearAppData(
const std::string& device_serial, const std::string& package) { … }
Status AdbImpl::SetDebugApp(
const std::string& device_serial, const std::string& package) { … }
Status AdbImpl::Launch(
const std::string& device_serial, const std::string& package,
const std::string& activity) { … }
Status AdbImpl::ForceStop(
const std::string& device_serial, const std::string& package) { … }
Status AdbImpl::GetPidByName(const std::string& device_serial,
const std::string& process_name,
int* pid) { … }
Status AdbImpl::GetSocketByPattern(const std::string& device_serial,
const std::string& grep_pattern,
std::string* socket_name) { … }
Status AdbImpl::ExecuteCommand(
const std::string& command, std::string* response) { … }
Status AdbImpl::ExecuteHostCommand(
const std::string& device_serial,
const std::string& host_command, std::string* response) { … }
Status AdbImpl::ExecuteHostShellCommand(
const std::string& device_serial,
const std::string& shell_command,
std::string* response) { … }