Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Adb putty enhancement - support for multi-devices #38

@yumeyao

Description

@yumeyao

The original adb putty doesn't support for multi-devices, because any string after ':' are recognized as port number by putty, so that even if "transport:" is specified, only "transport" is forwarded to adb_init().

So I changed adb.c a little to make it work.

here is the code snip used to replace original part in adb_init()

    /* send initial data to adb server */
#define ADB_SHELL_DEFAULT_STR "0012" "host:transport-usb"
#define ADB_SHELL_DEFAULT_STR_LEN (sizeof(ADB_SHELL_DEFAULT_STR)-1)
#define ADB_SHELL_SERIAL_PREFIX "host:transport:"
#define ADB_SHELL_SERIAL_PREFIX_LEN (sizeof(ADB_SHELL_SERIAL_PREFIX)-1)
    do {
        size_t len = strlen(host);
        if (len == 0) {
            sk_write(adb->s, ADB_SHELL_DEFAULT_STR, ADB_SHELL_DEFAULT_STR_LEN);
        } else {
#define ADB_SHELL_HOST_MAX_LEN (sizeof(sendbuf)-4-ADB_SHELL_SERIAL_PREFIX_LEN-1)
            if (len > ADB_SHELL_HOST_MAX_LEN)
                len = ADB_SHELL_HOST_MAX_LEN;
            sprintf(sendbuf,"%04x" ADB_SHELL_SERIAL_PREFIX, len+ADB_SHELL_SERIAL_PREFIX_LEN);
            /* memcpy used here because I don't want to use snprintf */
            memcpy(sendbuf+4+ADB_SHELL_SERIAL_PREFIX_LEN, host, len);
            sk_write(adb->s,sendbuf,len+4+ADB_SHELL_SERIAL_PREFIX_LEN);
        }
    } while (0);

_After applying with this patch, one can open adb shell over a specific device by inputing the device ID listed out by "adb devices" into the "Host Name" (Where you may want to change it to "Device ID" when adb is selected)._

_To open the default device (when only 1 device connected), just input a ':' into "Host Name"_

TODO List:

  1. Change "Host Name" to "Device ID" when adb mode is selected.
  2. Allow for blank "Host Name" field when adb mode is selected. (So that ':' is not needed any more)
  3. Add a button to list all devices when adb mode is selected. Adb can be moved to last one, and the button can be placed right after it.
  4. An adb Settings Page in 'Connection', to allow for connecting using other commands rather than "adb shell".

BTW,
I'm willing to accomplish those in TODO list by myself, so could you give me write access to this or simple instructions for how to commit here? I'm quite unfamiliar with github.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions