Android-cuttlefish cvd tool
Classes | Macros | Functions | Variables
commandline.cpp File Reference
#include "sysdeps.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include "client/host_services.h"
#include <sys/ioctl.h>
#include <termios.h>
#include "adb.h"
#include "adb_auth.h"
#include "adb_client.h"
#include "adb_host.pb.h"
#include "adb_install.h"
#include "adb_io.h"
#include "adb_unique_fd.h"
#include "adb_utils.h"
#include "app_processes.pb.h"
#include "bugreport.h"
#include "client/file_sync_client.h"
#include "commandline.h"
#include "incremental_server.h"
#include "services.h"
#include "shell_protocol.h"
#include "socket_spec.h"
#include "sysdeps/chrono.h"
Include dependency graph for commandline.cpp:

Classes

struct  StdinReadArgs
 
class  AdbServerStateStreamsCallback
 

Macros

#define TRACE_TAG   ADB
 
#define SIDELOAD_HOST_BLOCK_SIZE   (CHUNK_SIZE)
 

Functions

static std::string product_file (const std::string &file)
 
static void help ()
 
static void stdin_raw_init ()
 
static void stdin_raw_restore ()
 
int read_and_dump_protocol (borrowed_fd fd, StandardStreamsCallbackInterface *callback)
 
int read_and_dump (borrowed_fd fd, bool use_shell_protocol, StandardStreamsCallbackInterface *callback)
 
static void stdinout_raw_prologue (int inFd, int outFd, int &old_stdin_mode, int &old_stdout_mode)
 
static void stdinout_raw_epilogue (int inFd, int outFd, int old_stdin_mode, int old_stdout_mode)
 
bool copy_to_file (int inFd, int outFd)
 
static void send_window_size_change (int fd, std::unique_ptr< ShellProtocol > &shell)
 
static void stdin_read_thread_loop (void *x)
 
static std::string ShellServiceString (bool use_shell_protocol, const std::string &type_arg, const std::string &command)
 
static int RemoteShell (bool use_shell_protocol, const std::string &type_arg, char escape_char, bool empty_command, const std::string &service_string)
 
static int adb_shell (int argc, const char **argv)
 
static int adb_abb (int argc, const char **argv)
 
static int adb_shell_noinput (int argc, const char **argv)
 
static int adb_sideload_legacy (const char *filename, int in_fd, int size)
 
static int adb_sideload_install (const char *filename, bool rescue_mode)
 
static int adb_wipe_devices ()
 
static bool wait_for_device (const char *service, std::optional< std::chrono::milliseconds > timeout=std::nullopt)
 
static bool adb_root (const char *command)
 
int send_shell_command (const std::string &command, bool disable_shell_protocol, StandardStreamsCallbackInterface *callback)
 
static int logcat (int argc, const char **argv)
 
static void write_zeros (int bytes, borrowed_fd fd)
 
static int backup (int argc, const char **argv)
 
static int restore (int argc, const char **argv)
 
static CompressionType parse_compression_type (const std::string &str, bool allow_numbers)
 
static void parse_push_pull_args (const char **arg, int narg, std::vector< const char * > *srcs, const char **dst, bool *copy_attrs, bool *sync, bool *quiet, CompressionType *compression, bool *dry_run)
 
static int adb_connect_command (const std::string &command, TransportId *transport, StandardStreamsCallbackInterface *callback)
 
static int adb_connect_command (const std::string &command, TransportId *transport=nullptr)
 
static int adb_connect_command_bidirectional (const std::string &command)
 
const std::optional< FeatureSet > & adb_get_feature_set_or_die (void)
 
static int process_remount_or_verity_service (const int argc, const char **argv)
 
static int adb_query_command (const std::string &command)
 
static bool _is_valid_ack_reply_fd (const int ack_reply_fd)
 
static bool _is_valid_os_fd (int fd)
 
bool forward_dest_is_featured (const std::string &dest, std::string *error)
 
int adb_commandline (int argc, const char **argv)
 

Variables

DefaultStandardStreamsCallback DEFAULT_STANDARD_STREAMS_CALLBACK (nullptr, nullptr)
 
static constexpr int kDefaultServerPort = 5037
 
static termios g_saved_terminal_state
 

Macro Definition Documentation

◆ SIDELOAD_HOST_BLOCK_SIZE

#define SIDELOAD_HOST_BLOCK_SIZE   (CHUNK_SIZE)

◆ TRACE_TAG

#define TRACE_TAG   ADB

Function Documentation

◆ _is_valid_ack_reply_fd()

static bool _is_valid_ack_reply_fd ( const int  ack_reply_fd)
static

◆ _is_valid_os_fd()

static bool _is_valid_os_fd ( int  fd)
static

◆ adb_abb()

static int adb_abb ( int  argc,
const char **  argv 
)
static

◆ adb_commandline()

int adb_commandline ( int  argc,
const char **  argv 
)

◆ adb_connect_command() [1/2]

static int adb_connect_command ( const std::string &  command,
TransportId transport,
StandardStreamsCallbackInterface callback 
)
static

◆ adb_connect_command() [2/2]

static int adb_connect_command ( const std::string &  command,
TransportId transport = nullptr 
)
static

◆ adb_connect_command_bidirectional()

static int adb_connect_command_bidirectional ( const std::string &  command)
static

◆ adb_get_feature_set_or_die()

const std::optional< FeatureSet > & adb_get_feature_set_or_die ( void  )

◆ adb_query_command()

static int adb_query_command ( const std::string &  command)
static

◆ adb_root()

static bool adb_root ( const char *  command)
static

◆ adb_shell()

static int adb_shell ( int  argc,
const char **  argv 
)
static

◆ adb_shell_noinput()

static int adb_shell_noinput ( int  argc,
const char **  argv 
)
static

◆ adb_sideload_install()

static int adb_sideload_install ( const char *  filename,
bool  rescue_mode 
)
static

◆ adb_sideload_legacy()

static int adb_sideload_legacy ( const char *  filename,
int  in_fd,
int  size 
)
static

◆ adb_wipe_devices()

static int adb_wipe_devices ( )
static

◆ backup()

static int backup ( int  argc,
const char **  argv 
)
static

◆ copy_to_file()

bool copy_to_file ( int  inFd,
int  outFd 
)

◆ forward_dest_is_featured()

bool forward_dest_is_featured ( const std::string &  dest,
std::string *  error 
)

◆ help()

static void help ( )
static

◆ logcat()

static int logcat ( int  argc,
const char **  argv 
)
static

◆ parse_compression_type()

static CompressionType parse_compression_type ( const std::string &  str,
bool  allow_numbers 
)
static

◆ parse_push_pull_args()

static void parse_push_pull_args ( const char **  arg,
int  narg,
std::vector< const char * > *  srcs,
const char **  dst,
bool *  copy_attrs,
bool *  sync,
bool *  quiet,
CompressionType compression,
bool *  dry_run 
)
static

◆ process_remount_or_verity_service()

static int process_remount_or_verity_service ( const int  argc,
const char **  argv 
)
static

◆ product_file()

static std::string product_file ( const std::string &  file)
static

◆ read_and_dump()

int read_and_dump ( borrowed_fd  fd,
bool  use_shell_protocol,
StandardStreamsCallbackInterface callback 
)

◆ read_and_dump_protocol()

int read_and_dump_protocol ( borrowed_fd  fd,
StandardStreamsCallbackInterface callback 
)

◆ RemoteShell()

static int RemoteShell ( bool  use_shell_protocol,
const std::string &  type_arg,
char  escape_char,
bool  empty_command,
const std::string &  service_string 
)
static

◆ restore()

static int restore ( int  argc,
const char **  argv 
)
static

◆ send_shell_command()

int send_shell_command ( const std::string &  command,
bool  disable_shell_protocol,
StandardStreamsCallbackInterface callback 
)

◆ send_window_size_change()

static void send_window_size_change ( int  fd,
std::unique_ptr< ShellProtocol > &  shell 
)
static

◆ ShellServiceString()

static std::string ShellServiceString ( bool  use_shell_protocol,
const std::string &  type_arg,
const std::string &  command 
)
static

◆ stdin_raw_init()

static void stdin_raw_init ( )
static

◆ stdin_raw_restore()

static void stdin_raw_restore ( )
static

◆ stdin_read_thread_loop()

static void stdin_read_thread_loop ( void *  x)
static

◆ stdinout_raw_epilogue()

static void stdinout_raw_epilogue ( int  inFd,
int  outFd,
int  old_stdin_mode,
int  old_stdout_mode 
)
static

◆ stdinout_raw_prologue()

static void stdinout_raw_prologue ( int  inFd,
int  outFd,
int &  old_stdin_mode,
int &  old_stdout_mode 
)
static

◆ wait_for_device()

static bool wait_for_device ( const char *  service,
std::optional< std::chrono::milliseconds >  timeout = std::nullopt 
)
static

◆ write_zeros()

static void write_zeros ( int  bytes,
borrowed_fd  fd 
)
static

Variable Documentation

◆ DEFAULT_STANDARD_STREAMS_CALLBACK

DefaultStandardStreamsCallback DEFAULT_STANDARD_STREAMS_CALLBACK(nullptr, nullptr) ( nullptr  ,
nullptr   
)

◆ g_saved_terminal_state

termios g_saved_terminal_state
static

◆ kDefaultServerPort

constexpr int kDefaultServerPort = 5037
staticconstexpr