Commit graph

2978 commits

Author SHA1 Message Date
Mark Salyzyn
2f6c180749 adb: use /system/bin/remount command
Replace direct logic in support for 'adb remount' with an exec out to
/system/bin/remount to do the heavy lifting.  Remount success and
failure strings are reported by the adb remount service in response
to the various reported errors, freeing up the remount command itself
from the legacy of script expectations.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: I686fa465f463b881bbb38f709d780a95e463be80
2019-03-04 11:12:54 -08:00
Josh Gao
b530537d46 Merge "adbd: fix a case where we can fail to join a thread." 2019-03-01 10:16:46 +00:00
Josh Gao
5841a96afc adbd: tune USB read/write sizes and queue depths.
Reduce the operation sizes to sizes that are small enough that the
kernel will run the OOM killer to try to make them succeed. Compensate
for the smaller operation sizes by increasing the queue depth.

Bug: http://b/126582877
Test: benchmark_device.py
Change-Id: I4d351f56c8f83fea882614238cc3fec8ba1e9bf9
2019-02-28 15:53:48 -08:00
Josh Gao
b416f2252e adb: add benchmarks for sink/source.
Test: ./benchmark_device.py
Change-Id: Ib9e911574be3afa94efcfd9bc5be0a5cf7b9e2c0
2019-02-28 15:53:48 -08:00
Josh Gao
e778b3ad71 adbd: fix a case where we can fail to join a thread.
Bug: http://b/126703621
Change-Id: I3061d24bbdc154ebf1f9e3f5a903f01382fa518f
2019-02-28 13:53:24 -08:00
Josh Gao
50cb647e7d Merge "adbd: limit the sizes of aio writes." 2019-02-28 07:25:21 +00:00
Josh Gao
86b33be035 adbd: limit the sizes of aio writes.
The kernel does a kmalloc of the write size for each write during
io_submit, which can lead to failure if the kernel's heap is fragmented
such that it can't allocate a contiguous 1MB chunk. Partition writes
into 16 page chunks which are much more likely to succeed.

Bug: http://b/126582877
Test: test_device.py
Change-Id: Ib2d48561594e1d81f1a2f62e34eaa40265ac47c4
2019-02-27 15:45:59 -08:00
Dario Freni
455f12446e Merge "Support splitAPK in install-multi-package." 2019-02-27 19:00:14 +00:00
Josh Gao
c2970282cb Merge "Revert "adbd: switch the default USB implementation."" 2019-02-26 22:15:40 +00:00
Josh Gao
0d780391a1 Revert "adbd: switch the default USB implementation."
This reverts commit 12f328489b.

Reason for revert: possibly causing b/126388431

Change-Id: Ida7c30a92f552f923f3bcb153d945d58ebbc4257
2019-02-26 22:10:33 +00:00
Josh Gao
216d158daf Merge changes I86c3ec0f,I57d1a30a,Ib50d289b,I791a4f82,I316a8799, ...
* changes:
  adb: switch sockets.cpp to ConsumePrefix.
  adbd: switch abb to ConsumePrefix.
  adb: increment server version.
  adb: wait for device to disconnect upon `adb root`.
  adb: implement wait-for-disconnect.
  adb: tell the client what transport it received.
  adbd: switch daemon/services to ConsumePrefix.
  adb: switch host_service_to_socket to string_view.
  adb: switch handle_host_request to string_view.
  adb: switch adb_io.h to string_view.
  adb: add helper to consume a prefix on a string_view.
  adb: make ParseUint reject garbage at the end by default.
2019-02-26 20:55:19 +00:00
Josh Gao
5782600271 Merge "adbd: switch the default USB implementation." 2019-02-26 06:47:46 +00:00
Josh Gao
43f3805950 adb: switch sockets.cpp to ConsumePrefix.
Test: mma
Change-Id: I86c3ec0fd90fe45e59c0187f664d46020bad2c0f
2019-02-25 13:59:00 -08:00
Josh Gao
ccc584523a adbd: switch abb to ConsumePrefix.
Test: mma
Change-Id: I57d1a30a526c97c5b5a2718740b76220da6eea39
2019-02-25 13:59:00 -08:00
Josh Gao
aa4f31a124 adb: increment server version.
Increment the server version for adb_connect with transport id, and
wait-for-disconnect.

Bug: http://b/124244488
Test: none
Change-Id: Ib50d289b68fce4befbf1f5d9507d7e6f9cc1f4f5
2019-02-25 13:59:00 -08:00
Josh Gao
2020dd6f2e adb: wait for device to disconnect upon adb root.
Previously, there was a race where if adb root took longer than 3
seconds to take effect, we'd return early and allow subsequent commands
to be targeted at the still-not-dead transport, and spuriously fail.

Bug: http://b/124244488
Test: test_device.py
Change-Id: I791a4f82946eb28e4d37729ab0ed3b7fc05b42a2
2019-02-25 13:59:00 -08:00
Josh Gao
1e9e471c9c adb: implement wait-for-disconnect.
Bug: http://b/124244488
Test: manual
Change-Id: I316a87994924c51c785e46a4900380c58e726985
2019-02-25 13:59:00 -08:00
Josh Gao
79797ecbb1 adb: tell the client what transport it received.
Prerequisite for making `adb root` wait for the device that it told to
restart to disappear: the client needs to know which transport to wait
on.

Bug: http://b/124244488
Test: manual
Change-Id: I474559838ad7c0e961e9d2a98c902bca3b60d6c8
2019-02-25 13:49:25 -08:00
Josh Gao
2df76b7ee7 adbd: switch daemon/services to ConsumePrefix.
Test: mma
Change-Id: Ib4bb7d3352219a9883a5089e08225fb17145c2ee
2019-02-25 13:49:25 -08:00
Josh Gao
0ecc4020d6 adb: switch host_service_to_socket to string_view.
Test: manual
Change-Id: I09b83cc82edb10c1a51ecc5ebb8d9fe5294222c3
2019-02-25 13:49:25 -08:00
Josh Gao
769f853f96 adb: switch handle_host_request to string_view.
Test: test_adb.py
Test: test_device.py
Change-Id: Ideae5262a6dff2e27c50f666144d48f874837290
2019-02-25 13:49:25 -08:00
Josh Gao
342b661e81 adb: switch adb_io.h to string_view.
Test: mma
Change-Id: Ifa16502bac18429491426c45ece562657cff1689
2019-02-25 13:49:25 -08:00
Josh Gao
ac8da2a7df adb: add helper to consume a prefix on a string_view.
It's error-prone to manually writing code of the following form:

  if (foo.starts_with("some_prefix:")) {
    foo.remove_prefix(strlen("some_prefix:"));
  }

Add a helper to do that for us.

Test: mma
Change-Id: I5df391deba8b6c036fcbf17a1f1c79af8d9abd2b
2019-02-25 13:49:25 -08:00
Josh Gao
aeca208385 adb: make ParseUint reject garbage at the end by default.
Test: adb_test on host
Change-Id: Ie63d89bd08f0b296a3d54ff66aae85fe52d8cd0f
2019-02-25 13:49:25 -08:00
Dario Freni
6dc6157bc8 Support splitAPK in install-multi-package.
Fix: 125342787
Test: adb install-multi-package file1.apex
base.apk:split1.apk:split2.apk (and also the non-split version)

Change-Id: I3d5ee2504b6d1e4f7ae555586960b61a2e1e9680
2019-02-25 12:10:31 +00:00
Alex Buynytskyy
05626c18af Adding EXEC version of calling ABB.
This is corresponding to exec: command of adb and allows for simplifed calls
to binder without shell protocol.

Bug: 111621042
Test: manual

Change-Id: Id6935cd53e351388ecf6d2d15f3a204cb871536a
2019-02-23 06:15:03 +00:00
Julien Desprez
9bfa166ad9 Merge "Temporarily @ignore test_reconnect" 2019-02-21 18:16:21 +00:00
Josh Gao
effcb96670 Merge "adb: update symlink timestamps." 2019-02-21 02:31:03 +00:00
Josh Gao
7b1cb66a83 adb: update symlink timestamps.
Bug: http://b/120162375
Test: adb sync; adb shell touch -h -d 2008-01-0101:01:01 /system/bin/ls; adb sync; adb sync
Change-Id: Iedf54528b164913739c66c71d20006e484a4f5e4
2019-02-20 13:17:56 -08:00
Julien Desprez
fb4c13500f Temporarily @ignore test_reconnect
For the purpose of on-boarding all the other tests,
skip test_reconnect for now.

Test: atest -v adb_integration_test_adb
Bug: 123247844
Change-Id: I50269272adbfc3f946d71bae13677546566d541f
2019-02-20 09:42:49 -08:00
Josh Gao
a80b64f2a0 adbd: log when exiting due to root/unroot/tcpip/usb.
Test: treehugger
Change-Id: Ibfbe4d512c6e126f2e6d311867316f033a4c9ab7
2019-02-19 13:12:59 -08:00
Josh Gao
8954d0bc98 Merge changes from topic "base_cmsg"
* changes:
  adb: switch to base::{Send,Receive}FileDescriptors.
  debuggerd: switch to base::{Send,Receive}FileDescriptors.
  base: add helpers for sending/receiving file descriptors.
2019-02-19 20:53:01 +00:00
Josh Gao
f80c326d2e Merge "adbd: fallback to legacy USB implementation if needed." 2019-02-17 04:14:22 +00:00
Josh Gao
12f328489b adbd: switch the default USB implementation.
Switch to the nonblocking FFS implementation that fixes several race
conditions on connect/disconnect.

Test: treehugger
Change-Id: I91fdb9b27152078cb38e610861a05f1fa95aa3a2
2019-02-15 11:43:49 -08:00
Josh Gao
c0b831bb81 adbd: fallback to legacy USB implementation if needed.
Detect kernels that don't support AIO on functionfs endpoints and fall
back to the old legacy implementation.

Test: treehugger
Change-Id: Ice28dcd40c9730ac2dd5e468d065b41c0e076146
2019-02-15 11:43:49 -08:00
Josh Gao
8e0af5f1b5 adb: switch to base::{Send,Receive}FileDescriptors.
Test: test_device.py
Test: adb abb package list packages
Change-Id: I080dc8620d77b0e6144c895fd2a0cbf7b8063c53
2019-02-13 13:21:54 -08:00
Josh Gao
982f7bd345 base: add ScopedLockAssertion.
This is a useful helper for anyone that's using thread safety
annotations alongside std::condition_variable, extract it from adb and
move it to libbase.

Test: mma
Change-Id: Ic51e2f2a0e6a16628034b29d8ff32bf2155afccd
2019-02-12 16:32:35 -08:00
Treehugger Robot
9c4fda6cd2 Merge "adb: "support" O_CLOEXEC in adb_open on Windows." 2019-02-08 06:56:47 +00:00
Josh Gao
aa95aa063f adb: hopefully deflake test_adb.py.
The reconnection test is spuriously failing on test infrastructure for
unclear reasons, which might be due to a race between the connection
attempt and the first command we send. Insert a sleep to hopefully
reduce the flakiness.

Bug: http://b/123247844
Test: ./test_adb.py (but it didn't fail for me in the first place)
Change-Id: Ic36924c16bae424accfec700af4623794fd1f123
2019-02-07 17:53:29 -08:00
Josh Gao
4b019a5f25 adb: "support" O_CLOEXEC in adb_open on Windows.
Previously, we were rejecting the flag and failing with EINVAL. File
handles aren't inherited by default, so just ignore the flag.

Bug: http://b/123753498
Test: adb install --streaming foo.apk
Change-Id: I17401fcdd58024956d47a5c4c0c57b06831d9817
2019-02-07 14:23:39 -08:00
Josh Gao
74b7ec72f8 adb: don't close sockets before hitting EOF.
Reimplement commit ffc11d3cf3 using
fdevent. The previous attempt was reverted because we were blindly
continuing when revents & POLLIN == 0, which ignored POLLHUP/POLLERR,
leading to spinloops when the opposite end of the file descriptor was
shutdown when we had no data left to read.

This patch reimplements the functionality implemented by that commit
using fdevent, which gets us detection of spin loops for free.

Bug: http://b/74616284
Test: ./test_device.py
Change-Id: I1abd671fef4c29e99dad968aa66bb754ca382578
2019-01-31 23:36:41 -08:00
Josh Gao
1a90118bbb adb: implement fdevent_set_timeout.
Test: adb_test
Change-Id: I9ae61465617b6a2fe0a1c161ad88c4feae49ec80
2019-01-31 23:36:41 -08:00
Josh Gao
69ba5179f4 Merge changes If8747ba1,Id1943ebd
* changes:
  adb: improve network_connect error messages.
  adbd: fix TCP bind address.
2019-01-31 21:19:45 +00:00
Tom Cherry
54ea49ba05 Merge "Add android::fs_mgr namespace for new Fstab code" 2019-01-31 19:35:54 +00:00
Josh Gao
ee0e63f71d Merge changes Ief3dbf8e,Ib06e6f65
* changes:
  adb: add fdevent callback that passes the fdevent.
  base: don't overwrite errno in unique_fd::~unique_fd.
2019-01-31 09:09:12 +00:00
Treehugger Robot
a15f385821 Merge changes from topic "move_bionic_to_apex3"
* changes:
  Handle adb sync with Bionic under /bionic
  Proper mount namespace configuration for bionic
2019-01-31 04:46:49 +00:00
Tom Cherry
a3530e6366 Add android::fs_mgr namespace for new Fstab code
Should have been done a while ago, but better late than never.

Test: treehugger
Change-Id: I0ea6e8d459cd3f3b3ce2d00a7a6a9786d52c52dd
2019-01-30 20:20:05 -08:00
Josh Gao
c162c713ef adb: add fdevent callback that passes the fdevent.
This is useful for when we don't want to actually store the fdevent
into a separate struct to be able to destroy it, but instead want to
destroy it immediately from the callback.

Test: adb_test
Change-Id: Ief3dbf8ea6a6bd72dc7e73f9ab9b7429e48fc181
2019-01-30 15:18:56 -08:00
Josh Gao
64e597a62f adb: improve network_connect error messages.
Test: manual
Change-Id: If8747ba1951d3c87561fbd3fb4968821243b2ee2
2019-01-30 14:54:10 -08:00
Josh Gao
eb0875db65 adbd: fix TCP bind address.
The switch to socket_spec_listen broke adbd over TCP, because
socket_spec_listen only listens on localhost.

Bug: http://b/123592649
Test: manual
Change-Id: Id1943ebd7f0059db05ad756fe96189c60ebde337
2019-01-30 14:49:20 -08:00