Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b708d162 authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Show transfer progress in adb sync/pull/push.

Change-Id: If5439877d060f9bab29cf84be996071cf680c2d4
parent bb51fbc4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -213,12 +213,13 @@ LOCAL_STATIC_LIBRARIES_windows := AdbWinApi
LOCAL_REQUIRED_MODULES_windows := AdbWinApi AdbWinUsbApi

LOCAL_SRC_FILES := \
    adb_client.cpp \
    client/main.cpp \
    console.cpp \
    commandline.cpp \
    adb_client.cpp \
    services.cpp \
    file_sync_client.cpp \
    line_printer.cpp \
    services.cpp \
    shell_service_protocol.cpp \

LOCAL_CFLAGS += \
+10 −15
Original line number Diff line number Diff line
@@ -101,12 +101,10 @@ static void help() {
        "                                 will disconnect from all connected TCP/IP devices.\n"
        "\n"
        "device commands:\n"
        "  adb push [-p] <local> <remote>\n"
        "  adb push <local> <remote>\n"
        "                               - copy file/dir to device\n"
        "                                 ('-p' to display the transfer progress)\n"
        "  adb pull [-p] [-a] <remote> [<local>]\n"
        "  adb pull [-a] <remote> [<local>]\n"
        "                               - copy file/dir from device\n"
        "                                 ('-p' to display the transfer progress)\n"
        "                                 ('-a' means copy timestamp and mode)\n"
        "  adb sync [ <directory> ]     - copy host->device only if changed\n"
        "                                 (-l means list but don't copy)\n"
@@ -1065,15 +1063,14 @@ static std::string find_product_out_path(const std::string& hint) {
    return path;
}

static void parse_push_pull_args(const char **arg, int narg, char const **path1,
                                 char const **path2, bool* show_progress,
static void parse_push_pull_args(const char **arg, int narg,
                                 char const **path1, char const **path2,
                                 int *copy_attrs) {
    *show_progress = false;
    *copy_attrs = 0;

    while (narg > 0) {
        if (!strcmp(*arg, "-p")) {
            *show_progress = true;
            // Silently ignore for backwards compatibility.
        } else if (!strcmp(*arg, "-a")) {
            *copy_attrs = 1;
        } else {
@@ -1561,22 +1558,20 @@ int adb_commandline(int argc, const char **argv) {
        return do_sync_ls(argv[1]) ? 0 : 1;
    }
    else if (!strcmp(argv[0], "push")) {
        bool show_progress = false;
        int copy_attrs = 0;
        const char* lpath = NULL, *rpath = NULL;

        parse_push_pull_args(&argv[1], argc - 1, &lpath, &rpath, &show_progress, &copy_attrs);
        parse_push_pull_args(&argv[1], argc - 1, &lpath, &rpath, &copy_attrs);
        if (!lpath || !rpath || copy_attrs != 0) return usage();
        return do_sync_push(lpath, rpath, show_progress) ? 0 : 1;
        return do_sync_push(lpath, rpath) ? 0 : 1;
    }
    else if (!strcmp(argv[0], "pull")) {
        bool show_progress = false;
        int copy_attrs = 0;
        const char* rpath = NULL, *lpath = ".";

        parse_push_pull_args(&argv[1], argc - 1, &rpath, &lpath, &show_progress, &copy_attrs);
        parse_push_pull_args(&argv[1], argc - 1, &rpath, &lpath, &copy_attrs);
        if (!rpath) return usage();
        return do_sync_pull(rpath, lpath, show_progress, copy_attrs) ? 0 : 1;
        return do_sync_pull(rpath, lpath, copy_attrs) ? 0 : 1;
    }
    else if (!strcmp(argv[0], "install")) {
        if (argc < 2) return usage();
@@ -1768,7 +1763,7 @@ static int install_app(TransportType transport, const char* serial, int argc, co
    int result = -1;
    const char* apk_file = argv[last_apk];
    std::string apk_dest = android::base::StringPrintf(where, adb_basename(apk_file).c_str());
    if (!do_sync_push(apk_file, apk_dest.c_str(), false)) goto cleanup_apk;
    if (!do_sync_push(apk_file, apk_dest.c_str())) goto cleanup_apk;
    argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */
    result = pm_command(transport, serial, argc, argv);

+140 −123

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -64,9 +64,9 @@ union syncmsg {

void file_sync_service(int fd, void* cookie);
bool do_sync_ls(const char* path);
bool do_sync_push(const char* lpath, const char* rpath, bool show_progress);
bool do_sync_push(const char* lpath, const char* rpath);
bool do_sync_sync(const std::string& lpath, const std::string& rpath, bool list_only);
bool do_sync_pull(const char* rpath, const char* lpath, bool show_progress, int copy_attrs);
bool do_sync_pull(const char* rpath, const char* lpath, int copy_attrs);

#define SYNC_DATA_MAX (64*1024)

adb/line_printer.cpp

0 → 100644
+161 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading