Commit graph

2369 commits

Author SHA1 Message Date
Josh Gao
18e944f1f7 Merge "adb: fix darwin build break." am: a0661237e1 am: 8016a0aa11 am: 40866ccfc0
am: 3521f70220

Change-Id: Ie93c0c172346bec1a07ea8e604ca23e5453840d6
2017-05-10 23:39:04 +00:00
Josh Gao
7132752306 Merge changes I394f5782,I9475f5d0,I59707186 am: 44f6592b0d am: b7f3707cd3 am: 75f0275fba
am: 9deb8140bf

Change-Id: Icfca230b2efb39332a2627192ff8610f532dae4c
2017-05-10 23:38:35 +00:00
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
Josh Gao
362b4041f3 adb: fix darwin build break.
Fix the following build breakage:

    system/core/adb/client/usb_osx.cpp:433:13: error: static declaration of 'usb_cleanup' follows non-static declaration
    static void usb_cleanup() NO_THREAD_SAFETY_ANALYSIS {
                ^
    system/core/adb/usb.h:48:5: note: previous declaration is here
        ADB_USB_INTERFACE(native::usb_handle*);

Bug: http://b/38203892
Test: mma on linux, darwin
Change-Id: I1c042e4d64ddcc0713f329202bc2037e590a9b4f
2017-05-10 13:58:51 -07:00
Josh Gao
44f6592b0d Merge changes I394f5782,I9475f5d0,I59707186
* changes:
  adb: move all cleanup to a function with defined ordering.
  adb: make `adb kill-server` wait for the server to die.
  adb: libusb: replace sleep with timed CV wait.
2017-05-10 18:42:14 +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
Josh Gao
01b7bc43e9 adb: move all cleanup to a function with defined ordering.
We want to explicitly define the order in which we teardown adb, so
move all of the at_quick_exits sprinkled throughout into one function
containing all of the cleanup functions.

Bug: http://b/37104408
Test: adb kill-server; adb start-server
Change-Id: I394f5782eb147e394d4b87df1ba364c061de4b90
2017-05-09 14:32:47 -07:00
Josh Gao
b3c14ec693 adb: make adb kill-server wait for the server to die.
Make the host:kill service shutdown its socket on process exit, instead
of immediately. Also, unify the two 'kill-server' implementations and
hide _adb_connect.

Bug: http://b/37104408
Test: adb kill-server; adb start-server
Change-Id: I9475f5d084d5fb91d33e393f2fd4e34056613384
2017-05-09 14:31:15 -07:00
Josh Gao
707a6e469f adb: libusb: replace sleep with timed CV wait.
Instead of sleeping for 500ms at the end of every device poll loop, use
a timed condition variable wait so that we can tell the device poll
thread to immediately commit suicide.

Bug: http://b/37869663
Test: adb kill-server; adb start-server
Change-Id: I597071866f7d9ef91900411727345d32c1a97556
2017-05-09 14:30:13 -07: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