Commit graph

249 commits

Author SHA1 Message Date
Josh Gao
d594359e7f Merge "adbd: avoid starting multiple worker threads." am: 5ddd49eeae
am: dcfc785d20

Change-Id: Id5fbaba786214b2d5b9dcab7f433ce12f850d35d
2019-05-02 14:33:26 -07:00
Josh Gao
910ce0ff08 adbd: avoid starting multiple worker threads.
A previous patch intended to make receiving multiple FUNCTIONFS_ENABLEs
non-fatal, but failed to do so because we would try to spawn another
worker thread and hit a different assertion.

Bug: http://b/130638368
Test: echo mem | adb shell "su 0 sh -c 'cat > /sys/power/state'"
Change-Id: I53456112244d8b4f7d26df6ec6961389fca70498
2019-05-01 17:27:27 -07:00
Ian Kasprzak
19187f1bfc Merge "Revert "Add a way to turn off unique_fd's operator int."" am: e30fe5fe89
am: e285dbeae3

Change-Id: I8a4911e8b6970c3b0defef66dc109358ff2d6748
2019-04-25 10:30:15 -07:00
Ian Kasprzak
e30fe5fe89 Merge "Revert "Add a way to turn off unique_fd's operator int."" 2019-04-25 17:16:55 +00: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
ed0033b4c0 Merge "adbd: reduce queue depths." am: 0fcd9292c4
am: 1c6d4f3663

Change-Id: I95bc10b35cf00f02833978d762c21be4b8e9b5e2
2019-04-24 18:29:59 -07:00
Josh Gao
0fcd9292c4 Merge "adbd: reduce queue depths." 2019-04-25 01:09:23 +00:00
Josh Gao
8c856f3e10 Merge "Add a way to turn off unique_fd's operator int." am: 971bae0bcf
am: 7653723999

Change-Id: I06811b1e5ff3d45e4b0490bf00d1608bdf1ce1c4
2019-04-24 16:07:09 -07:00
Josh Gao
28293f16a8 adbd: reduce queue depths.
Each operation we submit results in a contiguous allocation in the
kernel which can trigger OOM-killing. Tune the queue depths to reduce
the chances of this happening, with a minimal impact on performance.

Bug: http://b/126582877
Test: ./benchmark_device.py with blueline
Change-Id: I4b0f83d54a9a9a69f0ab48322d78fb137c94dd35
2019-04-24 15:05:21 -07: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
039cc7d1f8 Merge "adbd: reduce the USB buffer sizes to 16k." am: f05fbe6957
am: 949a903ff5

Change-Id: I887c8b43ac51eef60b5d0ec2a489277ad8a0c092
2019-04-17 16:15:35 -07:00
Josh Gao
770a6a4d46 adbd: reduce the USB buffer sizes to 16k.
Some USB controllers only support 16k writes, so drop down to that.

Bug: http://b/130622010
Test: treehugger
Change-Id: I836d5b2d0d6fcae05f290af11a6a19c6e8d7c1ba
2019-04-16 15:14:24 -07:00
Alex Buynytskyy
88f48b125a Merge "Binding err to inout for raw protocol for in-process execute." am: 265af10e6e
am: 4daf72da7a

Change-Id: I38919f3b0c01590ba4a80beef7a1cf5e34e3a298
2019-04-09 12:28:14 -07:00
Alex Buynytskyy
704c97d6c2 Binding err to inout for raw protocol for in-process execute.
As raw protocol does not allow for splitting err - it has to be redirected to inout.
Before this change it was not done for in-process and all err data was lost.

Bug: 130086616
Test: manual + atest adbd_test
Change-Id: I6cd11c940673d73e2993a6eb23c46d31bd8bf504
2019-04-08 19:16:05 -07:00
Josh Gao
804ffede3e Merge "adbd: demote CHECKs to warning logs." am: 16f4a033c3 am: 887e8f4bfd
am: 8cecb02a2c

Change-Id: Id2ab6435ad2953cd4bb6348fc5166a07a598832f
2019-04-02 15:27:18 -07:00
Josh Gao
87afd52fb5 adbd: demote CHECKs to warning logs.
It seems like we don't actually always get these events in order, so
demote them to a log and restart the connection instead of aborting.

Bug: http://b/129464137
Test: mma
Change-Id: I7dffbf62f9dea665cf9f9f9e1bd18d444b6905ec
2019-04-02 10:56:07 -07:00
Josh Gao
73a9681319 Merge "adb: make adb reconnect perform a USB reset." am: 3b25a17a8a am: 0d9d5ef1bb
am: e5a5a5b18f

Change-Id: If54f9d0b4c8a003ab7cd5557a4d0b0a48fc3654d
2019-04-01 15:34:48 -07:00
Josh Gao
3b25a17a8a Merge "adb: make adb reconnect perform a USB reset." 2019-04-01 21:42:57 +00:00
Josh Gao
3705b346b9 adb: make adb reconnect perform a USB reset.
Bug: http://b/128941083
Test: manual
Change-Id: Iaf46d2c46cc82b590768004486d119244591c8e2
2019-03-28 15:47:44 -07:00
Josh Gao
2a1fb09335 Merge "adbd: wait for FUNCTIONFS_BIND for up to a second, then retry." am: bfcb981b32 am: 80268fd592
am: 51ca488977

Change-Id: Ia4a29eedde07ea29b0a7650179330386ecf19af1
2019-03-28 14:02:31 -07:00
Josh Gao
19dc296305 adbd: wait for FUNCTIONFS_BIND for up to a second, then retry.
Occasionally, after we open the functionfs endpoint and write our
descriptors to it, we end up in a state where we never receive any
events from ep0, presumably due to a race against some other part of
the system, since adding sleeps reduces the likelihood. Add an
(arbitrarily chosen) timeout for the initial FUNCTIONFS_BIND we read,
and retry on failure.

Bug: http://b/128679787
Test: unplug and replug a blueline 14,000 times with a usb switch board
Change-Id: I4b3d5d552179ee7f3fefcc15f9575f793926f784
2019-03-27 18:04:45 +00:00
Greg Kaiser
e0a1be42cb Merge changes Ia84ed9ec,I1c0fde72 am: 10533c57ed am: b6bc0075f4
am: d095e07371

Change-Id: I85cb7c71f37565e220a16ea6f21548887ef8e20c
2019-03-26 18:17:41 -07:00
Josh Gao
3d26a86676 Merge changes I80af5f4b,I2fd0034e am: 2decb2fc3a am: c9a893c1eb
am: 448aed3c73

Change-Id: I783537a4b2ec10659c563b4461186d2230895e35
2019-03-26 18:08:11 -07:00
Treehugger Robot
10533c57ed Merge changes Ia84ed9ec,I1c0fde72
* changes:
  fastboot: Avoid extra std::string copies
  adb: Avoid extra std::string copies
2019-03-27 00:33:05 +00:00
Josh Gao
6933d54e09 adbd: listen to all functionfs events.
Monitor for FUNCTIONFS_UNBIND as well, so that in the case where we get
FUNCTIONFS_BIND, FUNCTIONFS_UNBIND, FUNCTIONFS_BIND, we don't trigger an
assertion failure from seeing two FUNCTIONFS_BINDs.

Bug: http://b/129134256
Test: manual
Change-Id: I80af5f4b833513e932262638b9f8d76bbcb35504
2019-03-26 13:38:41 -07:00
Josh Gao
63b52ec13b adbd: increment writes_submitted_ before submitting writes.
If we fail to submit writes for some reason (e.g. the USB cable was
unplugged), another thread that's waiting on the write mutex can enter
SubmitWrites and attempt to resubmit the writes that we already failed
to submit, leading to a failed assertion of !IoBlock::pending.

Increment writes_submitted_ before actually calling io_submit, so we
skip over these writes and fall through to exit.

Bug: http://b/129134256
Test: manually unplugged a blueline
Change-Id: I2fd0034e45db22c8f637c81039ce686b7aa6a03b
2019-03-26 13:06:38 -07:00
Greg Kaiser
e2125fdeb1 adb: Avoid extra std::string copies
When a function argument takes a std::string, it's inefficient to
pass std::string::c_str(), since that creates an additional copy.
So we change these calling sites.

Test: TreeHugger
Change-Id: I1c0fde7275eb3ebd3baf05ec62581b0243655608
2019-03-26 12:00:19 -07:00
Josh Gao
f31a12aa71 Merge "adbd: support ro.adb.nonblocking_ffs." am: affe351420 am: c94cec6d9d
am: 1e43373c62

Change-Id: Icdafb535240608d0e7ba927583c79199ef78747a
2019-03-19 13:10:35 -07:00
Josh Gao
affe351420 Merge "adbd: support ro.adb.nonblocking_ffs." 2019-03-19 19:44:00 +00:00
Josh Gao
c57206a541 Merge "adb: fix uninitialized variable." am: 588a87d68e am: 966b39b34c
am: 4ba1491a38

Change-Id: I5765725c70d659e73b5b852cad0095a9d0d52522
2019-03-18 20:49:51 -07:00
Josh Gao
8038e35fdf adbd: support ro.adb.nonblocking_ffs.
Allow disabling ro.adb.nonblocking_ffs via an ro system property, which
gets overridden by the currently supported persist.adb.nonblocking_ffs.

Bug: http://b/128679787
Test: mma
Change-Id: I28891d2da129e9654bf63ab8a4c330c4d2f5b336
2019-03-18 17:59:24 -07:00
Josh Gao
b019574476 adb: fix uninitialized variable.
Previously, we were initializing IoBlock::pending when submitting a read,
but leaving it uninitialized when doing a write, which would sometimes
result in an assertion firing when we received a previously allocated
block of memory that happened to have a nonzero value in pending.

Test: treehugger
Change-Id: I434c65f554ceed313fea9cfcc98788908f3ca8bc
2019-03-18 17:12:19 -07:00
Jiyong Park
c9a07bcbb4 Revert "Handle adb sync with Bionic under /bionic" am: fc97d2a116 am: 8b9fa0a44d
am: ebe1460df5

Change-Id: I24a5a49a8cd894b93664c65b76534db614d891e2
2019-03-15 02:43:37 -07:00
Jiyong Park
8b9fa0a44d Revert "Handle adb sync with Bionic under /bionic"
am: fc97d2a116

Change-Id: I8c8780f0009795d281b93efa691791427402ef45
2019-03-15 02:18:42 -07:00
Treehugger Robot
4cd0914048 Merge changes from topic "apex_earlymount_no_bionic_bindmount"
* changes:
  /bionic path is gone
  Revert "Handle adb sync with Bionic under /bionic"
  Don't bind-mount bionic files
2019-03-15 09:02:18 +00:00
Bowgo Tsai
76f9dc6f31 Merge changes from topic "adb_root_in_user" am: da1251d6a5 am: ac5d9460f2
am: c613c0d130

Change-Id: I46e9d64a103c7a983d908e7b6f131332aafe1b72
2019-03-14 22:05:05 -07:00
Bowgo Tsai
9b30c0a7e6 adbd: allowing adb root when the device is unlocked
As there is no security guarantee when the device is unlocked,
allowing adb root gives us more rooms to debug a USER build images.

Also, this makes it possible to run VTS on a USER build GSI, with
setting ro.debuggable=1 and unlocking the device.

This basically re-lands a reverted change:
https://android-review.googlesource.com/c/platform/system/core/+/437815

Which isn't needed after we moved /sbin/adbd to /system/bin/adbd in
USERDEBUG GSI. But it's still needed for USER build GSI.

Bug: 126493225
Test: unlock a USER build device, check 'adb root' can work
Change-Id: I93f12c8a3fe65c96c947e4602795eadfe591c521
2019-03-15 03:04:46 +08:00
Jiyong Park
fc97d2a116 Revert "Handle adb sync with Bionic under /bionic"
This reverts commit 7c7189c469.

Bug: 125549215
Test: system/core/fs_mgr/tests/adb-remount-test.sh
Change-Id: I4ee40cda9c3b94b116dc822c7b9736cfe2c9c9f0
2019-03-14 07:35:54 +09:00
Josh Gao
2986dd4dfc Merge "adbd: properly handle FUNCTIONFS_BIND without ENABLE." am: 22ff8e1909 am: b90db0840a
am: 313d214ec0

Change-Id: I63965d5bf49bdf63383bdd6aaac703c06fab5179
2019-03-11 17:15:56 -07:00
Josh Gao
007a4dc7a6 adbd: properly handle FUNCTIONFS_BIND without ENABLE.
If a device is unplugged, a BIND will happen without an ENABLE until the
device is plugged in, which would previously result in adbd crashing
every 5 seconds due to an attempt to join a thread that hadn't been
started.

Bug: http://b/128255355
Test: manually observed adbd via serial cable while unplugged
Change-Id: I90d6384e7e829df1ffaf73a95f2418a2ff97fb03
2019-03-11 13:06:17 -07:00
Josh Gao
b1aa106e44 Merge "Revert "Revert "adbd: switch the default USB implementation.""" am: f97193d96f am: d9e3421558
am: 3fafb971d9

Change-Id: Ie98d0d8b581fb53d0e7ecc64f55744fa851e3174
2019-03-07 21:14:18 -08:00
Treehugger Robot
f97193d96f Merge "Revert "Revert "adbd: switch the default USB implementation.""" 2019-03-08 03:29:41 +00:00
Josh Gao
2d918cde58 Merge "adbd: cleanups in remount/verity." am: 98efc485de am: d659bb49be
am: b7dc01a570

Change-Id: Ia1f05becfdbba49606fb9bd47123e81c73d55e97
2019-03-06 18:46:04 -08:00
Josh Gao
3ed90b75da adbd: cleanups in remount/verity.
1. Don't clear O_CLOEXEC on an fd we're duping to stdin/out/err: dup2
   does that for us if oldfd != newfd, and we know the fd can't be
   stdin/out/err.
2. Use unique_fd.
3. Remove gotos by breaking the remount logic into its own function.

Test: mma
Change-Id: If9929e7f20de445322fd498e1379a2d4e572cb52
2019-03-06 13:03:30 -08:00
Mark Salyzyn
2085759c6d Merge "adb: use /system/bin/remount command" am: d458066bc7 am: bc0887add7
am: be17923ece

Change-Id: Iaf7574caa4b4ee23acc864d7eeaf3a095394c215
2019-03-04 14:51:39 -08:00
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
291f29613c Merge "adbd: fix a case where we can fail to join a thread." am: b530537d46 am: ace5a7c799
am: ee76606206

Change-Id: Ic09c38e919a1d1d12308504b4cbe2d388b94c42d
2019-03-01 02:30:19 -08:00
Josh Gao
b67e5cd91d Merge changes I4d351f56,Ib9e91157 am: 7669ea5a44 am: 68f136b407
am: a7140a1222

Change-Id: I403b2d6c59dcc16a8853ffccdc40eba5984699f4
2019-03-01 02:29:03 -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