Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adb putty enhancement - support for multi-devices #38

Closed
yumeyao opened this Issue · 4 comments

3 participants

@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.

@stfnm

You can simply fork the repo here on github, commit and push your changes to your fork, and then open a pull request. This is the preferred github way. :)

Also you should check out the help section: http://help.github.com/fork-a-repo/

@yumeyao

Thanks. :)
Was working with git on gerrit (Android) way, not sensible about the github way.

The pull request of this basic patch is sent.

@yumeyao yumeyao closed this
@yumeyao yumeyao reopened this
@yumeyao

just reopen here for tracking todo list. :)

@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
e4a28fb
@FauxFaux
Owner

Looks okay to me, but I still have no way to test it. Merged, thanks.

@FauxFaux FauxFaux closed this
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
29c4bc6
@ztNFny ztNFny referenced this issue
Closed

v011 broke ADB #50

@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
f24b1a8
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
16e3088
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
ecef27a
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
e766aec
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
3963646
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
78306a9
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
94932c4
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
6c59619
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
b073d50
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
96bb165
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
dec082d
@FauxFaux FauxFaux referenced this issue from a commit
@yumeyao yumeyao GH-38: Fix adb-putty to support multi-devices
To connect a specific device, input device ID in host name
To connect the default device, input a colon(:) in host name
1926250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.