Commit Graph

2435 Commits

Author SHA1 Message Date
Elliott Hughes 2e93eda69c Don't include the build number in the adbd binary.
We want repeatable builds for minimal OTAs.

Bug: http://b/64634017
Bug: 64709603 (presubmit balking at the line above)
Test: repeated builds after `touch daemon/main.cpp` keep same md5sum
Change-Id: Iedeb44377ea45bbf20e2212760802198a57dc14a
2017-08-15 20:07:04 +00:00
Josh Gao 60364171da Merge "adbd: add logging to troubleshoot usb issues." into oc-dr1-dev
am: 4ee59e0b51

Change-Id: I418023c78988508c72557f2c7572efa163a174ef
2017-07-27 15:34:59 +00:00
Josh Gao 8f484a6896 adbd: add logging to troubleshoot usb issues.
Bug: http://b/63899881
Bug: http://b/63901259
Bug: http://b/63904904
Test: treehugger
Change-Id: Ifbc3caa6b416093bf8e127194003747c910352dc
(cherry picked from commit 184f571cfd)
2017-07-27 00:34:31 -07:00
Bowgo Tsai 9679967dac Merge "adbd: lessen security constraints when the device is unlocked" am: e03665142e am: 0fe0ced23c
am: 620f6e65b3

Change-Id: I532c68a077019cbf133db5cbdcf967509415687b
2017-07-18 02:45:06 +00:00
Bowgo Tsai f1d3dbc32f adbd: lessen security constraints when the device is unlocked
ALLOW_ADBD_ROOT ('adb root') and ALLOW_ADBD_NO_AUTH (ro.adb.secure = 0)
are false in user build. This prevents a non-A/B device from running
Treble VTS because it requires 'adb root'. Without ALLOW_ADBD_NO_AUTH,
adb still can work if ro.adb.secure = 1. However, allowing it to be 0
is better for test automation.

The image combination in VTS is:
  - system.img (userdebug): provided by Googlg
  - boot.img (user): provided by the OEM  <-- adbd is here
  - vendor.img (user): provided by the OEM

This change allows 'adb root' and 'ro.adb.secure = 0' when the device is
unlocked in user build. No changes for userdebug/eng builds.

Note that the device must be unlocked when running VTS. Otherwise,
verified boot will prevent it from booting the system.img provided by
Google (no verity metadata).

Bug: 63313955
Bug: 63381692
Test: use the above image combination, check 'adb root' and
      'ro.adb.secure = 0' can work

Change-Id: I109d96c950e54c4fb0ac0c98b989a20593681e52
2017-07-18 08:41:19 +08:00
Josh Gao aabd9a09b5 Revert "adb: turn on libusb by default."
This reverts commit f2f0b31850.

libusb seems to be causing flakiness on some machines. Disable it for
now.

Bug: http://b/62962248
Test: python test_device.py (with DeviceOfflineTest commented out)
Change-Id: Ia9de78ab772c22574cf5ca7facb78f22af6d7a71
(cherry picked from commit 969110ca4a)
2017-06-29 11:22:55 -07:00
Dan Albert 6c95c3edcd Merge "Indicate that a packet was truncated." am: 046160959c am: e76c8020ba
am: c83ec67ec3

Change-Id: I61c12bc6fbcd205c2421831a64ffb783249a2222
2017-06-27 23:06:56 +00:00
Treehugger Robot 046160959c Merge "Indicate that a packet was truncated." 2017-06-27 22:50:48 +00:00
Dan Albert 9893f93950 Indicate that a packet was truncated.
Test: make checkbuild, check adb log
Bug: None
Change-Id: I0006ed284697f01966fdd79ca0b05dbc6d2eecf0
2017-06-27 13:26:14 -07:00
Josh Gao cb39742d3a Merge "Revert "adb: turn on libusb by default."" am: b22067677e am: de931dab2d
am: 947a301852

Change-Id: Ideabacf8cd79adaf6fb828874ac636ed88707240
2017-06-26 22:17:29 +00:00
Treehugger Robot b22067677e Merge "Revert "adb: turn on libusb by default."" 2017-06-26 21:33:34 +00:00
Josh Gao 969110ca4a Revert "adb: turn on libusb by default."
This reverts commit f2f0b31850.

libusb seems to be causing flakiness on some machines. Disable it for
now.

Bug: http://b/62962248
Test: python test_device.py (with DeviceOfflineTest commented out)
Change-Id: Ia9de78ab772c22574cf5ca7facb78f22af6d7a71
2017-06-26 13:17:58 -07:00
TreeHugger Robot b7806433bf Merge "adb: increase the shell command length limit." into oc-dr1-dev 2017-06-21 20:18:32 +00:00
Elliott Hughes b76034e755 Merge "Give a clear error message if we can't start the server." am: b6d3f28287 am: 1496863091
am: 07db226264

Change-Id: Ic2244ee02ca83ccdffcfbefac49797c2e4f7d459
2017-06-21 01:06:53 +00:00
Treehugger Robot b6d3f28287 Merge "Give a clear error message if we can't start the server." 2017-06-21 00:48:30 +00:00
Elliott Hughes 6eadee8607 Give a clear error message if we can't start the server.
Bug: http://b/35218713
Test: adb kill-server ; export HOME=/ ; adb devices
Change-Id: I53cc30213be0eab84e42b09c7b501362d6e44b05
2017-06-20 14:21:41 -07:00
Josh Gao 34abac7d36 adb: increase the shell command length limit.
Relax the shell command length limits when talking to an adbd with the
shell protocol.

shell is pretty much the only service that takes an arbitrarily long
string, so this is somewhat safe.

Bug: http://b/37716055
Test: `adb shell $(python -c 'print "echo " + "f" * (32*1024)') | wc` on L and master

Merged-In: I0737fd2244530ef8080f300cd3a3549a1ab93465
Change-Id: I0737fd2244530ef8080f300cd3a3549a1ab93465
2017-06-20 16:55:12 +00:00
Josh Gao d1f7fef69b adb: fix deadlock between transport_unref and usb_close.
Fix a deadlock that happened when a reader/writer thread released a
transport while the hotplug thread attempted  to handle a device
disconnection. Decrementing a transport refcount to zero would hold the
global transport mutex and attempt to take the usb handles mutex, while
the hotplug thread would hold the usb handles mutex and try to call
unregister_usb_transport, which would attempt to take the global
transport mutex.

Resolve this by making transport_unref not take the global transport
mutex.

Bug: http://b/62423753
Test: python test_device.py
Merged-In: Ib48b80a2091a254527f3a7d945b6a11fae61f937
Change-Id: Ib48b80a2091a254527f3a7d945b6a11fae61f937
(cherry picked from commit 7e197ef833)
2017-06-19 11:17:44 -07:00
Josh Gao 24e8e0d0d8 Merge "adb: increase the shell command length limit." am: 9d2e688b9a am: 749d2a0ab5
am: 3df484eeab

Change-Id: I90d845f1c2b6aa767a7c5540b25619724f3b2331
2017-06-17 22:10:31 +00:00
Treehugger Robot 9d2e688b9a Merge "adb: increase the shell command length limit." 2017-06-17 21:57:12 +00:00
Josh Gao a019f78141 adb: increase the shell command length limit.
Relax the shell command length limits when talking to an adbd with the
shell protocol.

shell is pretty much the only service that takes an arbitrarily long
string, so this is somewhat safe.

Bug: http://b/37716055
Test: `adb shell $(python -c 'print "echo " + "f" * (32*1024)') | wc` on L and master
Change-Id: I0737fd2244530ef8080f300cd3a3549a1ab93465
2017-06-16 18:01:11 -07:00
Josh Gao 7ff1e56f59 Merge "adb: fix deadlock between transport_unref and usb_close." am: 6f61a6d9c4 am: 2a8ce10cd8
am: 64523c01bd

Change-Id: I94128840430281a54c74cdfb2b35744b4730942f
2017-06-12 23:16:10 +00:00
Treehugger Robot 6f61a6d9c4 Merge "adb: fix deadlock between transport_unref and usb_close." 2017-06-12 23:03:55 +00:00
Nicolas Norvez c616a8ad84 Merge "adbd: optionally use qemud pipe without ro.kernel.qemu" am: b3c363f32c am: 516ee2445d
am: 6ff249f483

Change-Id: I7a5886b9a9c325036007ad9251b0952fdbd7a206
2017-06-12 21:53:42 +00:00
Nicolas Norvez 717f15353f adbd: optionally use qemud pipe without ro.kernel.qemu
adbd currently decides to use the QEMUD pipe if ro.kernel.qemu=1, as set
for ranchu. The Android container in Chrome OS doesn't have that
property set and it can't be set to 1 because it's used as equivalent to
"runs inside an emulator" throughout Android and changes the way
graphics are handled, whether Bluetooth is supported, etc., behaviour
that we do not want to trigger in Chrome OS.

adbd now also checks service.adb.transport to decide whether to use the
QEMUD (goldfish) pipe.
adbd still first checks for ro.kernel.qemu to preserve existing
behaviour and will still fallback to TCP if it can't use Goldfish.

Bug: 38497992
Test: tested by jmgao@ -thanks!- on aosp_angler, adb still works.

Change-Id: I8370704145ae7301ac7aeef81c5cbd94cfcb7fd7
2017-06-12 12:22:32 -07:00
Josh Gao 7e197ef833 adb: fix deadlock between transport_unref and usb_close.
Fix a deadlock that happened when a reader/writer thread released a
transport while the hotplug thread attempted  to handle a device
disconnection. Decrementing a transport refcount to zero would hold the
global transport mutex and attempt to take the usb handles mutex, while
the hotplug thread would hold the usb handles mutex and try to call
unregister_usb_transport, which would attempt to take the global
transport mutex.

Resolve this by making transport_unref not take the global transport
mutex.

Bug: http://b/62423753
Test: python test_device.py
Change-Id: Ib48b80a2091a254527f3a7d945b6a11fae61f937
2017-06-07 18:54:09 -07:00
Josh Gao 806ca1a1b0 Merge changes Id51dcb18,I2517dcb9 am: 4db472b779 am: aa3c3fc3be
am: 4b32a1f8b8

Change-Id: I9b9a5f594dd9a20bbf6dc2fead193433deb51942
2017-06-07 20:12:53 +00:00
Josh Gao fd79f01baf adb: libusb: switch from polling for accessibility to a sleep.
For unclear reasons, it seems that for some people, devices are
becoming accessible, inaccessible, and then inaccessible again.
Switch to a sleep for now.

Bug: http://b/62200735
Test: manual
Merged-In: Id51dcb188c3534a57c35cbfd30a181c99115a23c
Change-Id: Id51dcb188c3534a57c35cbfd30a181c99115a23c
(cherry picked from commit 5b8b10e078)
2017-06-07 11:29:21 -07:00
Josh Gao f74dd42e4e adb: improve race between device_connected and device_disconnected.
If a device is unplugged while it's being processed, we can be inside
register_usb_transport still when we call unregister_usb_transport,
leading to bad things happening. Move the call of
register_usb_transport into the scope guarded by usb_handles_mutex.

Bug: http://b/62200735
Test: manual
Merged-In: I2517dcb9d30d9a08cebbb5f715ae3fd30c510109
Change-Id: I2517dcb9d30d9a08cebbb5f715ae3fd30c510109
(cherry picked from commit 7dd382ded9)
2017-06-07 11:29:14 -07:00
Josh Gao 5b8b10e078 adb: libusb: switch from polling for accessibility to a sleep.
For unclear reasons, it seems that for some people, devices are
becoming accessible, inaccessible, and then inaccessible again.
Switch to a sleep for now.

Bug: http://b/62200735
Test: manual
Change-Id: Id51dcb188c3534a57c35cbfd30a181c99115a23c
2017-06-07 11:08:00 -07:00
Josh Gao 7dd382ded9 adb: improve race between device_connected and device_disconnected.
If a device is unplugged while it's being processed, we can be inside
register_usb_transport still when we call unregister_usb_transport,
leading to bad things happening. Move the call of
register_usb_transport into the scope guarded by usb_handles_mutex.

Bug: http://b/62200735
Test: manual
Change-Id: I2517dcb9d30d9a08cebbb5f715ae3fd30c510109
2017-06-07 11:06:53 -07:00
Josh Gao 8e2661eedc Merge changes I6c6bf61b,I3fb0b3a8 am: 3160a25010 am: 9d7880fe96 am: 14f749c2c4
am: 2d30a74181

Change-Id: I57a3916c312b8cc23c616232e84ad6c5507b5a39
2017-06-06 03:05:34 +00:00
Josh Gao 60b8c26520 adb: libusb: don't try to delete a usb_handle twice.
Previously, we would attempt to delete a usb_handle in both
device_disconnected and usb_close. If the one in device_disconnected
happened to happen first, usb_close would abort when it failed to find
the handle it was supposed to own.

Bug: http://b/62020217
Test: unplugging device on darwin
Change-Id: I6c6bf61bf89a4d9a23458c00b457080d3d6cc744
2017-06-05 15:11:53 -07:00
Josh Gao 664a618c06 adb: don't hold queue lock while performing callbacks.
Fix yet another source of deadlocks.

Bug: http://b/62020217
Test: unplugged device on darwin
Change-Id: I3fb0b3a84c56aed7d0da8ddba36e2d01fdb682ee
2017-06-05 14:54:45 -07:00
Josh Gao f2bd9a1b6f Merge "adb: reunregress waiting for device on start-server." am: 72076d1aa7 am: 08a70ac6e5 am: 986ba5bbbb
am: 86aeea69f2

Change-Id: Icfb77a5a596ebd9207793d9c7929bebb992de40d
2017-06-02 00:58:23 +00:00
TreeHugger Robot b4ad076ede Merge "Send color space information with screenshots" 2017-06-01 19:27:08 +00:00
Romain Guy 3a4e80ab8a Send color space information with screenshots
Version 2 of the framebuffer protocol in adb can now be used to read
the color space information of the screenshot: unknown (native),
sRGB or Display P3.

Bug: 29940137
Test: Manual
Change-Id: I037da58e1c4f6e9e874d72348140c067640c6931
2017-05-31 19:13:47 -07:00
Josh Gao 0b13c89f7a adb: reunregress waiting for device on start-server.
Move the invocation of adb_notify_device_scan_complete to
the end of device_connected, where we decrement connecting_devices.
Also, create a dedicated thread for handling hotplug events, instead of
reusing the main thread for this, since the main thread blocks until
device scan is complete.

Test: `adb kill-server; adb devices`
Change-Id: Ia73b1a57538174282a48ef73ab0a3e58152d6f83
2017-05-31 12:13:59 -07:00
Josh Gao 2f8dc5c785 Merge "adb: fix deadlock." am: 68599f5759 am: d5a2cdb72c am: a08c949c7a
am: 86d63c89b0

Change-Id: I7c45e6fcf3327d97ff15adbaa47df7ad08d4d0b2
2017-05-31 02:26:15 +00:00
Treehugger Robot 68599f5759 Merge "adb: fix deadlock." 2017-05-31 02:03:42 +00:00
Josh Gao d1a3e8f1ab adb: fix deadlock.
libusb hotplug callbacks are called with the libusb lock taken, and we
call into libusb with our local mutex, so we need to enforce an ordering
between the two. Instead of calling device_connected or
device_disconnected directly, enqueue them onto the main thread.

Bug: http://b/62200735
Test: manually hotplugged a device
Change-Id: Ic5d55db83b47f4bb60f124ce94ddfe06f5f1a0c6
2017-05-30 17:09:42 -07:00
GuangHui Liu 51dff9791e Merge "Create build target to pull adb test scripts." am: 9c0a541f08 am: 0daaf93424 am: 621e253c43
am: 3b9865faa9

Change-Id: Ic5fb3113f33aa7bc0bfac3366862ce0236768e20
2017-05-25 17:11:19 +00:00
GuangHui Liu 9c0a541f08 Merge "Create build target to pull adb test scripts." 2017-05-25 16:48:19 +00:00
Felipe Leme 8baa2168af Merge "Always print the initial bugreport progress message." am: 5b17d7131b am: 8b54eb7681 am: 916a84e38b
am: bcb2f87c5c

Change-Id: Ic9988557ad259439ad72b43c154d8d092f540088
2017-05-24 02:26:53 +00:00
Dan Albert a1a4371517 Merge "Add host feature for `push --sync` support." am: 886e6cac05 am: e2d7a50b69 am: 311f93faca
am: e0e9e4661b

Change-Id: I9909f7e52fc60b2446d84d1fc5da82a3925f921e
2017-05-23 23:58:17 +00:00
Felipe Leme e5d665b46f Always print the initial bugreport progress message.
Otherwise, it might take seconds to display the initial percentage,
and the user might thing something is wrong and CTRL-C the process.

Fixes: 62003852
Test: added BugreportTest.OkProgressZeroPercentIsNotIgnored
Test: m -j32 adb_test && ./out/host/linux-x86/nativetest64/adb_test/adb_test --gtest_filter=BugreportTest.*

Change-Id: I8e7dbb28666c825c1408d5d204f813064fc3048f
2017-05-23 16:58:16 -07:00
Dan Albert 5176df8d4a Add host feature for `push --sync` support.
Test: adb host-features | grep push_sync
Bug: None
Change-Id: Ia7a7e9c3c2e6632a9c954fbad8f64602a21d9757
2017-05-23 14:30:00 -07:00
GuangHui Liu 41bda344a9 Create build target to pull adb test scripts.
Test: m adb_integration_test_adb adb_integration_test_device

Change-Id: I8c97af44ecf65eeae8a8dd678c43ad1d9f6c8a51
2017-05-23 10:42:59 -07:00
Josh Gao 8b4f5d97ce Merge changes I8d0c60e5,Ib8ad0ad6 am: a6bb369cb0 am: c7d9eb8636 am: a1c2561863
am: fb37f521b0

Change-Id: Ib67fcd1ff88df4e379ce92693eaa339d2dad0fbb
2017-05-23 03:00:18 +00:00
Treehugger Robot a6bb369cb0 Merge changes I8d0c60e5,Ib8ad0ad6
* changes:
  adb: boolify check_header and check_data.
  adb: redirect stdout/stderr before initializing usb.
2017-05-23 02:51:32 +00:00