Commit graph

3548 commits

Author SHA1 Message Date
Josh Gao
a2929d5751 check_ms_os_desc: fix buffer overflow.
Bug: http://b/155505587
Test: check_ms_os_desc
Change-Id: Ie99715ab62571d24460c3a1fb859d22951f30cb8
2020-06-02 15:24:47 -07:00
Josh Gao
3f2f3bacf9 adb: don't use parameterized in test_adb.py.
The test bots don't have this module installed.

Test: treehugger
Change-Id: I849a075b784eac296608e45bec7b2fce38f56ac4
2020-06-02 13:14:45 -07:00
Treehugger Robot
4ea509e25d Merge "adb: only submit USB writes on the worker thread." 2020-05-20 23:34:37 +00:00
Josh Gao
962551000b adb: only submit USB writes on the worker thread.
After USB disconnection, io_submit will block until the endpoint comes
back up. We handle this in the worker thread by sending it a signal to
break it out of io_submit when we notice that USB has gone down, but
opportunistic writes from the main thread can get stuck in this scenario
as well. Submitting the writes only on the worker thread doesn't have a
measurable impact on performance, so avert this scenario by only
submitting writes from the worker thread.

Bug: http://b/157078255
Test: test_device.py
Change-Id: I1118f2e2a70d13f15592eb996e7084033ed5cb9d
2020-05-20 21:03:18 +00:00
Josh Gao
b27365510d Merge "adb: fix flakiness in PTY shell protocol." 2020-05-20 21:01:23 +00:00
Josh Gao
be41ae5666 adb: fix flakiness in PTY shell protocol.
When a subprocess closes its PTY slave, the master fd will report
POLLHUP when polled. This leads to us prematurely tearing everything
down, without reading out output that's been written to the PTY.

Resolve this by waiting until the fd no longer reports POLLIN.

Bug: http://b/156551485
Bug: http://b/156552734
Test: `adb shell 'X=0; while /data/nativetest64/adbd_test/adbd_test --gtest_filter="ShellServiceTest.*Pty*" >/dev/null 2>&1; do X=$((X+1)); echo $X; done'` for 1000 iterations (failed within 20, previously)
Test: test_device.py
Change-Id: Ie591e0cafb532cd6cebdf6f356dc967565b5a2d9
2020-05-19 20:54:40 -07:00
Josh Gao
8f83498cbd adb: fix abb test.
Don't hardcode cmd's output.

Bug: http://b/157092201
Test: python3 -m unittest test_device.AbbTest
Change-Id: I7145e8d2a31b1c1b459c1e55af3670b95e653eee
2020-05-19 20:12:52 -07:00
Alex Buynytskyy
a64d4f81a4 Optimizing install-multi-package to use ABB.
Bug: 150803885
Test: atest adb_test adbd_test
Test: adb install-multi-package Picsart_9.30.5.apk Pinterest_6.54.0.apk
Change-Id: I2fcd093e61afdd16d481194e1d5f8f66acf6a66c
2020-05-19 04:29:34 +00:00
Alex Buynytskyy
c06d01e2d9 Incremental install mode for install-multi.
Bug: 150803885
Test: atest adb_test adbd_test fastdeploy_test
Change-Id: I242104267273bac21ab41390d3e77a434ffa565d
2020-05-19 04:29:27 +00:00
Joshua Duong
7ce4a267f5 Merge changes from topic "adb-mdns"
* changes:
  adb pair: allow passing password as command-line argument.
  Change adb auto-connect to use mdns instance name.
  'adb pair' by mdns instance name.
  'adb connect' by mDNS service name.
  Add mDNS service instance name parser.
2020-05-19 00:30:06 +00:00
Joshua Duong
dcba5c9257 adb pair: allow passing password as command-line argument.
Bug: 155194845

Test: adb pair <host>
Test: adb pair <host> <pairing code>
Change-Id: I9813b5812a98524109a4c90cb089eab652da06fa
2020-05-18 14:24:10 -07:00
Joshua Duong
04d207d315 Change adb auto-connect to use mdns instance name.
This change will fix reconnects when the ip address and port changes for
the same mdns instance name.

Bug: 152886765

Test: 'adb pair <mdns_instance>' and wait for auto-connect.
'adb devices' | grep <mdns_instance
On device, toggle wireless debugging off/on. Client should be able to
reconnect with the different port.

Change-Id: I9ad486534019ee70fb54c9f26ce028951eca8566
2020-05-18 14:23:01 -07:00
Joshua Duong
beac509301 'adb pair' by mdns instance name.
Bug: 152886765

Test: Turn on wireless debugging > "Pair with Pairing Code". On client,
> adb pair <mdns_instance>

Change-Id: I8f15c3ea17f3ac02205064f64aca0167bf5d2ad5
2020-05-18 14:23:01 -07:00
Joshua Duong
7ebc595736 'adb connect' by mDNS service name.
Bug: 152886765

Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: test_adb.py

Change-Id: I7e93ceca7cdf913060bbc5afe824593a9922c6d9
2020-05-18 14:22:52 -07:00
Josh Gao
ec5aa591e8 adb: don't cache failure to get features.
When we're waiting for the device to show up (e.g. `adb logcat` with the
device not connected), we can transition from the feature set being
unavailable to being available.

Test: `adb logcat` with device disconnected
Change-Id: I5c93a725605c886cba2c66daa25b484c90a170ec
2020-05-15 16:22:31 -07:00
Alex Buynytskyy
04aa5bedcc Passing additional flags to incremental installation.
Bug: 150803885
Test: atest adb_test adbd_test fastdeploy_test
Change-Id: Ifa9b9e570259d35eb0121817bbb791044c6efcfd
2020-05-14 13:58:47 -07:00
Treehugger Robot
b6a6023bda Merge "Make some fdevent member functions pure virtual." 2020-05-13 03:31:03 +00:00
Elliott Hughes
e65e002102 Add a few more trivial socket_spec.h tests.
Also remove some dead code. The "missing port" case in
parse_tcp_socket_spec hasn't been meaningful since we put the default
port back.

Test: treehugger
Change-Id: I40958f0f1c2dd7f0315142c2c0363a70fe6f80fe
2020-05-12 16:38:11 -07:00
Elliott Hughes
631fe1e6df Make some fdevent member functions pure virtual.
...because that makes our coverage numbers look better. But since there
are only two concrete classes anyway, we weren't gaining much from the
default implementation and it's arguably more intention-revealing now.

Test: treehugger
Change-Id: I7a8a3195023048b1a84277358b857222692d96ee
2020-05-12 16:18:52 -07:00
Josh Gao
a227c19ef2 Merge changes Id8d9fa6c,I47d3ad50,I7cebbf75,Id10e320a
* changes:
  adbd: avoid compiling more code in the daemon.
  adb: don't run all of the tests again over TCP in coverage.
  adbd: respect ADB_TRACE on host adbd.
  adb: mark kMaxProcessNameLength as constexpr.
2020-05-12 05:32:48 +00:00
Treehugger Robot
8987016b1e Merge changes I24e70952,I652560ad
* changes:
  adb: use transport-id to make coverage script faster.
  adb: add `adb transport-id` command.
2020-05-12 02:22:27 +00:00
Treehugger Robot
1d77251d76 Merge "Remove unneeded optimize_for lite" 2020-05-11 23:49:29 +00:00
Joshua Duong
7be8519cdb Add mDNS service instance name parser.
This will be used for parsing user-provided names to 'adb connect' and
'adb pair' in order to check for matches in the mdns service registry.

Bug: 152886765

Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
--gtest_filter=mdns_utils*

Change-Id: Ifd74b4394212853c1c193a2ea64937f6a6a0ff24
2020-05-07 10:25:15 -07:00
Joshua Duong
2814928567 Merge "[adb client] Fix mdns discovery service registry." 2020-05-06 21:39:59 +00:00
Josh Gao
a11d27f920 adb: use transport-id to make coverage script faster.
Test: ./coverage/gen_coverage.sh
Change-Id: I24e70952946ad91d51acf9bda386826e4e73a0d2
2020-05-05 14:44:01 -07:00
Josh Gao
3441f232ab adb: add adb transport-id command.
Make it possible to safely script waiting for a device to go away after
root/unroot.

Test: manual
Change-Id: I652560ad1d88a5c6a1e8ea5787c3cf165c82aa63
2020-05-05 14:43:53 -07:00
Joshua Duong
077ac11106 [adb client] Fix mdns discovery service registry.
We were getting stale service ip addresses because we weren't
destroying the sdref correctly.

Also, we were leaking the ResolvedServices when removing it from the
ServiceRegistry. Converted them to smart pointers to fix that.

Bug: 153343580

Test: test_adb.py
Change-Id: Ib7c1dbf54937d4ac6d9885cb5f7289bef616d12e
2020-05-05 00:21:12 -07:00
Luca Stefani
9a3d868d3e Remove unneeded optimize_for lite
* It's already specified in the java_library definition

Test: m deployagent_lib, no warnings
Change-Id: I58fa9af71b8f817da55cfc040fbcbd80fd6425cf
2020-05-01 16:11:22 +02:00
Josh Gao
9f3064f26f adbd: avoid compiling more code in the daemon.
Strip out more code that has no meaning on device, to "improve"
coverage.

Test: test_device.py over TCP
Change-Id: Id8d9fa6cc6c6c30773f67303bcc89e6d60824700
2020-04-27 14:38:28 -07:00
Josh Gao
a786f0a857 adb: don't run all of the tests again over TCP in coverage.
They take forever, and we're only really interested in the transport
related code, so test that more directly.

Test: ./coverage/gen_coverage.sh
Change-Id: I47d3ad50db0f1020fe4b3da5cdfe455190d022b5
2020-04-27 14:38:28 -07:00
Josh Gao
ad18395b65 adbd: respect ADB_TRACE on host adbd.
Test: ADB_TRACE=1 adbd
Change-Id: I7cebbf7596add865fab95f5d6c746c0b8a16997a
2020-04-27 14:38:28 -07:00
Josh Gao
34cd60f075 adb: mark kMaxProcessNameLength as constexpr.
Otherwise, the build fails with -O0.

Test: mma with -O0 in adb_defaults
Change-Id: Id10e320afc183eda5b46555b3b50dd8ffd84a700
2020-04-27 14:38:28 -07:00
Jooyung Han
60985953bd Merge "Add min_sdk_version:R to updatable apexes" 2020-04-25 04:41:43 +00:00
Joshua Duong
3eea62432d Merge "[adb] Disable _adb._tcp. service auto-connect by default." 2020-04-24 05:38:22 +00:00
Treehugger Robot
abc40c7c5d Merge "Using ABB for install-multi." 2020-04-24 01:15:49 +00:00
Joshua Duong
2eedc2303b [adb] Disable _adb._tcp. service auto-connect by default.
Added ADB_MDNS_AUTO_CONNECT envionment variable to control which
services to allow auto-connect. By default, only _adb-tls-connect
services can auto-connect, since these services only auto-connect once
paired. _adb services will try to auto-connect to every service found.

Bug: 152636135

Test: ADB_TRACE=1 adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=adb adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=adb,adb-tls-connect adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=adb-tls-connect adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=0 adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=1 adb server nodaemon | grep whitelist

Change-Id: Ie562ea24fea3d6d96e67b376a0523b09e2778eb7
2020-04-23 16:55:52 -07:00
Alex Buynytskyy
a59e9b4e70 Using ABB for install-multi.
ABB uses single shared CMD for all operations which improves
reliability.

Bug: b/153486595
Test: atest adb_test adbd_test fastdeploy_test
Change-Id: I1e3da63882c980811ed2e9f5556732b24a041ce5
2020-04-23 16:30:49 -07:00
Josh Gao
0e778dc794 adb: allow filtering by file in coverage/show.sh.
Test: ./coverage.sh transport.cpp
Change-Id: I5fd3b25d9b3edd7a9131dae902e1868ced0384cc
2020-04-22 23:15:06 -07:00
Josh Gao
d5d5ba1644 adbd: don't use libc++_static.
We have dependencies that use libc++_shared, which results in ODR
violation manifesting as host adbd crashing on launch in libc++ locale
initialization.

Test: adbd on host
Change-Id: I6c039b325308fb8c36dfe5c1d090ff4ebe9e3433
2020-04-22 23:15:06 -07:00
Josh Gao
8a9277a243 adb: split transport_local.cpp into client/daemon.
Improve coverage some more.

Test: ./coverage/gen_coverage.sh && ./coverage/report.sh
Change-Id: I014d7ad25b2793d5d836ce5e526d657d46687ea4
2020-04-22 23:15:02 -07:00
Joshua Duong
13c639e0bb [adb client] Add "mdns services" command.
This command list all discovered mdns services, so we
can connect via service name later on.

Bug: 152521166

Test: 'adb mdns services'
Test: test_adb.py
Change-Id: I23d42a7933e67a65bd0c9924afd6abe5915c0a11
2020-04-22 08:43:15 -07:00
Joshua Duong
504d393176 [adb client] Add "adb mdns check" command.
This command will check if the mdns daemon is available on the host
machine.

Bug: 152510294

Test: pkill -9 mdnsd; adb mdns check; mdnsd; adb mdns check;
Test: test_adb.py
Change-Id: If644678a339763817a8a7adcbdc545626d161aba
2020-04-22 08:43:15 -07:00
Josh Gao
073c8d2394 adbd: improve coverage by compiling less code.
Test: ./coverage/gen_coverage.sh && ./coverage/report.sh
Change-Id: I26f823e2587435b7ec2c6ca05955adef5cfc23a0
2020-04-21 17:57:29 -07:00
Josh Gao
f099105f07 adb: refactor and relocate coverage script.
Test: ./coverage/gen_coverage.sh
Change-Id: Iaff2b1577e32ba4ec8647a418a2ff4a1e9a0835d
2020-04-21 17:57:19 -07:00
Josh Gao
79d4f148d6 adbd: test TCP in coverage.
Test: ./coverage.sh
Change-Id: I82a0d54fcc1e19585a27c2d049be40289bf15f60
2020-04-21 17:57:17 -07:00
Josh Gao
e3c62cc549 adb: allow wait-for-disconnect to match offline for TCP devices.
This fixes a bug in adb root/unroot where we always fail because we're
waiting for a TCP device to disappear.

Test: test_device.py over TCP
Change-Id: I7e4b6fdaa1070cee1f9b471de46ae00bf89b3089
2020-04-21 17:57:15 -07:00
Josh Gao
03bee48659 adbd: add unit tests to coverage report.
Test: ./coverage.sh
Change-Id: I268367b857efc2125c6714a1d0b0e874fa8d143d
2020-04-21 17:57:13 -07:00
Josh Gao
67095b28de Merge "adb: add helper binary to do a usb reset on a device." 2020-04-21 23:01:48 +00:00
Josh Gao
c0d8686053 adbd: add a script to generate coverage information.
Test: ./coverage.sh
Change-Id: I1a3608063e4c4e3af5ec01680f0255d8c69e7127
2020-04-20 17:37:50 -07:00
Josh Gao
98419f738b adbd: add a log message on start.
Make it easier to identify adbd's PIDs for coverage purposes by adding
an explicit log message to grep for.

Test: manual
Change-Id: I47e13417c0d9adb7d427414fd70c218f988909f5
2020-04-20 16:45:55 -07:00