Commit graph

2362 commits

Author SHA1 Message Date
Elliott Hughes
cf4289550c Merge "Fix style nits in adb's Android.mk." am: 30b7f59efc am: 86698112b9 am: eba1d8338f
am: 94ed60471d

Change-Id: Idb4e5a160bbab50919e5a1b053a0d0f43fce8e28
2017-05-10 23:38:06 +00:00
Elliott Hughes
bca78df5a4 Merge "Fix build error when (ADB|FASTBOOT)_VERSION has space" am: 3d29736d6b am: f2f3c3b91c am: 8ff4dbe443
am: cd81886b94

Change-Id: Icd8b12444f496c177d5aedcae624a2662c5e960c
2017-05-10 17:01:50 +00:00
Elliott Hughes
8964fbfa5f Fix style nits in adb's Android.mk.
We [try to] always use trailing \s in lists.

Bug: N/A
Test: builds
Change-Id: Ibc1ccacbe8a31f784f206d29a8c4f0f4650f7bde
2017-05-10 08:41:50 -07:00
SzuWei Lin
b3526e1ee8 Fix build error when (ADB|FASTBOOT)_VERSION has space
Test: make, and build pass
Change-Id: I8fc608a5b8bccb43b8af72978ce16a945147f62d
2017-05-10 18:52:02 +08:00
Elliott Hughes
aeb2a10daa Merge "Show the "platform tools" version in adb/fastboot --version." am: 6f4d47438d am: 3602f6141a am: 92764e2cb2
am: 3a92b606b5

Change-Id: Ic492a698b54e7195984ba733b9e5bf8542c1c2ee
2017-05-10 03:20:42 +00:00
Treehugger Robot
6f4d47438d Merge "Show the "platform tools" version in adb/fastboot --version." 2017-05-10 01:41:41 +00:00
Elliott Hughes
4d4f64ff94 Show the "platform tools" version in adb/fastboot --version.
Annoyingly folks parse the "adb --version" output so we have the
less-interesting protocol version first. But at least now we'll
have the "real" version somewhere...

Bug: N/A
Test: "adb --version"/"fastboot --version"
Change-Id: Ia85b561bd8d84c6fd6995923730d36f53b2f800b
2017-05-09 08:21:54 -07:00
Josh Gao
ccbe13234c Merge "adb: properly handle libusb_clear_halt failure." am: 761ae04777 am: b44385f6b3 am: 9886b1aa4a
am: 59edd00124

Change-Id: I334822bc95ca9f2d41f491b059bbb17f63d7f913
2017-05-08 22:58:32 +00:00
Treehugger Robot
761ae04777 Merge "adb: properly handle libusb_clear_halt failure." 2017-05-08 22:44:34 +00:00
Josh Gao
8bf37d7a4d adb: properly handle libusb_clear_halt failure.
The original code used continue to attempt to try to skip the current
device, but there was an loop between the outside one and the continue.
Move the device handling logic into a function and replace continue
with return.

Test: mma
Change-Id: Iaa7f4b5ddc26d2ce03f1172d37d6307190b44412
2017-05-08 13:50:58 -07:00
Elliott Hughes
1bfaecf6a9 Merge "Give slightly less useless versions to adb and fastboot." am: ddfd5056a2 am: 77ca73f8a7 am: a2ce98d026
am: 0221e94d3e

Change-Id: I94b713bc3e1ce1e966763da89eb6c64aba4bca30
2017-05-06 05:37:16 +00:00
Elliott Hughes
ddfd5056a2 Merge "Give slightly less useless versions to adb and fastboot." 2017-05-06 05:24:49 +00:00
Elliott Hughes
74a7296879 Merge "Fix macOS build." am: 71feb7b321 am: dcbd2a1501 am: 666b616592
am: 4db76b1d69

Change-Id: I58146e8d725f96967a9db1e982823d9598773e8b
2017-05-06 01:18:55 +00:00
Elliott Hughes
2708a953d2 Give slightly less useless versions to adb and fastboot.
This will let us see (a) whether the user has a legit build or something they
built themselves and (b) what Android release it corresponds to.

This isn't as useful as showing what Platform Tools release we correspond to,
but I'm planning on doing that as a separate line.

Bug: N/A
Test: adb --version ; fastboot --version
Change-Id: Idca489295e3c6f8571146f95822c08808e36b382
2017-05-05 16:29:19 -07:00
Elliott Hughes
4acb36020b Fix macOS build.
system/core/adb/client/usb_libusb.cpp:162:20: error: unused function 'get_device_serial_path' [-Werror,-Wunused-function]
  static std::string get_device_serial_path(libusb_device* device) {
                     ^

Bug: N/A
Test: no choice but to submit and see...
Change-Id: I0026d3273891588c27df5ccd71c41ad9907b038d
2017-05-05 16:26:30 -07:00
Elliott Hughes
8cf938d1dd Merge "Improve udev failure diagnostics." am: 5ad9ba12df am: 94202c2b9d am: 1ad393daba
am: 9edecb4d62

Change-Id: I3b7e34d524f87f24da2a7b77f84e0144f3b92526
2017-05-05 22:40:39 +00:00
Elliott Hughes
cd35664cdc Improve udev failure diagnostics.
A couple of folks had trouble understanding the existing message.

Before:

  8XV7N15917000596	no permissions (udev requires plugdev group membership); see [http://developer.android.com/tools/device.html]

After:

  8XV7N15917000596	no permissions (user buttmunch is not in the plugdev group); see [http://developer.android.com/tools/device.html]

This also fixes a libusb regression where we wouldn't show anything for
devices where we don't have permissions.

Bug: http://b/37707122
Test: ran "adb devices" as user buttmunch
Change-Id: I2fcd735ff4178145432b532a6e4dc8c93b2743fd
2017-05-05 12:50:16 -07:00
Josh Gao
d7c9fa39c2 Merge changes from topic 'adb_thread_safety' am: 9083ff1c24 am: 2ca23fa508 am: 05b7443644
am: 577c2172d1

Change-Id: I1d384220c6eea9cb3066a8cbe86298543bde574a
2017-05-05 00:23:10 +00:00
Josh Gao
09e163e96b Merge "adb: make darwin build with thread safety analysis." am: 971e6585a6 am: b80ef5e6fd am: 5e0b56adfa
am: fcfa8731c3

Change-Id: I1246b35a5bb2fc3c3f48995b3a00bc2de7e8b499
2017-05-04 23:22:35 +00:00
Josh Gao
fd713e53e8 adb: wait for devices to come up instead of sleeping for 3s.
Replace a hard-coded 3 second sleep with logic to wait until we've
scanned USB devices once and they've all come online.

Before:
    adb shell true  0.00s user 0.00s system 0% cpu 3.047 total

After:
    adb shell true  0.00s user 0.00s system 9% cpu 0.041 total

Bug: http://b/37869663
Test: `time adb shell true` after adb kill-server
Change-Id: I251d42afb885908ed9d03167287594ea16650d3f
2017-05-04 16:03:12 -07:00
Josh Gao
04a8218f09 adb: make darwin build with thread safety analysis.
Test: mma on darwin
Change-Id: I44dfc53fc381e60de83f3bc503691cdb8179ca91
2017-05-04 16:03:12 -07:00
Josh Gao
6f46e6b912 adb: initialize mDNS asynchronously.
Use fdevent_run_on_main_thread to initialize mDNS in a thread and
register an fdevent from the main thread upon success.

This reduces the startup time of `adb server` by ~3 seconds when mDNS
can't be successfully started. With an already running adb server,
`time adb server nodaemon` goes from:

    adb server nodaemon  0.00s user 0.16s system 4% cpu 3.817 total

to:

    adb server nodaemon  0.00s user 0.01s system 1% cpu 0.665 total

Bug: http://b/37869663
Test: `adb server nodaemon` with an existing adb server
Change-Id: Ia5a1a2a138610f3bf6792400050ca68f95ae3734
2017-05-04 16:03:12 -07:00
Josh Gao
4c936397c1 adb: add fdevent_run_on_main_thread.
Add a function to run a function on the main thread, to allow fdevents
that depend on a blocking function to be registered.

Bug: http://b/37869663
Test: adb_test on linux
Change-Id: I84a0b372360420b7647057297b8f437e8afa874e
2017-05-04 16:03:12 -07:00
Josh Gao
d25638cd51 Merge "adb: use the actual wMaxPacketSize for usb endpoints." am: c7988b1f68 am: ff9d6425d4 am: 44190c3709
am: 439f523d0c

Change-Id: I44cd780ef9afc65ba793cbf2c1276f8ce2605d7b
2017-05-04 00:55:11 +00:00
Josh Gao
c7988b1f68 Merge "adb: use the actual wMaxPacketSize for usb endpoints." 2017-05-04 00:12:23 +00:00
Josh Gao
3c82f122e7 Merge "adb: enable -Wthread-safety on linux/darwin." am: 2983d2710e am: 0c91897714 am: d3f512ebe3
am: 425d0db555

Change-Id: If252edb1d239ed4ab507c17526ab53bf6f7292d5
2017-05-03 23:52:36 +00:00
Josh Gao
2983d2710e Merge "adb: enable -Wthread-safety on linux/darwin." 2017-05-03 23:38:59 +00:00
Josh Gao
68f679c35b adb: enable -Wthread-safety on linux/darwin.
Delete the sysdeps/mutex tests that -Wthread-safety complains about.
We're using the standard library's std::mutex on all platforms now,
anyway.

Test: mma
Change-Id: I3bf958c72604b29dfb1d9c898d3c9aa34aed2685
2017-05-03 14:28:21 -07:00
Josh Gao
ef3d343254 adb: use the actual wMaxPacketSize for usb endpoints.
Previously, adb was assuming a fixed maximum packet size of 1024 bytes
(the value for an endpoint connected via USB 3.0). When connected to an
endpoint that has an actual maximum packet size of 512 bytes (i.e.
every single device over USB 2.0), the following could occur:

    device sends amessage with 512 byte payload
    client reads amessage
    client tries to read payload with a length of 1024

In this scenario, the kernel will block, waiting for an additional
packet which won't arrive until something else gets sent across the
wire, which will result in the previous read failing, and the new
packet being dropped.

Bug: http://b/37783561
Test: python test_device.py on linux/darwin, with native/libusb
Change-Id: I556f5344945e22dd1533b076f662a97eea24628e
2017-05-03 12:32:39 -07:00
Felipe Leme
0bd23c900f Merge "Don't display bugreport progress when it recedes, for real..." am: 499af38623 am: 35d7f65654 am: eed955d7c6
am: 378c2a0c4f

Change-Id: I2f29e46d55988e61def72e661c48c770386115fc
2017-05-03 15:36:05 +00:00
Treehugger Robot
499af38623 Merge "Don't display bugreport progress when it recedes, for real..." 2017-05-03 15:21:26 +00:00
Elliott Hughes
4df2bc7e8c Merge "Improve "adb sideload" error reporting." am: 66b25eb810 am: f2fe436d32 am: 2b0d807531
am: df3dc783af

Change-Id: I2d6489d7613acc4331f71e9c6199ef979e169d05
2017-05-03 01:04:09 +00:00
Elliott Hughes
66b25eb810 Merge "Improve "adb sideload" error reporting." 2017-05-03 00:51:09 +00:00
Elliott Hughes
09e794c05d Improve "adb sideload" error reporting.
Rather than quietly fall through to the legacy code with no explanation,
say why the first connection failed, and that the second attempt is only
going to be relevant for folks trying to sideload to a pre-KitKit device.

Before:

  $ adb sideload mysid-ota-424425.zip
  opening 'mysid-ota-424425.zip'...
  connecting...
  falling back to older sideload method...
  error: closed

After:

  $ adb sideload mysid-ota-424425.zip
  adb: sideload connection failed: no devices/emulators found
  adb: trying pre-KitKat sideload method...
  adb: pre-KitKat sideload connection failed: no devices/emulators found

Also switch the legacy code to just read+write blocks rather than trying to
load the whole OTA package into RAM (which is in short supply on Win32).
This is probably of no practical use other than that it lets us report a
better error message (better than "terminate called after throwing an
instance of 'std::bad_alloc'").

Bug: https://issuetracker.google.com/37139736
Test: "adb sideload" with no device/a mysid/an angler
Change-Id: Ia568044aac61bd054301ebfd7fcd5ad5d6f3147a
2017-05-02 14:41:04 -07:00
Felipe Leme
4cc03611cd Don't display bugreport progress when it recedes, for real...
The previous fix was taking account just the progress reported by dumpstate,
not progress/percentage. As such, it was not detecting the cases where the
percentage decreased but the progress didn't.

Bug: 37878670
Test: m -j32 adb_test && ./out/host/linux-x86/nativetest64/adb_test/adb_test --gtest_filter=BugreportTest.*

Change-Id: I5830028f3191a9b17f63aeed5c049b29fa7d1179
2017-05-02 10:08:39 -07:00
David Zeuthen
c8d19a571f Merge "adb: Support 'adb enable/disable-verity' when using AVB." am: 8fc6cc8910 am: 2b3a568171 am: 1855c98ac2
am: c14134bf1b

Change-Id: I749a17bb9db825e73e116b27a52a109cbef4e546
2017-05-02 16:07:26 +00:00
David Zeuthen
1e033d6804 adb: Support 'adb enable/disable-verity' when using AVB.
Link with libavb_user and use this to enable/disable dm-verity if AVB
is in use.

Bug: 34124301
Test: Manually tested.
Change-Id: Ic03651312b955081cb3c126f6dafc46d6eeec0da
2017-05-02 09:39:55 -04:00
Elliott Hughes
23da485530 Merge "Stop writing NUL bytes in adbkey.pub." am: d340c1ebbe am: 68c9642a9d am: a404e8ffe8
am: 5ccb3b97b6

Change-Id: I103bf495648b4a003677969ff7bbd1aae1f7ad4f
2017-05-02 01:04:57 +00:00
Treehugger Robot
d340c1ebbe Merge "Stop writing NUL bytes in adbkey.pub." 2017-05-02 00:51:48 +00:00
Elliott Hughes
0b771b33fd Stop writing NUL bytes in adbkey.pub.
In N we moved some code from C to C++ without realizing that EVP_EncodedLength
includes space for a terminating NUL and EVP_EncodeBlock writes one. Because
our key reading code copes with the NUL, we never noticed.

Distinguish between the required space returned by EVP_EncodedLength and the
actual number of bytes (not including NUL) used return by EVP_EncodeBlock.

Bug: http://b/36187819
Test: hexdump of ~/.android/adbkey.pub
Change-Id: I81a487ddbb5c884593b6426d1f41cfaece26ff90
2017-05-01 16:05:16 -07:00
Elliott Hughes
7e05467050 Merge "Simplify "adb sync" documentation." am: 05eed13247 am: 893a3c4468 am: 4942d4a8cc
am: e856654357

Change-Id: Id513f4cc42dda438ce0f3c51d0387e98f9102e8a
2017-05-01 21:04:07 +00:00
Elliott Hughes
0754cb929c Simplify "adb sync" documentation.
Remove -p (which only applied to "adb sync"), explicitly mention
$ANDROID_PRODUCT_OUT in the "adb sync" help text, and add "adb sync all"
as a synonym for "adb sync" for ease of documentation.

Bug: http://b/33761074
Test: "adb sync" still works, "adb --help" looks good
Change-Id: Ie5b2459a7e5e4140298f78815be25fa7c7bb47d0
2017-05-01 11:04:31 -07:00
Jerry Zhang
91fc4fd245 Merge "Revert "adb: Lower EP_ALLOC retry count"" am: 169590c47f am: 935d600800 am: ddcc232493
am: d3632d3ce1

Change-Id: I2d9698c24d9e03e812fd5d48c7bdfdcfcd1c2c33
2017-04-28 03:37:12 +00:00
Jerry Zhang
40a8778491 Revert "adb: Lower EP_ALLOC retry count"
This reverts commit 05fe272a87.

Commit "adb: Do not signal gaget stack unless descriptors are written"
fixed the main issue for configfs devices where device wasn't enabled
until after the ioctl was attempted. Thus it is safe to bring up the
retry count so that the ioctl doesn't fail due to small delays in
usb stack.

Test: use adb, switch configs on configfs devices
2017-04-27 15:00:13 -07:00
Yabin Cui
1810d58e35 Merge "adb: fix two device offline problems." am: 2e821078e4 am: ae6a3605d2 am: 66cfd45a34
am: c4a1393a15

Change-Id: Ice92131cda4d9f421f0f62058a3867a918044d84
2017-04-20 19:57:10 +00:00
Treehugger Robot
2e821078e4 Merge "adb: fix two device offline problems." 2017-04-20 19:45:18 +00:00
Yabin Cui
b5e11415d9 adb: fix two device offline problems.
When device goes offline, user usually has to manually replug the
usb device. This patch tries to solve two offline situations, all
because when adb on host is killed, the adbd on device is not notified.

1. When adb server is killed while pushing a large file to device,
the device is still reading the unfinished large message. So the
device thinks of the CNXN message as part of the previous unfinished
message, so it doesn't reply and the device is in offline state.

The solution is to add a write_msg_lock in atransport struct. And it
kicks the transport only after sending a whole message. By kicking
all transports before exit, we ensure that we don't write part of
a message to any device. So next time we start adb server, the device
should be waiting for a new message.

2. When adb server is killed while pulling a large file from device,
the device is still trying to send the unfinished large message. So
adb on host usually reads data with EOVERFLOW error. This is because
adb on host is reading less than one packet sent from device.

The solution is to use buffered read on host. The max packet size
of bulk transactions in USB 3.0 is 1024 bytes. By preparing an at least
1024 bytes buffer when reading, EOVERFLOW no longer occurs. And teach
adb host to ignore wrong messages.

To be safe, this patch doesn't change any logic on device.

Bug: http://b/32952319
Test: run python -m unittest -q test_device.DeviceOfflineTest
Test: on linux/mac/windows with bullhead, ryu.
Change-Id: Ib149d30028a62a6f03857b8a95ab5a1d6e9b9c4e
2017-04-20 10:14:59 -07:00
Elliott Hughes
6ff8689e32 Merge "Fix various adb error reporting bugs." am: 8dead17a58 am: e6b808ea5b am: 38ed0537be
am: 1b50735ed4

Change-Id: Iaab2bb3a83664634bac3392eb17d50e50b690e47
2017-04-20 01:20:48 +00:00
Elliott Hughes
1fc8f6e0cf Fix various adb error reporting bugs.
`adb install` was writing success to stderr rather than stdout.

Server mismatch messages were going to stdout rather than stderr.

Error messages should consistently start with a lower case letter.

Also improve consistency of syntax error reporting.

Bug: https://issuetracker.google.com/37128706 (adb install success to stdout)
Bug: https://issuetracker.google.com/37140458 (server mismatch on stderr)
Bug: http://b/32413861 (consistency)
Test: ran tests
Change-Id: I0d6cb0c7482bec03483dacefd996644b7a28d273
2017-04-18 14:51:27 -07:00
Steven Moreland
7ad4868835 Merge "libcutils: compile with BOARD_VNDK_VERSION current" into oc-dev am: 64639fd7dc
am: fc5d4345fa

Change-Id: I9673d2afe656b558a98b83d138ea867a39b51a18
2017-04-17 23:34:52 +00:00