Commit graph

222 commits

Author SHA1 Message Date
Josh Gao
47330e21db adb: statically link libbase into the tests.
Make it easier to run the Windows tests with wine.

Test: adb_test
Test: wine adb_test.exe
Change-Id: I243c3adf4f6519dd7a38666ab42b384858351e21
2017-04-12 17:38:09 -07:00
Josh Gao
46de1d7f03 adb: don't try to resolve 'localhost'
Misconfigured systems can have localhost pointing to an address that
isn't 127.0.0.1 or ::1.

adb is the only caller of the libcutils socket_loopback functions, so
move them into adb and switch the implementations over to using
INADDR_LOOPBACK and in6addr_loopback, instead of resolving 'localhost'
when connecting.

Bug: http://b/37282612
Test: `killall adb; adb shell`
Test: `killall adb; ip addr del 127.0.0.1/8 dev lo; adb shell`
Change-Id: I01c1885f1d9757ad0f7b353dd04b4d1f057741c8
2017-04-12 16:07:49 -07:00
Casey Dahlin
1b35c3f471 Merge changes from topic 'adb-mdnsd'
am: f4f95496ce

Change-Id: I1749f913b8c5cca64880d3eec3009f850bc9141e
2017-03-10 01:16:46 +00:00
Casey Dahlin
bd2c93fab0 Enable mDNS on Darwin
am: 304150a521

Change-Id: Id0d77614fc3bf580c2879b9ad801c77dcbfc7752
2017-03-10 01:16:31 +00:00
Casey Dahlin
cef0c7cf7d Don't include mDNS support on platforms other than Linux
am: d6c8091e9f

Change-Id: Ife0b6e08098c05288c3ea63e9063e5116335716a
2017-03-10 01:16:18 +00:00
Casey Dahlin
b298855764 Add mDNS device discovery for adb client
am: 13a269ea24

Change-Id: Ib5f80b3ccc9db7c6fe6f5c989e82083d734ce4df
2017-03-10 01:16:05 +00:00
Casey Dahlin
cc9c92fa95 Make ADBD announce its presence over mDNS
am: 6cd5e0b4ef

Change-Id: Ida2f133f72087f291f2d34e968503ae81c3fbd50
2017-03-10 01:15:31 +00:00
Casey Dahlin
304150a521 Enable mDNS on Darwin
We have to disable IPv6 to get this going, but nobody was yet using
IPv6, so that should be fine for now.

Test: Verified mDNS discovery on a MacBook
Bug: 31042497
(cherry picked from 9ae65de087171072f3890a81b074ae27db319508)

Change-Id: I628f0a1e9c4784db42fa56f5faf2904b6e1cf548
2017-03-07 14:45:52 -08:00
Casey Dahlin
d6c8091e9f Don't include mDNS support on platforms other than Linux
Test: Shamu build now passes
Bug: None
(cherry picked from 122a7738606d854d6dc10fa361c1d7296cc9670a)

Change-Id: I650adf0bca96fb655163f5e9b27d9995ae448ec2
2017-03-07 14:45:52 -08:00
Casey Dahlin
2fe9b60475 Make ADB over mDNS work on Windows
Test: Verified ADB over mDNS on a Windows machine
Bug: 30482671
(cherry picked from 9fdd77101f49d03ff29342e12e23edf241f68522)

Change-Id: If955ca304db71a5b08c5a9654f1e27ab74af9af8
2017-03-07 14:45:52 -08:00
Casey Dahlin
13a269ea24 Add mDNS device discovery for adb client
Test: Was able to discover a raspberry pi.
Bug: 28074466
(cherry picked from e292cd16760321fccc99c8c261cb92fa4b6462ab)

Change-Id: Id9571576457a4a0a078e48a274a4e8eac78bfe2b
2017-03-07 14:45:51 -08:00
Casey Dahlin
6cd5e0b4ef Make ADBD announce its presence over mDNS
We now request mdnsd from adb and register a service of type _adb._tcp
for clients to connect to.

Test: Verified service appears in avahi-browse
Bug: 28074466
(cherry picked from 379ac414e4d9f53388d903913022a55695292775)

Change-Id: Ie871b9c8b40e86063cc1e68e8f3e4290ead2d279
2017-03-07 14:42:06 -08:00
bohu
294d44be33 DO NOT MERGE ANYWHERE Qemu-pipe: refactor qemu_pipe.h into libqemu_pipe
Traditionally, qemu_pipe has both the declaration and implentation of each
function in one header file--qemu_pipe.h, and it is getting incovenient to
maintain.

This CL separates the implementation of functions from the header file,
and makes qemu_pipe a static library for other modules to link to.

Note that the interface and implementation of qemu_pipe are kept unchanged,
and future CLs will enhance the implementation to make it more reliable and
more compatible with old and new API levels.

Following projects are affected by this refactoring, and they are modified
accordingly:

device/generic/goldfish
device/generic/goldfish-opengl
hardware/ril/reference-ril

Change-Id: I541ecbf0cc7eadeef9d4e37ffd9ca7bfcc5c94c0
2017-03-01 16:33:44 -08:00
Josh Gao
3d4d973e82 Revert "adb: remove win32 dependency on libwinpthread-1.dll."
This reverts commit c2e984eec8.

Move the change to build/make, so that other win32 binaries get this as
well.
2017-02-23 13:16:52 -08:00
Josh Gao
c2e984eec8 adb: remove win32 dependency on libwinpthread-1.dll.
Explicitly link against the static libwinpthread.a to avoid a
dependency on the dll.

Also, make the tests link against libbase statically.

Bug: http://b/31665213
Test: wine adb.exe
Test: wine adb_test.exe
Change-Id: Ifd41afcb1756a4b9b6db12e102b4db502e73d846
2017-02-21 15:30:11 -08:00
Josh Gao
1c70e1bcbc adb: add libusb implementation for Linux/Darwin.
Add a libusb-based implementation alongside the existing native
implementations, controlled by the ADB_LIBUSB environment variable.

Windows will need more work for the usb driver.

Bug: http://b/31321337
Test: python test_device.py on linux/darwin, with ADB_LIBUSB=0 and 1
Change-Id: Ib68fb2c6c05475eae3ff4cc19f55802a6f489bb7
2017-01-25 13:52:53 -08:00
Josh Gao
456e1ad420 adb: move usb_* to client/usb_*.
Bug: http://b/31321337
Test: mma
Change-Id: I21eefab953737e87d211959616ac4f48926dd92c
2017-01-19 15:49:55 -08:00
Josh Gao
44c688ca19 adb: reorganize adbd USB handling code.
Break adbd's USB initialization code into its own static library to
allow it to be used by benchmark code that pretends to be adbd.

Bug: http://b/31289465
Test: adb shell works on bullhead
Change-Id: I0ac7d78a4f7aef59bd6d14fc5cf1ed870e1f3a9d
2017-01-19 13:19:45 -08:00
Josh Gao
cbe70cb0a8 debuggerd: advance our amazing bet.
Remove debuggerd in favor of a helper process that gets execed by
crashing processes.

Bug: http://b/30705528
Test: debuggerd_test
Change-Id: I9906c69473989cbf7fe5ea6cccf9a9c563d75906
2017-01-17 13:57:57 -08:00
Alex Deymo
705353ae27 Remove "_static" and "_host" suffix from libext4_utils.
Bug: 34220783
Change-Id: I967dbaa9c48ad1feed2369c3a40f745b86a350f8
2017-01-11 14:05:42 -08:00
Tao Bao
40e0ec918e adb: Fix the 'adb reboot sideload' for A/B devices.
We used to write the command file (/cache/recovery/command) to trigger
the sideload mode. A/B devices don't support that (may not have /cache
paritition). This CL switches to using libbootloader_message which
writes the command to BCB (bootloader control block) instead.

Test: "adb root && adb reboot sideload" reboots sailfish into recovery
      sideload mode.

Change-Id: I158fd7cbcfa9a5d0609f1f684a2d03675217628f
2017-01-05 18:01:01 -08:00
Josh Gao
5a1e3fdaf8 Revert "Revert "adb: extend sync protocol's stat support.""
This reverts commit afa4b5d6eb.

Add functions to translate errno to and from the linux asm-generic
values, since mips has different values.

Bug: http://b/33058958
Test: python test_device.py with both old and new adbd
Change-Id: I1a122235f3e793ed10b3bf3ad293388015134150
2016-12-05 17:38:30 -08:00
Josh Gao
a3577e1ac5 Revert "Revert "adb: move adb_strerror to sysdeps/win32/errno.cpp.""
This reverts commit 43c02b27cd.

Test: mma
Change-Id: I6b22ead8a4b964973ee2fdb8deba42bea74880cf
2016-12-05 17:38:30 -08:00
Josh Gao
afa4b5d6eb Revert "adb: extend sync protocol's stat support."
This reverts commit d6d5c38469.
2016-12-05 13:16:02 -08:00
Josh Gao
43c02b27cd Revert "adb: move adb_strerror to sysdeps/win32/errno.cpp."
This reverts commit 4fba3d2638.
2016-12-05 13:15:55 -08:00
Josh Gao
4fba3d2638 adb: move adb_strerror to sysdeps/win32/errno.cpp.
Bug: none
Test: mma
Change-Id: I9df4d6faf9883a78f50ca6b2b7c35f095d06ae20
2016-11-30 13:23:21 -08:00
Josh Gao
d6d5c38469 adb: extend sync protocol's stat support.
Extend the file sync protocol to support calling regular stat (instead
of lstat), return error codes, and provide the entire stat struct.

Bug: http://b/33058958
Test: python test_device.py with both old and new adbd
Change-Id: I841123debc380f86194a19e91c97d85160112144
2016-11-30 13:23:21 -08:00
Treehugger Robot
955648a915 Merge "Rely on the platform -std default." 2016-10-14 02:28:38 +00:00
Elliott Hughes
36e0d390a2 Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I18a1d816d63b64601485045070851f32d44e85eb
2016-10-10 14:31:12 -07:00
Treehugger Robot
4a8b178c97 Merge "adb: split up adb_auth.cpp." 2016-10-06 19:37:31 +00:00
Josh Gao
3bd2879d8e adb: split up adb_auth.cpp.
All of the functions in adb_auth.cpp were used in only one of
adb/adbd. Split up them up into adb_auth_host.cpp and adbd_auth.cpp
respectively.

Bug: http://b/29273531
Test: built and flashed bullhead, adb still works
Change-Id: Ib610c5157522634cc273511175152f1306cc52a7
2016-10-06 12:36:26 -07:00
Tao Bao
fee161d189 adb: Remove the obsolete include path to ext4_utils.
Since commit 8ad80763e4 has removed
'#include "ext4_sb.h"', there's no more reference to ext4_utils headers.

Test: `mmma system/core/adb`

Change-Id: I7ca1a6e91f1e0de84238c2a7facbebe9600a3d87
2016-10-05 18:06:03 -07:00
Josh Gao
1099215e30 adb: parse tcp socket specs with base::ParseNetAddress.
libbase already has IPv6-aware address parsing, so use it instead of
adb's handrolled IPv4-only parsing.

Bug: http://b/31537253
Change-Id: I4e9ce56b55d7d02787c0fa67b724490bf49ce479
Test: mma && adb start-server && \
      adb -L 'tcp:[::ffff:127.0.0.1]:5037' devices && \
      adb -L 'tcp:localhost:5037' devices && \
      adb -L 'tcp:127.0.0.1:5037' devices && \
      adb -L 'tcp:5037' devices && \
      $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
2016-09-20 13:55:43 -07:00
Elliott Hughes
82ff315bb0 Add android::base::GetExecutablePath, switch adb and fastboot over.
We'd long had two copies of this stuff, so rather than rewrite both
Linux versions to use android::base::Readlink, let's kill the duplication
too...

Bug: http://b/30988271
Change-Id: I4de58a94a22a4b1faf969a6fc70ca1560a4d5121
2016-09-01 09:24:24 -07:00
Felipe Leme
6f5080faa5 DO NOT MERGE: Show bugreport progress.
adb calls bugreportz to generate a bugreport; initially, bugreportz
would only report the final status of the operation (OK or FAIL), but
now it sends intermediate PROGRESS lines reporting its progress (in the
form of current/max).

Similarly, the initial implementation of 'adb bugreport <zip_file>'
would print an initial 'please wait' message and wait for the full
stdout before parsing the result, but now it uses a new callback class
to handle the stdout as it is generated by bugreportz.

BUG: 28609499

Change-Id: I6644fc39a686279e1635f946a47f3847b547d1c1
(cherry picked from commit cd42d658b2)
(cherry picked from commit 97b73a0daf)
2016-08-30 13:06:28 -07:00
Felipe Leme
698e065e14 DO NOT MERGE: Split bugreport() into its own file and added unit tests.
bugreport() will be soon refactored to track progress, which will
require more comprehensive unit tests.

As such, it's better to move it to its own files, which in turn also
requires moving send_shell_command() and usage() to commandline.h.

Fixes: 30100363
Bug: 30268737

Change-Id: I3cdf114a0b5547293320042ff0749a60886440b0
(cherry picked from commit 78e0963e4b)
(cherry picked from commit 218e1ff759)
2016-08-30 13:06:23 -07:00
Josh Gao
cfb21412e5 adb: factor out socket specification.
Move the logic for string socket specification out to separate
functions to facilitate using arbitrary sockets for the adb command
socket.

Bug: http://b/30445394
Change-Id: Icd8fdb853272edc029fb3a0f5b18e941dc8ef52c
Test: adb_test, adbd_test, test_device.py
2016-08-25 17:12:26 -07:00
Josh Gao
47763c3a09 libcrypto_utils: convert to Soong.
Bug: http://b/30708454
Change-Id: Iaad64272ced766f87e67f2877e990afccc558065
2016-08-05 18:07:36 -07:00
Josh Gao
f551ea0f63 adb: fix stat on Windows.
stat on Windows fails with ENOENT when passed a path with a trailing
slash or backslash, regardless of whether the target is actually a
directory. Emulate the correct POSIX behavior by stripping trailing
path separators and then checking if the target is a directory if
successful.

Bug: http://b/30481559
Bug: https://code.google.com/p/android/issues/detail?id=214633
Change-Id: I1d398d19a9bce1ecb3fdc4aabc31aa98c82c3f93
Test: Relevant adb_tests pass on Linux and Windows 10.
2016-08-01 12:36:04 -07:00
Josh Gao
809607ae28 adb: use libdebuggerd_client.
Bug: http://b/24414818
Change-Id: I177708877488e5c4f99c453498485a2daa9b79b0
2016-06-17 13:11:29 -07:00
Josh Gao
b463baf610 adb: add track-jdwp and track-devices commands.
Expose these to the command line client to make it easier to poke
around.

Bug: http://b/28347842
Change-Id: Ia939b3a41eb8201365d50cd2996b83d884e42b64
2016-05-14 18:35:44 -07:00
David Pursell
eaae97e127 adb: support forwarding TCP port 0.
This CL adds support to forward or reverse TCP port 0 to allow the
system to automatically select an open port. The resolved port number
will be printed to stdout:
  $ adb forward tcp:0 tcp:8000
  12345
  $ adb reverse tcp:0 tcp:9000
  23456
This allows testing to be more robust by not hardcoding TCP ports which
may already be in use.

Forwarding port 0 is a host-only change and will work with any device,
but reversing port 0 requires the device to be updated with a new adbd
binary.

This CL also does a little bit of cleanup such as moving the alistener
class out of adb.h, and adds some error checking and additional tests.

Bug: 28051746
Test: python -m unittest discover
Test: adb_test
Test: `adb forward` and `adb reverse` with tcp:0
Change-Id: Icaa87346685b403ab5da7f0e6aa186aa091da572
2016-05-09 16:55:10 -07:00
Mattias Nissler
097b6bbc76 Switch fs_mgr and adb to libcrypto_utils.
Update code and dependencies to use BoringSSL + libcrypto_utils
instead of mincrypt.

Change-Id: Ic75164bd50c84b81b6310e27a67d4b3c174984f9
2016-04-12 23:04:11 +00:00
Ying Wang
71edfc8b9a Also archive adb.exe/fastboot.exe when building win_sdk.
On linux we archive both Linux and Windows binaries.

Bug: 27315911
Change-Id: I17d25cd1ea611a9c917f1e78b47f21a8959eea20
2016-02-29 19:27:06 -08:00
David Pursell
e663c163ac Merge "adb: use TCP keepalive." 2016-02-29 17:43:35 +00:00
Dan Willemsen
582c8fe1d4 Remove duplicate fdevent.cpp entry
Fixes the following warnings:

build/core/binary.mk:894: warning: overriding commands for target
`out/target/product/bullhead/obj/STATIC_LIBRARIES/libadbd_intermediates/fdevent.o'
build/core/binary.mk:894: warning: ignoring old commands for target
`out/target/product/bullhead/obj/STATIC_LIBRARIES/libadbd_intermediates/fdevent.o'
build/core/binary.mk:894: warning: overriding commands for target
`out/target/product/bullhead/obj_arm/STATIC_LIBRARIES/libadbd_intermediates/fdevent.o'
build/core/binary.mk:894: warning: ignoring old commands for target
`out/target/product/bullhead/obj_arm/STATIC_LIBRARIES/libadbd_intermediates/fdevent.o'

Change-Id: Id4b13574e568284cefbc3a763d40843e73ddbd3d
2016-02-23 14:28:20 -08:00
David Pursell
bfd9503d1d adb: use TCP keepalive.
Currently adb only realizes a TCP transport has gone away when it tries
to send a packet, which caused problems in particular for `adb reboot`
since no packets are sent, leading to the client hanging until Ctrl+C.

This CL turns on TCP keepalive packets to send 1 packet every second,
allowing up to 10 failures before disconnecting. Using built-in TCP
functionality turns out to be much cleaner in this case than trying to
implement our own keepalive packets at the application layer, and
should be more lightweight since it's all done in the TCP stack.

Bug: http://b/23093474

Change-Id: Ifb41cbb85b9752a9f394e1eed3c6ac4da47a4e4d
2016-02-23 09:11:18 -08:00
Josh Gao
4a9084228a Merge changes I6541bb13,I486055bb,Id6ac1c54,I16cf7d44
* changes:
  adb: make fdevent_test, socket_test compile on Windows.
  adb: add fd exhaustion test, fix errno reporting in sysdeps_win32.
  adb: move win32 fd base to 2048, fix fd allocation.
  adb: don't emulate fdevent or socketpair on Windows.
2016-02-20 01:41:09 +00:00
Josh Gao
022d447e9e adb: make fdevent_test, socket_test compile on Windows.
Switch pthread_* to use the adb_thread_* abstractions to allow the fdevent
and socket tests to compile on Win32.

Bug: http://b/27105824
Change-Id: I6541bb1398780b999837e701837d7f86a5eee8ca
2016-02-19 11:24:51 -08:00
Josh Gao
3777d2ecc0 adb: don't emulate fdevent or socketpair on Windows.
Change-Id: I16cf7d4427eb79f36db39e91f85402a268fa72f5
2016-02-19 11:24:51 -08:00