History log of /system/core/adb/transport_local.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
eec5e52ea24a9b86a9cee75c1e3207e9378b41c8 06-Oct-2016 Lingfeng Yang <lfy@google.com> Fix adb flakiness on reboot

bug: 31950237

There are two lists of active ADB transports (devices),
and with the emulator, they can go out of sync.

This CL more conservatively checks if there are no
transports in either list before commiting to
register a new transport for the emulator.

Change-Id: Id1201dc59c70825881dad80925c2e5bcc13dbd5e
(cherry picked from commit edaedfd5da41b2f5aa14b4d52742a6d8caa49214)
/system/core/adb/transport_local.cpp
9fe742684c9d154c6ca9b6e035d6d380e0cc4bdf 06-May-2016 Josh Gao <jmgao@google.com> adb: search for a maximum of 16 emulators.

Android Wear has unfortunately been using port 5601 for years, which
falls into the range of ports we were previously polling for Android
emulators. Reduce the maximum number of emulators we can support so
that 5601 no longer falls within our range.

Bug: http://b/26468076
Change-Id: I931809cfa412122f4781eebe0164facab12c95f0
/system/core/adb/transport_local.cpp
a28918cf30035edce887c7987a8b27033eeaa317 18-Apr-2016 Yabin Cui <yabinc@google.com> Fix kick_transport test.

Fix broken kick_transport test, and make it not access atransport
internal variables.

Bug: 25935458
Change-Id: I91b4d32a222b2f369f801bbe3903acac9c8ea4f7
(cherry picked from commit 7f27490e7f386401dc38287a67dcb8826e2260c5)
/system/core/adb/transport_local.cpp
251d46e68a279df2eb359e87a24b0e47fdfe4b78 09-Mar-2016 Prathmesh Prabhu <pprabhu@google.com> emulator: Use distinct serial names for simultaneous qemu pipes.

ADB local transport for the emulator based on qemu pipes uses a socket
transport. Before this CL, multiple connection requests accepted by the
qemu pipe device would result in ADB transport with the same serial.
The register function would fail as a result, and all subsequent
connections would fail.

Test:
while true; do adb kill-server; adb devices; done
Doesn't fail for > 10 minutes.

This CL replaces an earlier CL
(I0fdcf2694516151c5f8f8e1580648b940679c981) that was unsafe for real
devices.

BUG=27441661

Change-Id: I7d801b175f3bee10fc7e0ab1b12d5623984371b9
/system/core/adb/transport_local.cpp
8ac1b044afd879ff6e0bb969d6c25c89b1869ea8 29-Feb-2016 bohu <bohu@google.com> Emulator: fix adbd qemu pipe partial write

It does happens that the adb_write only writes to the
qemu pipe partially which throws host side's adb backend
into confusion and crashes.

This CL replaces adb_write with WriteFdExactly;
adb_read with ReadFdExactly.

(cherry picked from commit f66c5938be56c6fe607725c80129e677e196f03a)

Change-Id: I684f5df79b1e3f00b4b7a2452c2712a73c15973c
/system/core/adb/transport_local.cpp
d9db09c3158d3da6aad34fbb926888ceafab3a55 12-Feb-2016 Josh Gao <jmgao@google.com> adb: make adb_thread_func_t return void, add adb_thread_exit.

Windows restricts the return value of threads to 32-bits, even on 64-bit
platforms. Since we don't actually return meaningful values from thread,
resolve this inconsistency with POSIX by making adb's thread abstraction
only take void functions.

Change-Id: I5c23b4432314f13bf16d606fd5e6b6b7b6ef98b5
(cherry picked from commit b5fea14e13bb6e41b36f374c954dc55faeef4627)
/system/core/adb/transport_local.cpp
46b0b1c694bd873bd8130440d9ec1367dbe6da6e 08-Dec-2015 Erik Kline <ek@google.com> Merge "Switch from using sockaddr to sockaddr_storage."
7e16cc15b5e16ec35f4c9f0516a6cacf90326856 01-Dec-2015 Erik Kline <ek@google.com> Switch from using sockaddr to sockaddr_storage.

This is to ensure sufficient space is always available.

Change-Id: Ifa87b93ecdc90dcacbfb24446c872344da6703d3
/system/core/adb/transport_local.cpp
4f71319df011d796a60a43fc1bc68e16fbf7d321 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename of base/ to android-base/.

Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
/system/core/adb/transport_local.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/transport_local.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/transport_local.cpp
49ee7cf9a10f66ffa9a3490c69db5fa46e0a966b 29-Aug-2015 Siva Velusamy <vsiva@google.com> adb: set thread names (linux & mac)

Bug: 23423333
Change-Id: I0069f32ddbae2a10fb130064f721facf45b2cc09
/system/core/adb/transport_local.cpp
661327e8e40f95076e0e8abe86193da16b061bd8 11-Aug-2015 Yabin Cui <yabinc@google.com> Remove confusing variable HOST.

First, HOST is always 0 in adbd, which matches ADB_HOST=0.
Second, HOST is always 1 when adb_main is called, which matches ADB_HOST=1.
For adb client that doesn't call adb_main, it never touches local_init(),
init_transport_registration() and fdevent_loop(). So the changes in adb.cpp,
services.cpp and transport_local.cpp do nothing with it.
As a conclusion, I think we can remove HOST and use ADB_HOST instead.

Change-Id: Ide0e0eca7468b6c3c130f6b50974406280678b2e
/system/core/adb/transport_local.cpp
0e2c19465964d27f6da0e5d23c329b7892d41204 31-Jul-2015 Yabin Cui <yabinc@google.com> adb: poll for emulator connection.

Bug: 19974213
Change-Id: I336f3ad6f428277c54479e5b8c45d5343c64f472
/system/core/adb/transport_local.cpp
5200c6670f041550c23821fec8e8e49b30ef6d29 31-Jul-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: initial IPv6 support and improved Winsock error reporting

Call getaddrinfo() for connecting to IPv6 destinations.

Winsock APIs do not set errno. WSAGetLastError() returns Winsock errors
that are more numerous than BSD sockets, so it really doesn't make sense
to map those to BSD socket errors. Plus, even if we did that, the
Windows C Runtime (that mingw binaries use) has a strerror() that does
not recognize BSD socket error codes.

The solution is to wrap the various libcutils socket_* APIs with
sysdeps.h network_* APIs. For POSIX, the network_* APIs just call
strerror(). For Windows, they call SystemErrorCodeToString() (adapted
from Chromium).

Also in this change:

- Various other code was modified to return errors in a std::string*
argument, to be able to surface the error string to the end-user.

- Improved error checking and use of D() to log Winsock errors for
improved debuggability.

- For sysdeps_win32.cpp, added unique_fh class that works like
std::unique_ptr, for calling _fh_close().

- Fix win32 adb_socketpair() setting of errno in error case.

- Improve _socket_set_errno() D() logging to reduce confusion. Map
a few extra error codes.

- Move adb_shutdown() lower in sysdeps_win32.cpp so it can call
_socket_set_errno().

- Move network_connect() from adb_utils.cpp to sysdeps.h.

- Merge socket_loopback_server() and socket_inaddr_any_server() into
_network_server() since most of the code was identical.

Change-Id: I945f36870f320578b3a11ba093852ba6f7b93400
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/transport_local.cpp
381cfa9a8bc262dcd823a8bb6adc189595a2fe7d 24-Jul-2015 Elliott Hughes <enh@google.com> Report getaddrinfo failures correctly.

Also move us off the "convenience" function because you can't get useful
error reporting from it.

Change-Id: I5fcc6a6d762f5f60906980a7835f01a35045be65
/system/core/adb/transport_local.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/transport_local.cpp
3abd31d8f4b4a86297ecc619ce746e660cb59028 09-Jun-2015 Spencer Low <CompareAndSwap@gmail.com> adb server: don't close stale fd when TCP transport is closed

I think this fixes a scary bug that could be on all host platforms.

When running 'adb unroot' with an emulator, the connection to the
emulator is dropped (as expected). I noticed that the adb.log showed:

_fh_from_int: 1168: 5280 | _fh_from_int: invalid fd 106 passed to adb_close

Background: Every transport has a socketpair (two bidirectional sockets
connected to each other to form one 'pipe') that are used as follows:

* When adb wants to write to a transport, it writes to
t->transport_socket (half of the socketpair). An input thread reads from
t->fd (the other half of the socketpair) and writes the data to the
underlying transport (TCP, USB).

* An output thread reads from the underlying transport (TCP, USB) and
writes the data to t->fd. The main thread runs fdevent_loop() which
reads from t->transport_socket and processes the packets (that really
came from the underlying transport).

So t->fd and t->transport_socket are just an intermediate pipe between
transport agnostic code in adb and the underlying transport (TCP, USB).

Here's what I think is going on:

1. When the TCP transport is closed (such as when running adb unroot),
adb server's output thread notices this (adb_read() returns zero), and
it writes a special packet to t->fd.

2. The main thread processes the special packet by writing the special
packet to the input thread.

3. input_thread() sees the special packet, so it breaks out of a read
loop and calls transport_unref() which calls transport_unref_locked().

4. transport_unref_locked() calls t->close() which is a function pointer
that points to transport_local.cpp: remote_close() which calls
adb_close(t->fd). <----- ****THIS IS THE BUG****

I think this is a (very old) typo and it should instead be
adb_close(t->sfd) (the transport’s actual TCP socket) because it does
not make sense for the particular transport mechanism (TCP, USB) to be
messing with a socket of the socketpair of the transport agnostic code
(t->fd).

5. transport_unref_locked() calls remove_transport() which writes an
action to another special socketpair.

6. The action is read and eventually transport_registration_func() is
called and it calls adb_close(t->fd). But t->fd was already
(erroneously) closed in #4 above!! Anyway, this causes the adb.log
output.

The fix is to fix the typo changing t->fd to t->sfd and adding some
resiliency around whether the socket has already been closed (probably
by remote_kick()).

I tested this by putting a new adbd on an emulator, a new adb on Linux
and Windows and running the adb unroot scenario and checking adb.log. I
also ran test_adb.py (which doesn't totally work without problems with
an emulator, but I'll leave that to another day.)

Change-Id: I188b6c74917a3d721c150fd17ed0f2b63a2178c3
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/transport_local.cpp
dcd78a15d0be143d48fc93af6a9fa5748dbf9790 19-May-2015 Dan Albert <danalbert@google.com> Make connection states a proper type.

Change-Id: I809f9b327c832b88dd63151bf7dcb012d88e81c4
/system/core/adb/transport_local.cpp
9b0f354fa25e3d5add516000c761e07c81c3bbc1 05-May-2015 Elliott Hughes <enh@google.com> Simplify adb_thread_create.

Change-Id: I36d6021ef8fbc23e8bcd4ddbe1dac0eba467cc70
/system/core/adb/transport_local.cpp
ab52c181fa4c1c9891644635dc5653cda5b90e2b 02-May-2015 Elliott Hughes <enh@google.com> Add WriteFdFmt and clean up more code.

Also say *which* device wasn't found.

Bug: http://b/20666660
Change-Id: I50e234ad89e39ae0a8995083c0b642c61275c5a3
/system/core/adb/transport_local.cpp
6452a89aa8934231e12ab77e0d90f12c3e892ad1 29-Apr-2015 Elliott Hughes <enh@google.com> More fixed-length buffer removal.

Bug: http://b/20666660
Change-Id: I0c738e9fed2defed48a9cf2d0a4f7b99c08dcf3d
/system/core/adb/transport_local.cpp
7b506090e1ac51f4990f17621c6e33847b0632a2 20-Apr-2015 Elliott Hughes <enh@google.com> Always explain why bind(2) failed.

This has confused several people lately.

Bug: http://b/20219978
Change-Id: I2537ceb83bff0b3166c230c728d4389a983db858
/system/core/adb/transport_local.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/transport_local.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/transport_local.cpp