History log of /system/core/adb/sockets.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2b933918fcdbfb411502a9b12d77d6a1895855ce 13-Sep-2017 Josh Gao <jmgao@google.com> adb: add lock to remove_socket.

The comment that was previously here says that local_socket_list_lock
must be taken, but this function is exposed to external callers that
can't possibly take the lock.

Bug: http://b/65419665
Bug: 64709603 (presubmit balking at the line above)
Test: python test_device.py
Change-Id: I12d464933936b2a210a827ccf19ea201020d8d78
(cherry picked from commit 62c92f0c0529d8d1817afb4ff0c83151e4bb0ea0)
/system/core/adb/sockets.cpp
1bd8498fc89d14b98e64142e07ad0c35c3bbffed 17-Aug-2017 Josh Gao <jmgao@google.com> adb: allow selection of a specific transport.

Extend device selection to allow selecting a specific transport via
monotonically increasing identifier (visible in devices -l).

This is useful when using multiple devices (like hikey960...) that
have identical bogus serial numbers like 0123456789ABCDEF.

Bug: http://b/37043226
Bug: 65419665
Test: adb -t {1, 2, 9999999} {get-serialno, shell, features}
Change-Id: I55e5dc5a406a4eeee0012e39b52e8cd232e608a6
(cherry picked from commit b122b175555d80b1d13dc1d864126f531e224d84)
/system/core/adb/sockets.cpp
a019f781417ea2351ace55603fc0906051f165c6 17-Jun-2017 Josh Gao <jmgao@google.com> adb: increase the shell command length limit.

Relax the shell command length limits when talking to an adbd with the
shell protocol.

shell is pretty much the only service that takes an arbitrarily long
string, so this is somewhat safe.

Bug: http://b/37716055
Test: `adb shell $(python -c 'print "echo " + "f" * (32*1024)') | wc` on L and master
Change-Id: I0737fd2244530ef8080f300cd3a3549a1ab93465
/system/core/adb/sockets.cpp
2e821078e432711006a580df19e68db48bfa9fae 20-Apr-2017 Treehugger Robot <treehugger-gerrit@google.com> Merge "adb: fix two device offline problems."
b5e11415d9fdb929321c66889063dac50fb737af 11-Mar-2017 Yabin Cui <yabinc@google.com> adb: fix two device offline problems.

When device goes offline, user usually has to manually replug the
usb device. This patch tries to solve two offline situations, all
because when adb on host is killed, the adbd on device is not notified.

1. When adb server is killed while pushing a large file to device,
the device is still reading the unfinished large message. So the
device thinks of the CNXN message as part of the previous unfinished
message, so it doesn't reply and the device is in offline state.

The solution is to add a write_msg_lock in atransport struct. And it
kicks the transport only after sending a whole message. By kicking
all transports before exit, we ensure that we don't write part of
a message to any device. So next time we start adb server, the device
should be waiting for a new message.

2. When adb server is killed while pulling a large file from device,
the device is still trying to send the unfinished large message. So
adb on host usually reads data with EOVERFLOW error. This is because
adb on host is reading less than one packet sent from device.

The solution is to use buffered read on host. The max packet size
of bulk transactions in USB 3.0 is 1024 bytes. By preparing an at least
1024 bytes buffer when reading, EOVERFLOW no longer occurs. And teach
adb host to ignore wrong messages.

To be safe, this patch doesn't change any logic on device.

Bug: http://b/32952319
Test: run python -m unittest -q test_device.DeviceOfflineTest
Test: on linux/mac/windows with bullhead, ryu.
Change-Id: Ib149d30028a62a6f03857b8a95ab5a1d6e9b9c4e
/system/core/adb/sockets.cpp
d73be1b96beab812b86f8174e7fc928291f0cb44 14-Apr-2017 Steven Moreland <smoreland@google.com> libcutils: compile with BOARD_VNDK_VERSION current

- moved __android_log_is_debuggable to a new public header
(log_properties.h)
- vendor version of sched_policy uses ALOG* instead SLOG*

Test: (sanity) liblog-unit-tests
Test: (sanity) libcutils_test (noting b/b/32972117, two tests continue
to fail)
Test: system/core as a whole makes with BOARD_VNDK_VERSION := current
now with no problems.
Test: boots/works on internal marlin
Bug: 33241851

(cherry picked from commit 1f83aa424f537cf3f07e1d27dbbcc524818b5358)

Merged-In: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
Change-Id: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
/system/core/adb/sockets.cpp
22d2b3e1c2e1152ca9cf86c3eb42cd42e7448a31 27-Oct-2016 Josh Gao <jmgao@google.com> adb: add `adb reconnect offline` to reconnect offline devices.

Add a command to reconnect offline/unauthorized devices, mainly for use
with the inotify-monitoring of vendor key directories added by 2e671202.

Bug: http://b/29273531
Test: manually tested with a sailfish + copying vendor keys
Change-Id: If34cccee4ae553ada65d128b57d03cba8c0d7c46
/system/core/adb/sockets.cpp
97787a00e6aeb9aba2d744566cfd9de3d2f8c4f6 29-Mar-2016 Mark Salyzyn <salyzyn@google.com> adb: use __android_log_is_debuggable()

Test: compile and months of adb functionality use
Bug: 27566046
Bug: 31456426
Change-Id: I6568eea0eda8dc67dec2ba34cd4c3f56fb0ff0e9
/system/core/adb/sockets.cpp
06d61d4d96d28777f76578fb5d3c823168853166 06-Oct-2016 Josh Gao <jmgao@google.com> adb: rationalize types.

Use fixed length types for structs going over the wire, constify
arguments where possible, use char* instead of unsigned char* for
apacket data, and assorted other refactoring.

Bug: http://b/29273531
Test: python test_device.py with every combination of old/new adb and adbd
Change-Id: I0b6f818a32be5386985aa4519f542003cf427f9d
/system/core/adb/sockets.cpp
b1c4d90215087b292279c06216acd0264399cdf2 28-Sep-2016 Treehugger Robot <treehugger-gerrit@google.com> Merge "adb: fix host-side serial number parsing for IPv6."
ffdec180176094dac0fb902263370dea1deb138f 24-Sep-2016 Elliott Hughes <enh@google.com> Switch adb to <android-base/properties.h>.

Bug: http://b/23102347
Test: manual
Change-Id: Iffa66258c01f84f41b9af99ab5e768a0a2669106
/system/core/adb/sockets.cpp
73d55aaab23256f85941730444e82cbc41a63f8b 21-Sep-2016 David Pursell <dpursell@google.com> adb: fix host-side serial number parsing for IPv6.

When the adb client sends a command to the adb server targeting a
particular device serial, it looks something like this:
host-serial:<serial>:<command>

But if <serial> happens to be an IPv6 address (e.g. when `adb connect`
targets IPv6), the current parsing code doesn't handle the additional
colons properly. This CL fixes the host-serial parsing to handle this
case.

This only affects commands that explicitly name a device serial, e.g.:
adb -s <IPv6> shell
adb -s <IPv6> forward <port> <port>
Implicitly using a single attached device was unaffected by this bug.

Bug: http://b/30891386
Test: `adb -s [fe80::ba27:ebff:feb1:934%eth2]:5555 shell` works now,
and new unittests pass.
Change-Id: Iffe784e61432ae94eb96ed3c8477900a3e807329
/system/core/adb/sockets.cpp
7eaef8a494b1e8c6f015d8ca239865c6032facf3 06-Sep-2016 Pirama Arumuga Nainar <pirama@google.com> Use <condition_variable> and <mutex.h> from MinGW

New MinGW prebuilts update includes pthreads and C++11 threads support.
Use mutex.h and condition_variable provided by MinGW.

Test: Build AOSP with new MinGW prebuilts
Change-Id: Ia8f890f86652612df3fc2618c2bfbb450a5a2f52
/system/core/adb/sockets.cpp
ffc73a39fd813c8823ca0e4cdc52b79521ce84da 15-Jun-2016 Elliott Hughes <enh@google.com> Minor adb style fixes.

Change-Id: Ic4b45828dfdf88ef6c0fc468f66df3e62d2fbe51
/system/core/adb/sockets.cpp
53eb31d87cb84a4212f4850bf745646e1fb12814 18-May-2016 Josh Gao <jmgao@google.com> adb: use asocket's close function when closing.

close_all_sockets was assuming that all registered local sockets used
local_socket_close as their close function. However, this is not true
for JDWP sockets.

Bug: http://b/28347842
Change-Id: I40a1174845cd33f15f30ce70828a7081cd5a087e
/system/core/adb/sockets.cpp
9b587dec6d0a57c8fe1083c1c543fbeb163d65fa 18-May-2016 Josh Gao <jmgao@google.com> adb: switch the socket list mutex to a recursive_mutex.

sockets.cpp was branching on whether a socket close function was
local_socket_close in order to avoid a potential deadlock if the socket
list lock was held while closing a peer socket.

Bug: http://b/28347842
Change-Id: I5e56f17fa54275284787f0f1dc150d1960256ab3
/system/core/adb/sockets.cpp
52bd8526aaaf10511177fb42c55c26bc722b0833 18-May-2016 Josh Gao <jmgao@google.com> adb: clang-format sockets.cpp.

Bug: http://b/28347842
Change-Id: Ie3748b6c803d4e8056e9d7abd065a8b99d945a5b
/system/core/adb/sockets.cpp
b4cff495a1f93b6c92f4327cbfb9e564b28913d8 29-Mar-2016 Dan Austin <danielaustin@google.com> Address const issues in preparation for libcxx rebase.

Change-Id: I4eccc1b5a70da9dd325e1a7e10ab0a3fe588c03f
/system/core/adb/sockets.cpp
3f902aad5b427a8162bf860a758878b55b13e775 01-Mar-2016 David Pursell <dpursell@google.com> adb: relax serial matching rules.

Currently targeting a device by serial requires matching the serial
number exactly. This CL relaxes the matching rules for local transports
to ignore protocol prefixes and make the port optional:
[tcp:|udp:]<hostname>[:port]

The purpose of this is to allow a user to set ANDROID_SERIAL to
something like "tcp:100.100.100.100" and have it work for both fastboot
and adb (assuming the device comes up at 100.100.100.100 in both
modes).

This CL also adds some unit tests for the modified functions to make
sure they work as expected.

Bug: 27340240
Change-Id: I006e0c70c84331ab44d05d0a0f462d06592eb879
/system/core/adb/sockets.cpp
7e6683ce40ba79c94ccc1e3b984cd39e63651dd5 15-Jan-2016 Josh Gao <jmgao@google.com> Increase the maximum shell command length to 4096ish.

The actual maximum length will depend on the version of the shell
protocol being used, and any additional parameters being passed through
(e.g. TERM=xterm-256color). This should be able to be raised to 64K for
devices with commit 3d2904c (L-MR1 and above), but that'll require some
plumbing.

Bug: http://b/20467103
Change-Id: Idf0c46af5b18b854110aba58df13a53297d2475f
/system/core/adb/sockets.cpp
363af568b8491af1a4256b09b04cfa8a0606d8cc 08-Nov-2015 Spencer Low <CompareAndSwap@gmail.com> adb/base: minor compiler portability improvements

I've been using these changes to compile with Visual Studio.

- GetFileBasename(): __FILE__ uses \ with Visual Studio.

- adb_trace.cpp: Apparently VS needs an ampersand before the function name.

- "expr1 ? : expr2" is a GCC extension.

- <algorithm> contains std::min().

- seekdir can't always be #define'd because some headers have members
named seekdir.

- adb_utils.cpp: Not really a compiler issue, just a random fix:
0x7F/DEL is not printable.

Change-Id: I0dfb634f1ba4ccbc0d1b9f71b00e838fbebb3b41
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/sockets.cpp
8d28e191c5ba81b82e51e3fd120d03851e1d905f 07-Oct-2015 Elliott Hughes <enh@google.com> Fix adb -d/-e error reporting.

If -d/-e fail, get-serialno and friends will now report an error
and return a failure status code on exit.

Also fix the behavior of -d/-e with $ANDROID_SERIAL --- -d/-e
should override $ANDROID_SERIAL, not the other way round.

I'm deleting my own comment here about always returning "unknown"
for scripts. I can't find any evidence that there are scripts
relying on that, so I think my comment meant "I fear that there
are scripts doing so".

Bug: http://b/24403699
Change-Id: Ie13a751f1137abcfe0cc6c46a0630ba5e02db676
/system/core/adb/sockets.cpp
aed3c61c4437ebb05eadfb3bf85d6962c30b9935 23-Sep-2015 Yabin Cui <yabinc@google.com> Adb: use VLOG() to replace D() for verbose logging.

As there are too many D(), we can keep both VLOG() and D() now, and get
rid of D() gradually.

Change-Id: I2f1cb70bcab3e82c99fed939341d03f6b2216076
/system/core/adb/sockets.cpp
c1b1f6ff5de82b457923eea3f0bbad1ac2e459d7 16-Sep-2015 Yabin Cui <yabinc@google.com> Add unit tests for local socket.

Add has_write_error flag in asocket, so it will not wait on local_socket_closing_list
to write pending packets in local_socket_close(). Although it doesn't fix any problem,
it helps to make the code more stable.
Add a missing put_apacket() in error handling.
Add a check when adding local socket in local_socket_closing_list.

Bug: 23314034

Change-Id: I75b07ba8ee59b7f277fba2fb919db63065b291be
/system/core/adb/sockets.cpp
0955c66b226db7a7f34613f834f7b0a145fd407d 31-Aug-2015 David Pursell <dpursell@google.com> adb: implement shell protocol.

Adds functionality for handling stdin/stdout/stderr streams and exit
codes using the shell protocol.

This CL just contains implementation for adbd which will not yet be
enabled. Once we have the ability to query transport features from the
adb client, another CL will add the implementation for the client side
and update the feature list to turn this on.

Note: this CL must be submitted together with a minadbd CL to update
the service_to_fd() function signature.

Bug: http://b/23030641

Change-Id: Ibed55e9c1946d8a35190696163ff63e8fb880238
/system/core/adb/sockets.cpp
7a3f8d6691b3fbd8014a98de8455dbcfcc9629e4 03-Sep-2015 Yabin Cui <yabinc@google.com> adb: clean up debug tracing a little.

Always use LOG() for debug tracing.
Remove useless D_lock. I believe it is useless to lock just before and after fprintf.

I verified the log output both on host and on device. The output looks fine to me.

Change-Id: I96ccfe408ff56864361551afe9ad464d197ae104
/system/core/adb/sockets.cpp
fd28f327ee0e110208ef42ded829286643860394 28-Aug-2015 Yabin Cui <yabinc@google.com> adb: remove adisconnect in aremotesocket.

The function of remote_socket_disconnect() is to make sure
the local_sockets and remote_sockets are closed when the binded
transport is disconnected. However, as we call close_all_sockets()
in handle_offline(), we don't need remote_socket_disconnect() any more.

Change-Id: I575f632d9f8703149f34e0210eb698a56e2516a9
/system/core/adb/sockets.cpp
00674124213d6a9f0564632a5ad172cbd78caf24 26-Aug-2015 Yabin Cui <yabinc@google.com> adb: fix a data race in local_socket_event_func.

If s->peer->enqueue() failed, s may be freed. So we should use
saved_xxx instead of s->xxx before verifying the return value.

Change-Id: I6c072406dceb98e2d02798d0dcdc428fa99e66fb
/system/core/adb/sockets.cpp
3d2904cdf2371e26c0465184436bd063979a5d97 13-Jul-2015 Tamas Berghammer <tberghammer@google.com> Increase size of the the adb packets sent over the wire

The reason behing this change is to increase the adb push/pull speed
with reduceing the number of packets sent between the host and the
device because the communication is heavily bound by packet latency.

The change maintains two way compatibility in the communication
protocol with negotiating a packet size between the target and the
host with the CONNECT packets.

After this change the push/pull speeds improved significantly
(measured from Linux-x86_64 with 100MB of data):

| Old push | Old pull || New push | New pull |
-----------------------------------------------------------
Hammerhead | 4.6 MB/s | 3.9 MB/s || 13.1 MB/s | 16.5 MB/s |
-----------------------------------------------------------
Volantis | 6.0 MB/s | 6.2 MS/s || 25.9 MB/s | 29.0 MB/s |
-----------------------------------------------------------
Fugu | 6.0 MB/s | 5.1 MB/s || 27.9 MB/s | 33.2 MB/s |
-----------------------------------------------------------

Change-Id: Id9625de31266e43394289e325c7e7e473379c5d8
/system/core/adb/sockets.cpp
dcd78a15d0be143d48fc93af6a9fa5748dbf9790 19-May-2015 Dan Albert <danalbert@google.com> Make connection states a proper type.

Change-Id: I809f9b327c832b88dd63151bf7dcb012d88e81c4
/system/core/adb/sockets.cpp
3bd73c12c07dcefc965abeef535ac53c4754d682 05-May-2015 Elliott Hughes <enh@google.com> Give enum types CamelCase names for clarity.

Change-Id: I1c89f1cc155ee839f372fb14d972a288183b8bcd
/system/core/adb/sockets.cpp
e67f1f87d9b1188ec8617035db7006c37ee7b21e 01-May-2015 Elliott Hughes <enh@google.com> More adb buffer fixes.

This patch factors out a lot of the basic protocol code: sending OKAY,
sending FAIL, and sending a length-prefixed string.

ADB_TRACE has been non-optional for a long time, so let's just remove
the #ifs.

Also actually build the device tracker test tool (and remove its duplicate).

Bug: http://b/20666660
Change-Id: I6c7d59f18707bdc62ca69dea45547617f9f31fc6
/system/core/adb/sockets.cpp
0b8ecb32908f0ccde550dd510f4a562239085806 17-Apr-2015 Elliott Hughes <enh@google.com> Merge "Remove extern "C" barriers to using C++."
2d4121c0dcc93382bcd7ea6476f433d8254919dd 17-Apr-2015 Elliott Hughes <enh@google.com> Remove extern "C" barriers to using C++.

Change-Id: Ic046d6aa540738cb46b54531bc59ba3b47b0136d
/system/core/adb/sockets.cpp
7be29c819b4fb8bf9b1d4b69a4333f8765de0281 17-Apr-2015 Elliott Hughes <enh@google.com> Show $ADB_VENDOR_KEYS if authentication fails.

Incorrectly set $ADB_VENDOR_KEYS is the most likely cause of failed
adb connections. Make it easier to debug such problems by including
the value in use in the error message.

Bug: 20165551
Change-Id: I64c1d98ae6d3fb40eea9e1f0ddcfcf4f2d9d7318
/system/core/adb/sockets.cpp
3313426fad9eaaf53017cdbde889ebcec91358ec 19-Mar-2015 Dan Albert <danalbert@google.com> File header cleanup.

* sysdeps.h should always be included first.
* TRACE_TAG needs to be defined before anything is included.
* Some files were missing copyright headers.
* Save precious bytes on my SSD by removing useless whitespace.

Change-Id: I88980e6e00b5be1093806cf286740d9e4a033b94
/system/core/adb/sockets.cpp
bac3474a8256cb32a29e8d46f78cad95a5502692 26-Feb-2015 Dan Albert <danalbert@google.com> Move adb to C++.

I keep trying to clean things up and needing std::strings. Might as
well just do this now.

usb_linux_client.c is going to stay as C because GCC isn't smart
enough to deal with the designated initializers it uses (though for
some reason it is in C mode).

The Darwin files are staying as C because I don't have a way to test
that they build.

The Windows files are staying as C because while I can actually build
for them, it's slow and painful.

Change-Id: I75367d29205a9049d34460032b3bb36384f43941
/system/core/adb/sockets.cpp