Commit graph

109 commits

Author SHA1 Message Date
Joshua Duong
d85f5c0130 [adbwifi] Add adbwifi_libs, TLS connection, and MDNS implementation.
Bug: 111434128, 119493510, 119494503

Test: Enable wireless debugging in Settings UI, click "pair with pairing code"
to generate pairing code.
On client, 'adb pair <ip_address>', enter pairing code at prompt and hit
enter. Pairing should complete.
'adb logcat'.
Change-Id: I86527bd3fc52e30a8e08ec5843dc3e100abf91fa
Exempt-From-Owner-Approval: approved already
2020-02-21 21:06:40 +00:00
Alex Buynytskyy
96ff54bf34 Incremental installations in adb, client/host side.
Test: adb install --incremental <apk>

Change-Id: I74e3eaf9718a16272bc533bc8298dfcf81120caa
2020-02-19 08:01:06 -08:00
Daniel Colascione
3ec7be7a84 Revert "Revert "Support socket activation of adb server""
Test: actually build both device and client adb this time

This reverts commit c77904e3c5.

Change-Id: I8c2b8f24884ff36ff2460dab2500bad777100dfd
2019-12-11 08:20:20 +00:00
Raman Tenneti
c77904e3c5 Revert "Support socket activation of adb server"
This reverts commit 4456b5fc15.

Reason for revert: Device boot failure BUG: 144355953

Change-Id: I539400fa2422bd4d6e396634c629a928cd2ac398
2019-11-12 18:55:29 +00:00
Daniel Colascione
4456b5fc15 Support socket activation of adb server
Socket activation allows adb to be run as a system daemon that starts
only as needed and supports race-free transparent restarts of the adb
server after a client issues an "adb kill-server" command.

Test: see SOCKET-ACTIVATION.txt
Change-Id: Ieabf08710ce4365e5513102f3aa578560aa7355e
2019-11-07 20:28:06 -08:00
Alex Buynytskyy
665f3ff5a7 FastDeploy refactor: 2+GB APK support, optimizations, tests.
- removed 2GB apk size cap,
- removed zip archive parsing on device (1.1M->236K agent size reduction),
- optimized matching entries search,
- added more robust matching entries search based on hash of CDr entry,
- reduced patch size by reusing Local File Header of matched entries,
- removed extra manifest parsing and extra agent calls,
- added device-side tests for agent,
- fix for Windows patch creation.

Test: atest adb_test fastdeploy_test FastDeployTests

Total time for 0-size patch reduction for 1.7G apk: 1m1.778s->0m36.234s.

Change-Id: I66d2cef1adf5b2be3325e355a7e72e9c99992369
2019-10-02 13:25:03 -07:00
Adrian Roos
68c14d10b8 adb: fix mac build
Ensure that off64_t is defined when building adb for mac

Fixes: 139646013
Test: make # On mac
Change-Id: I32b68738d71c8a63a35c22434092933dcabac1ce
(cherry picked from commit 2167b9082d)
2019-08-19 10:51:00 -07:00
Yurii Zubrytskyi
709dfc3524 [adb] Add a getter for native Win32 file handle
+ adb_pread() and adb_pwrite() functions for simpler cross
  platform file operations

Test: builds
Change-Id: I7e2b23e1da79acd7be974a3d7e1be0fb77d7d2c6
2019-08-08 15:52:21 -07:00
Josh Gao
57e09b16ca adb: move fdevent to its own folder.
Preparatory refactoring for platform-specific implementations.

Test: mma
Change-Id: I0f600122ac89241788c5f3300f362fd9ef02ddcd
2019-07-08 14:37:27 -07:00
Josh Gao
27241a7a96 Revert "Revert "Add a way to turn off unique_fd's operator int.""
The original commit broke aosp-master-with-phones, because of
vendor libraries the depended on the int versions of libbase functions.

This patch reverts the revert, and also adds ABI-compatibility shims for
the replaced functions.

This reverts commit 2c58e1924a.

Bug: http://b/131312539
Test: treehugger
Test: forrest run of aosp-master-with-phones
Change-Id: I75cc84ec8d963e20862f7662e8e2f409471f41cc
2019-05-06 16:18:02 -07:00
Ian Kasprzak
2c58e1924a Revert "Add a way to turn off unique_fd's operator int."
This reverts commit 93d63c010a.

Reason for revert: b/131312539 - All aosp-master-with-phones phones failing boot / health check.

Change-Id: Id4239f93484b7d6b8d9bcd355a59cbd40d9766e2
2019-04-25 15:59:28 +00:00
Josh Gao
93d63c010a Add a way to turn off unique_fd's operator int.
unique_fd's implicit conversion to int has led to tons of problems (see
all of the overloads for close, fdopen, fdopendir, etc.). Add a switch
that can turn it off, and reduce the ridiculous amount of work to fix up
callers by introducing a borrowed_fd type that can be constructed from
either int or unique_fd.

Test: treehugger
Change-Id: If77cf5cbcaddacdaec5919a15b3520fb68f51a62
2019-04-24 12:59:42 -07:00
Josh Gao
0f29cbc750 adb: switch unix_open to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: Ieecc9b1b7f2111f4da45d4bbd1b7703535fe7d4d
2018-12-21 01:43:31 -08:00
Elliott Hughes
d2aaede610 adb: don't use <error.h>.
This should fix the bloody Mac build, which doesn't have <error.h>. Since
we weren't entirely happy with error(3) anyway, switch to the toybox
style of error_exit and perror_exit, which are slightly briefer and quite
a bit more intention-revealing.

Bug: N/A
Test: builds
Change-Id: Ic8e411906c363af51657da5ce947b25a0b6bb1f3
2018-10-22 17:04:32 -07:00
Elliott Hughes
4679a39610 adb: rationalize fatal/error logging.
Let's use LOG(FATAL)/PLOG(FATAL) for actual fatal stuff.

Add a Windows error(3) and move folks who didn't really mean "abort"
fatal over to it. Also get rid of syntax_error which wasn't adding a
lot of value, and most of the places it was adding "usage: " didn't seem
entirely appropriate anyway.

In particular, we seemed to have confused fastdeploy.cpp into aborting
in most user error cases, and none of the reviewers noticed. Clearly
we'd all lost track of far too many options.

(I've also cleaned up a few random instances of fprintf(3) + exit(2).)

Bug: N/A
Test: manual
Change-Id: I3e8440848a24e30d928de9eded505916bc324786
2018-10-19 14:04:24 -07:00
Elliott Hughes
cabfc3dc80 Support > 2GiB seeks in adb_lseek.
Also stop using size_t (which will be 32-bit on Win32) for offsets in
adb_sideload_host, and stop truncating large file sizes in our
"sideload-host" messages.

Bug: http://b/112003354
Test: builds
Change-Id: If5b7cc9d1fc7ff7ca6eaebd20418f7b061846203
2018-09-26 14:48:05 -07:00
Josh Gao
c8d3853a14 Merge "adb: win32: set thread names" 2018-09-07 22:18:18 +00:00
Spencer Low
50beee3a2c adb: win32: set thread names
Use a new Windows 10 API, SetThreadDescription(). Background info from a Chrome developer:

https://randomascii.wordpress.com/2015/10/26/thread-naming-in-windows-time-for-something-better/

Test: Win10, Vista, adb shell
Test: Ran windbg -pn adb.exe, used .dump /ma to create a dump, ran
`dx -g @$curprocess.Threads' on the dump and it showed the thread names.

Change-Id: I14ea7121605cb3fa45ce7b59e2ba5882a215b59f
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-09-03 16:11:33 -07:00
Spencer Low
40babf0709 adb: win32: fix ReportServerStartupFailure
The code was passing an fd from adb_open() to android::base::ReadFdToString() which actually
takes a C-Runtime fd (on Windows), so it wasn't working.

The fix is to use APIs that deal with C-Runtime fds:
* unix_open()
* android::base::unique_fd
* unix_lseek() (added in this change)

I also removed an unnecessary call to GetProcessId() since we already have the process id
from the structure returned by CreateProcess().

Test: adb start-server on Win10 and Ubuntu (with a failing server)
Test: mma

Change-Id: Id6e2dd5532a02fe5d9caf96aa007a1b3434a0b59
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-09-02 19:26:25 -07:00
Josh Gao
45e3e95de0 adb: add better logging for connection failure.
Test: manual
Change-Id: I1babee0e01376955529dc1e7d5e3257a7f51f33d
2018-08-13 16:33:54 -07:00
Elliott Hughes
cd0f5c33fa Remove unused #include.
Bug: N/A
Test: builds
Change-Id: I792bfdb38672f7a51991c19a9838dd12500036c7
2018-07-11 11:21:36 -07:00
Elliott Hughes
d8a4c60276 Simplify __attribute__((__printf__)) use.
We don't need this now everyone's using clang...

Bug: http://b/69933068
Test: ran tests
Change-Id: I88f0cf03981ade47e210387fd6f3a2706dfeb9b8
2018-06-26 13:07:21 -07:00
Pirama Arumuga Nainar
a2df1ef441 Do not customize __format__ for Windows/MinGW to gnu_printf
Bug: http://b/69933090
Bug: http://b/69933068

MinGW uses gnu_printf to force C99 printf analysis with GCC, but clang
does not support gnu_printf.  So just use the default that's used for
other platforms.  This also mirrors upstream commit
015e637b4b/.

Test: m native-host-cross with Clang.
Change-Id: I3deb266d70e25296c4ae1d58637afbabc3d949c1
2018-06-25 11:52:54 -07:00
Josh Gao
2e1e789e2a adb: fix windows test build.
The switch over to soong unintentionally turned off building the
Windows tests (and there's a bug preventing them from being turned on).
Preemptively fix the build breakages that'll happen when we turn them
back on.

Test: mma with Android.bp 's/cc_test_host/cc_binary_host' hacks
Change-Id: I6582cfc61b96052537d50d8ba90533dbb66e3e1d
2018-03-23 13:03:28 -07:00
Josh Gao
5791e21697 base: export GetThreadId.
and stop using the incorrect (on Mac) version in adb..

Test: mma
Change-Id: If28f6c8d73b03db863be13ed88df81422c3aef87
2018-03-16 15:35:52 -07:00
Elliott Hughes
3df2fa6d8e Remove a duplicate TEMP_FAILURE_RETRY.
Bug: N/A
Test: builds
Change-Id: I19c2f50422e8a7e0c451a464586553f3e5eaadab
2017-11-28 18:05:27 -08:00
Elliott Hughes
7462f1858c Fix reference to out of scope local in adb_thread_setname.
Bug: https://android-review.googlesource.com/#/c/168725/5/adb/sysdeps.h@639
Test: boots, adbd thread names look sane
Signed-off-by: Ivan Maidanski <i.maidanski@samsung.com>
Change-Id: Ib3bdf53658f3903de8f0a5688f7d77745e677c77
2017-08-02 20:34:06 +00:00
Josh Gao
e1dacfc1b6 adb: kill adb_thread_{create, join, detach, exit}.
We have std::thread now, so we can delete this cruft.

Test: python test_device.py
Test: adb_test
Test: wine adb_test.exe
Test: /data/nativetest/adbd_test/adbd_test
Change-Id: Ie1c1792547b20dec45e2a62ce6515fcb981c3ef8
2017-04-12 17:12:32 -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
Josh Gao
3726a0195b Revert "adb: check our socketpair ends in our win32 emulation."
This reverts commit 5990191c4e.

Some Windows users are seeing mismatches between the two ends.

Bug: https://code.google.com/p/android/issues/detail?id=258400
Test: mma
Change-Id: Ie3a121a2754332608ff64b3b016adcb4258d41f3
2017-03-30 13:12:37 -07: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
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
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
05a3abfef3 adb: make sure that file mode macros match linux.
We use <sys/stat.h> mode macros on the host to parse modes sent over
from the device, so they had better match. Add static_asserts to ensure
this.

(Also, fix the cases where they don't.)

Test: mma -j48, compiled the static_asserts on darwin manually
Change-Id: I883e4e6c7489ea64d3c02d26790ac8293366d989
2016-11-21 18:39:21 -08:00
Elliott Hughes
dbe91eee26 Switch adb over to <chrono>.
Clearer code, and lets us lose some more portability cruft.

Bug: http://b/32878766
Test: manual
Change-Id: Ie44928bbf8d68a74127aaf76e7e0060e25fa2cc8
2016-11-16 09:12:12 -08:00
Tao Wu
7b700763f5 Fallback to IPv6 when IPv4 is not available in adb
Test: manual - make sure it works in both IPv4/IPv6 env.
BUG: 31537253
Change-Id: Ica492bff34a8c0441516a213d0e8b78fcdfd3282
Signed-off-by: Tao Wu <lepton@google.com>
2016-10-13 08:54:43 -07:00
Elliott Hughes
139b372fab Start retiring socket_loopback_client.
Bug: http://b/31537253
Test: can still talk to adb
Change-Id: Icfd7f00d35cf963befc139e81904790b4b8b67c0
2016-10-11 13:45:03 -07:00
Josh Gao
0cd3ae1c28 adb: kill adb_mutex_t, adb_cond_t.
Now that we have support for std::mutex and std::condition_variable on
Windows, remove our mutex compatibility layer in favor of the C++ one.

Bug: http://b/31653591
Test: mma && $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test && \
      python test_adb.py && python test_device.py
      (also on Windows)

Change-Id: I5b7ed9c45cc2a32edcf4e77b56dc28e441f15f34
2016-09-21 17:22:22 -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
5990191c4e adb: check our socketpair ends in our win32 emulation.
In our Win32 socketpair emulation, check that the ends are properly
connected before returning.

Change-Id: I33d356fd9ebcac89fc6a89a5200e926032220383
Test: no additional failing tests in adb_test.exe
2016-08-24 13:06:06 -07:00
Elliott Hughes
0aeb50500c Clean up key handling in adb.
This includes the locking we need to be able to re-load the keys at runtime.

We should rename "adb_auth_client.cpp" to "adb_auth_adbd.cpp" or
"adbd_auth.cpp" in a later change.

Change-Id: I9e1d5b6b7d0497d6f6e5d9c4fb660118cdff05a8
Test: "adb devices" works against a non-AOSP device with $ADB_VENDOR_KEYS set, says "unauthorized" without.
Bug: http://b/29273531
2016-08-11 13:53:18 -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
Elliott Hughes
e8b663fec3 Kill load_file.
Change-Id: I6c332f7d8e94d513605295b3d4d32c4e1cf878dc
2016-05-27 16:14:02 -07:00
Josh Gao
13ea01db45 adb/base: allow use of unique_fd inside adb.
adb implements its own file descriptor emulation layer on Windows,
which requires the use of adb_close instead of close throughout the
codebase. Add a template argument to unique_fd that allows for this.

Bug: http://b/28347842
Change-Id: I6397261f4973d49f2f8e04257bf67b348585bb63
2016-05-14 18:25:51 -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
Josh Gao
f0d3b4fc11 adb: make ScopedFd universally accessible and useful.
Change-Id: I707ffbd10958e7449b4c95dff48638480c746939
2016-03-04 15:15:56 -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
3777d2ecc0 adb: don't emulate fdevent or socketpair on Windows.
Change-Id: I16cf7d4427eb79f36db39e91f85402a268fa72f5
2016-02-19 11:24:51 -08:00
Josh Gao
d7b3749202 adb: sysdeps_win32: actually change ExitThread to _endthreadex.
Forgot to amend this into b5fea14e.

Change-Id: Id04e639eb87043901681db789d7a7925300fa867
2016-02-12 15:47:19 -08:00