Commit graph

2577 commits

Author SHA1 Message Date
Lennart Wieboldt
cd15fc7ba8 Remove LOCAL_CLANG and clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: I34adaeef2f6558a09f26027271222bad94780507
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 14:29:50 +02: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
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
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
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
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
Dan Albert
dfc0ba92a8 Merge "Add --sync support to push." am: 62db5fcee0 am: d50b10544b am: 141f9c46d5
am: 8572f515fd

Change-Id: I29fe1ae0cf6be95b7bd44aaaed87a06065229c16
2017-05-19 20:42:22 +00:00
Dan Albert
06b0d6b01b Add --sync support to push.
Passing --sync only copies files that are older on the device.

Test: nose2
Bug: None
Change-Id: I2ff6c3d1fe29262c8ee50db316aa92fc38dd7147
2017-05-19 11:09:58 -07:00
Dan Albert
05e2c509dd Merge "Fix test following -p removal." am: 5e49fbc547 am: 3039d9d4fa am: 222a69bc92
am: b34b448bcd

Change-Id: I79a75b5167f7b8e03a176ed05f42c89000e43a61
2017-05-19 17:32:28 +00:00
Dan Albert
def4aae26d Fix test following -p removal.
Just use the environment variable.

Test: nose2
Bug: None
Change-Id: I020c737f8aa7416b46794ce387a12f7959a9ca2a
2017-05-19 00:30:51 -07:00
Josh Gao
36dadca9f0 adb: boolify check_header and check_data.
Test: grep
Change-Id: I8d0c60e500bba855a1afc0877253262246c07fef
2017-05-18 13:40:13 -07:00
Josh Gao
16c5a133ab adb: redirect stdout/stderr before initializing usb.
Avoid printing USB logging to the console.

Test: None
Change-Id: Ib8ad0ad6c559689d0f8feec2e66b42380edd26fb
2017-05-18 13:38:50 -07:00
David Zeuthen
7718e06ac0 Merge "adb: Allow disabling verity on eng builds when using AVB." am: 7ce0f00c08 am: 1ceea342d5 am: 984757365f
am: 7fb7389b66

Change-Id: I738acce3d5548bcfc444b4c04a0e20ba95fd9962
2017-05-17 21:26:36 +00:00
David Zeuthen
abddbc2cdf adb: Allow disabling verity on eng builds when using AVB.
Unlike VB1.0, if a device is using AVB then dm-verity is used on any
build (userdebug, eng, etc.). Therefore, we should allow disabling
verity on any build (except USER), not just userdebug. This bug was
pointed out in https://android-review.googlesource.com/#/c/371372/

Bug: 34124301
Test: Manually tested on -eng build on device using AVB.
Change-Id: I314550c13d7458d5d1ef68eb06f98849e11fbe15
2017-05-17 14:28:47 -04:00
Josh Gao
7be316ec0d Merge changes I8e8e0963,I3c714f63,Id157412e,Ib7c26fbd am: 55ddb99527 am: 66ca192ac3 am: f4578f1ad4
am: 21348e1205

Change-Id: Ie54a5dfdba5f6e4681473709af4aa370abb46d48
2017-05-15 21:40:45 +00:00
Josh Gao
425aefdcf0 adb: libusb: recognize devices with multiple interfaces.
A bug was introduced by commit 8bf37d7a wherein we accidentally only
look at the first interface of a device when checking whether a USB
device was an ADB device or not.

Bug: http://b/38201318
Test: none
Change-Id: I8e8e0963c77cd2cb03538d926ab735f4b57e52b7
2017-05-12 17:08:50 -07:00
Josh Gao
3f60a968e3 adb: libusb: wait for devices to become accessible.
Android's host linux libusb uses netlink instead of udev for device
hotplug notification, which means we can get hotplug notifications
before udev has updated ownership/perms on the device.

When detecting a new device, poll the device file for a while until we
can access it, before trying to open it.

Bug: http://b/38170349
Test: manually incrased timeout and chmodded a device betwen 0 and 664
Change-Id: I3c714f630940df02b407442592301e2bbb3d9653
2017-05-12 17:08:50 -07:00
Josh Gao
6da1cd49b5 adb: libusb: switch to hotplug for device detection.
Switch from polling in a loop to using libusb's hotplug API to detect
when devices arrive and leave. Use this to remove devices that were
inaccessible when they're unplugged.

Bug: http://b/38170349
Test: plugged in device
Change-Id: Id157412eb46834debecb0cd45b47b1ced50c2274
2017-05-12 17:08:50 -07:00
Josh Gao
723258a4c7 adb: silence noise.
Remove logging statements that don't provide any benefit.

Test: none
Change-Id: Ib7c26fbdb019f4d6bbce2b7fb192cb5e6066e53f
2017-05-12 17:08:50 -07:00
Siarhei Vishniakou
f608eb283a Merge "Adding 'uhid' permission for access to /dev/uhid." am: cecbc9993d am: 04daed4793 am: d819380f50
am: b995b58631

Change-Id: I0c4f2e22d6195f219a2e1b0ef346ce89b642dc6c
2017-05-12 03:50:14 +00:00
Siarhei Vishniakou
cecbc9993d Merge "Adding 'uhid' permission for access to /dev/uhid." 2017-05-11 19:02:32 +00:00
Siarhei Vishniakou
0729dd1edb Adding 'uhid' permission for access to /dev/uhid.
This CL is in support of another CL c/2048848, topic
'Refactor hid command in /frameworks/base/cmds' in
internal master. Adding the permissions for
shell here to access uhid_node as part of the
new 'uhid' group.

Bug: 34052337
Test: Tested on angler, bluetooth mouse works OK.

Change-Id: If9e100aa1262d689fb8adc5c0ce93f157c96399e
2017-05-11 01:28:53 +00:00
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
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
Steven Moreland
fc5d4345fa Merge "libcutils: compile with BOARD_VNDK_VERSION current" into oc-dev
am: 64639fd7dc

Change-Id: Ic30e207a89cf80f6f509f64f92ec9ee32cfaf3c1
2017-04-17 23:19:28 +00:00
Steven Moreland
d73be1b96b libcutils: compile with BOARD_VNDK_VERSION current
- moved __android_log_is_debuggable to a new public header
    (log_properties.h)
- vendor version of sched_policy uses ALOG* instead SLOG*

Test: (sanity) liblog-unit-tests
Test: (sanity) libcutils_test (noting b/b/32972117, two tests continue
  to fail)
Test: system/core as a whole makes with BOARD_VNDK_VERSION := current
  now with no problems.
Test: boots/works on internal marlin
Bug: 33241851

(cherry picked from commit 1f83aa424f)

Merged-In: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
Change-Id: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
2017-04-17 14:44:17 -07:00
Steven Moreland
1f83aa424f libcutils: compile with BOARD_VNDK_VERSION current
- moved __android_log_is_debuggable to a new public header
    (log_properties.h)
- vendor version of sched_policy uses ALOG* instead SLOG*

Test: (sanity) liblog-unit-tests
Test: (sanity) libcutils_test (noting b/b/32972117, two tests continue
  to fail)
Test: system/core as a whole makes with BOARD_VNDK_VERSION := current
  now with no problems.
Test: boots/works on internal marlin
Bug: 33241851

Change-Id: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
2017-04-17 12:18:36 -07:00
Josh Gao
c6e404c83e Merge changes from topics 'adb_thread', 'adb_loopback' am: 0301b3217b am: 750dfee974 am: da1f886ed8
am: 5d6593c5f7

Change-Id: I9f95633015ec7194b4bab54a0626ab99d90504ee
2017-04-14 20:23:08 +00:00
Josh Gao
2abb5f879c adb: kill adb_thread_{create, join, detach, exit}. am: e1dacfc1b6 am: d56eebd6c2 am: ae80841ac7
am: 86a55ba49d

Change-Id: Ia99182c2f5eef3bcbd1a978bf8bdfeb3dfbd0be1
2017-04-14 20:23:02 +00:00
Josh Gao
1a4a570a23 adb: don't try to resolve 'localhost' am: 46de1d7f03 am: 32d7ede78b am: 677a73e5f1
am: 368e043a7b

Change-Id: I7586b4bd3622911eade0bfbf40359b7797d6eed1
2017-04-14 20:22:55 +00:00
Josh Gao
d56eebd6c2 adb: kill adb_thread_{create, join, detach, exit}.
am: e1dacfc1b6

Change-Id: I5e0324b33d40f873d196946cee7591de0b7b949c
2017-04-14 20:08:04 +00:00
Josh Gao
32d7ede78b adb: don't try to resolve 'localhost'
am: 46de1d7f03

Change-Id: Ie419c5ddd80938760d7eaa3f50605c9874ca33d7
2017-04-14 20:07:56 +00:00
Josh Gao
0301b3217b Merge changes from topics 'adb_thread', 'adb_loopback'
* changes:
  adb: statically link libbase into the tests.
  adb: kill adb_thread_{create, join, detach, exit}.
  adb: don't try to resolve 'localhost'
2017-04-14 20:04:04 +00:00
Josh Gao
47330e21db adb: statically link libbase into the tests.
Make it easier to run the Windows tests with wine.

Test: adb_test
Test: wine adb_test.exe
Change-Id: I243c3adf4f6519dd7a38666ab42b384858351e21
2017-04-12 17:38:09 -07:00
Josh Gao
e1dacfc1b6 adb: kill adb_thread_{create, join, detach, exit}.
We have std::thread now, so we can delete this cruft.

Test: python test_device.py
Test: adb_test
Test: wine adb_test.exe
Test: /data/nativetest/adbd_test/adbd_test
Change-Id: Ie1c1792547b20dec45e2a62ce6515fcb981c3ef8
2017-04-12 17:12:32 -07:00
Josh Gao
46de1d7f03 adb: don't try to resolve 'localhost'
Misconfigured systems can have localhost pointing to an address that
isn't 127.0.0.1 or ::1.

adb is the only caller of the libcutils socket_loopback functions, so
move them into adb and switch the implementations over to using
INADDR_LOOPBACK and in6addr_loopback, instead of resolving 'localhost'
when connecting.

Bug: http://b/37282612
Test: `killall adb; adb shell`
Test: `killall adb; ip addr del 127.0.0.1/8 dev lo; adb shell`
Change-Id: I01c1885f1d9757ad0f7b353dd04b4d1f057741c8
2017-04-12 16:07:49 -07:00
Johan Torås Halseth
fafc230863 Merge "Move adb backup/restore helptext to adb shell bu help." am: 4a36cc7cf6 am: 8898a151e6 am: 9f23feae1f
am: 406a75f1fc

Change-Id: I2371012be58cc3af0b1da87d9be558e3b1cb2cca
2017-04-12 09:33:48 +00:00
Johan Toras Halseth
eca1b3bdcc Move adb backup/restore helptext to adb shell bu help.
Key/value support for adb backup was added in ag/1946677, and help text
for adb shell bu is added in ag/2088937. This CL points the user to this
helptext instead of keeping it here, since it can quickly get out of
sync.

BUG=36170696

Test: adb
Change-Id: Ic40679f421a32e60f292ad20b726a89bfff03349
2017-04-11 19:15:17 +01:00
Yabin Cui
b3f264f9b3 Merge "adb: don't reset usb when connecting it." am: 4b8087aeb2 am: 0c1bad300c am: e7affdc47c
am: 7ecf6c0e79

Change-Id: If47a46c05eda4f59b5221d33c2940de8c8ba4c12
2017-04-04 22:20:47 +00:00
Treehugger Robot
4b8087aeb2 Merge "adb: don't reset usb when connecting it." 2017-04-04 19:29:09 +00:00
Yabin Cui
5d002b8d6a adb: don't reset usb when connecting it.
Calling libusb_reset_device() resets the usb connection with device
on linux platform. It can interfere with other usb interfaces and only
works on linux.
Removing it only affects when adb server is killed while doing IO with
device, which will be solved in later patches.

Bug: http://b/32952319
Test: none
Change-Id: I19522435eadd938ff95d49cbae3bcaa5c8f6d184
2017-04-04 10:29:21 -07:00
Elliott Hughes
8663c0083a Merge "Show install path in "adb --version" and "fastboot --version"." am: d2d8b68f70 am: 8aac990de2 am: dd05434457
am: ff5e2fa208

Change-Id: I6fac7e98bb6fc5487094406af888f985b2f938cd
2017-04-04 01:34:59 +00:00
Elliott Hughes
8aac990de2 Merge "Show install path in "adb --version" and "fastboot --version"."
am: d2d8b68f70

Change-Id: I3fac85f01f08c277bdc4ccc8ebbb22ddb9f3397f
2017-04-04 01:23:40 +00:00
Elliott Hughes
d2d8b68f70 Merge "Show install path in "adb --version" and "fastboot --version"." 2017-04-04 01:16:11 +00:00
Josh Gao
4182357b37 Merge "Revert "adb: check our socketpair ends in our win32 emulation."" am: c1314c8b13 am: 83b3c0817f am: cf476c9360
am: 3e5fb4a680

Change-Id: I2125437f764f714772845769927a6eaf39b82df8
2017-03-31 00:04:01 +00:00
Josh Gao
83b3c0817f Merge "Revert "adb: check our socketpair ends in our win32 emulation.""
am: c1314c8b13

Change-Id: I4eaca80573fc3b17ff312eae2e9e4598a0bcf55a
2017-03-30 23:56:45 +00:00
Elliott Hughes
1fd46dfa72 Show install path in "adb --version" and "fastboot --version".
Bug: http://b/36766455
Bug: http://b/34691048
Test: ran tests
Change-Id: I4b67ec54d41a281fe7a33c017d3cfbc8055e3b43
2017-03-30 15:10:24 -07:00
Josh Gao
3726a0195b Revert "adb: check our socketpair ends in our win32 emulation."
This reverts commit 5990191c4e.

Some Windows users are seeing mismatches between the two ends.

Bug: https://code.google.com/p/android/issues/detail?id=258400
Test: mma
Change-Id: Ie3a121a2754332608ff64b3b016adcb4258d41f3
2017-03-30 13:12:37 -07:00
bohu
f66a7ee897 Revert "Revert "Qemu-pipe: refactor qemu_pipe.h into libqemu_pipe""
This reverts commit 63ef9ff5fa.
2017-03-29 12:19:40 -07:00
bohu
63ef9ff5fa Revert "Qemu-pipe: refactor qemu_pipe.h into libqemu_pipe"
It broke master
BUG: 36695011

This reverts commit ff87855e10.

Change-Id: Ic1057a416748d4a3c9736cf3bb73982b8d45e5d5
2017-03-28 15:05:00 -07:00
Bo Hu
08ef70558d Merge changes from topic 'qemu-cp'
* changes:
  Qemu: make the qemu_pipe_open back compatible
  Emulator: Enhance qemu_pipe.h to handle partial rw
  Qemu-pipe: refactor qemu_pipe.h into libqemu_pipe
2017-03-28 18:13:54 +00:00
bohu
ff87855e10 Qemu-pipe: refactor qemu_pipe.h into libqemu_pipe
Traditionally, qemu_pipe has both the declaration and implentation of each
function in one header file--qemu_pipe.h, and it is getting incovenient to
maintain.

This CL separates the implementation of functions from the header file,
and makes qemu_pipe a static library for other modules to link to.

Note that the interface and implementation of qemu_pipe are kept unchanged,
and future CLs will enhance the implementation to make it more reliable and
more compatible with old and new API levels.

Following projects are affected by this refactoring, and they are modified
accordingly:

hardware/ril/reference-ril

Change-Id: I541ecbf0cc7eadeef9d4e37ffd9ca7bfcc5c94c0
(cherry picked from aosp 294d44be33)
2017-03-28 09:27:00 -07:00
Josh Gao
36699d3fb2 Merge "adb: allow symlinks to directories in directory_exists."
am: c10c31e8ba

Change-Id: I9480b98081f9db54955da19a4565c9a458781cdb
2017-03-24 18:43:23 +00:00
Josh Gao
ff468dce4c adb: allow symlinks to directories in directory_exists.
Bug: http://b/36516955
Test: python test_device.py
Change-Id: Ie81e87aac3b157182bde0955bdba23d48bfea873
2017-03-23 16:19:55 -07:00
Elliott Hughes
0cb8c69bf2 Merge "Switch "adb sideload" over to lseek/read."
am: c0ca39c41a

Change-Id: Ia50ff02ed1e11f6bac3d5ef2e5d09c03fa6f216c
2017-03-23 21:21:34 +00:00
Elliott Hughes
c0ca39c41a Merge "Switch "adb sideload" over to lseek/read." 2017-03-23 21:06:51 +00:00
Elliott Hughes
ee1ac710cd Switch "adb sideload" over to lseek/read.
This made no difference to the time taken to sideload an AOSP marlin
update (1m24s), but does reduce the memory requirements to 64KiB.

Bug: https://code.google.com/p/android/issues/detail?id=258500
Bug: http://b/36046324
Test: "time adb sideload update.zip"
Change-Id: Ib0a4daeb5fe798a9bb9c9e0e5fbcff0ed46f20df
2017-03-22 14:34:16 -07:00
Felipe Leme
70fd64ec05 Merge "Don't display bugreport progress when it recedes."
am: 450c44052c

Change-Id: Ieff977589b4c41687727099868b548e0072469f8
2017-03-21 02:05:04 +00:00
Treehugger Robot
450c44052c Merge "Don't display bugreport progress when it recedes." 2017-03-21 01:58:12 +00:00
Josh Gao
f9d12f272e Merge "adb: switch the jdwp control socket to SOCK_SEQPACKET."
am: 249836158e

Change-Id: Ia42f80f778b2ba78d5d6181038b144c89530f772
2017-03-20 23:28:34 +00:00
Josh Gao
b2a7251c55 adb: switch the jdwp control socket to SOCK_SEQPACKET.
Switch the jdwp control socket to SOCK_SEQPACKET so we don't have to
worry about short reads for the PID.

Bug: http://b/36411868
Test: adb jdwp
Change-Id: I908b88e93b1e0ca2895eb8e777d8438a7bbfa92a
2017-03-20 13:37:13 -07:00
Josh Gao
7e5b10b18c Merge "adb: detect closed jdwp socket."
am: e1c4e04f82

Change-Id: Ife55285da64e0c12dac3cd8e8171126c3bb8b543
2017-03-20 20:04:38 +00:00
Felipe Leme
dedcbaad51 Don't display bugreport progress when it recedes.
Also fixed InvalidNumberArgs that broke when usage() was moved out from
bugreport.cpp.

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

Change-Id: I7be5ef7de0fb0d339dc80a2abc816e1c905deb22
2017-03-20 11:49:21 -07:00
Josh Gao
3fd78c922c adb: detect closed jdwp socket.
If a process opens a JDWP socket, but crashes before writing the full
PID, adbd will spin forever.

Bug: http://b/36411868
Test: none
Change-Id: I1811759e15c3d9c819685c5fc159a566bd4bc842
2017-03-20 11:11:19 -07:00
Tom Cherry
ef3017bdbd Merge "Remove extraneous .clang-format files"
am: 41c7bb5055

Change-Id: I5062d81a01cde71a9bbe7549f9e3c9198af955ae
2017-03-15 00:55:35 +00:00
Tom Cherry
5b4eb23cfd Remove extraneous .clang-format files
The .clang-format files in the base, debuggerd, adb, libprocinfo, and
fastboot subdirectories each differ slightly from the top level
.clang-format-2 and .clang-format-4, but not in a substantially
meaningful way, as the source files in those directories have not been
re-formatted with clang-format.  Therefore, let's reduce the
differences and use only the two top level clang-format files.

Secondly perform some small clean-up of the top level .clang-format
files.  AllowShortBlocksOnASingleLine is already false in the Google
style, so it can be removed.  AllowShortFunctionsOnASingleLine should
not change between the -2 and -4 versions, so leave it at the Google
default style in both, which is 'All'.

The diff stats for these changes are:

./base/
Old:
640 insertions(+), 531 deletions(-)
New:
563 insertions(+), 808 deletions(-)

./debuggerd/
Old:
910 insertions(+), 886 deletions(-)
New:
991 insertions(+), 1023 deletions(-)

./adb/
Old:
2623 insertions(+), 2886 deletions(-)
New:
2655 insertions(+), 3103 deletions(-)

./libprocinfo/
Old:
2 insertions(+), 1 deletion(-)
New:
4 insertions(+), 18 deletions(-)

./fastboot/
Old:
618 insertions(+), 743 deletions(-)
New:
726 insertions(+), 882 deletions(-)

./init/
Old:
1755 insertions(+), 1866 deletions(-)
New:
1715 insertions(+), 1952 deletions(-)

Test: Above clang-format stats
Change-Id: I3f7b8ab0660c8394c5008ba95ea15e70dd22b55b
2017-03-14 14:06:31 -07:00
Bowgo Tsai
4ba84b2dd2 Merge "adb: replacing fs_mgr_read_fstab() with fs_mgr_read_fstab_default()"
am: eca92a5a6f

Change-Id: I192ac96673a3c7e8b4f81c7b27fd761d445556ee
2017-03-11 03:54:23 +00:00
Treehugger Robot
eca92a5a6f Merge "adb: replacing fs_mgr_read_fstab() with fs_mgr_read_fstab_default()" 2017-03-11 03:48:49 +00:00
Bowgo Tsai
66ee277353 adb: replacing fs_mgr_read_fstab() with fs_mgr_read_fstab_default()
The original default /fstab.{ro.hardware} might be moved to
/vendor/etc/. or /odm/etc/. Use the new API to get the default
fstab instead of using the hard-coded /fstab.{ro.hardware}.

Bug: 35811655
Test: boot marlin with /vendor/etc/fstab.marlin, then run 'adb remount'
Change-Id: I927209ce3c5bea45c01ed631a7c4c320fe728c00
2017-03-11 09:37:56 +08:00
Josh Gao
b0e8bbfc99 Merge "adb: properly erase destroyed jdwp_trackers."
am: e02eba8fd2

Change-Id: Ia87892fecebc64198b70acf089aa7eac3652175e
2017-03-10 21:00:23 +00:00
Treehugger Robot
e02eba8fd2 Merge "adb: properly erase destroyed jdwp_trackers." 2017-03-10 20:54:51 +00:00
Josh Gao
6def9bd67c adb: properly erase destroyed jdwp_trackers.
std::remove_if moves to-be-removed elements to the end of the vector
and returns an iterator that must be .erased.

Bug: http://b/35772578
Test: mma
Change-Id: Idfe8520e176204ac5ce000c30704873a3ffe6c9c
2017-03-10 11:24:37 -08:00
Casey Dahlin
1b35c3f471 Merge changes from topic 'adb-mdnsd'
am: f4f95496ce

Change-Id: I1749f913b8c5cca64880d3eec3009f850bc9141e
2017-03-10 01:16:46 +00:00
Casey Dahlin
bd2c93fab0 Enable mDNS on Darwin
am: 304150a521

Change-Id: Id0d77614fc3bf580c2879b9ad801c77dcbfc7752
2017-03-10 01:16:31 +00:00
Casey Dahlin
cef0c7cf7d Don't include mDNS support on platforms other than Linux
am: d6c8091e9f

Change-Id: Ife0b6e08098c05288c3ea63e9063e5116335716a
2017-03-10 01:16:18 +00:00
Casey Dahlin
b298855764 Add mDNS device discovery for adb client
am: 13a269ea24

Change-Id: Ib5f80b3ccc9db7c6fe6f5c989e82083d734ce4df
2017-03-10 01:16:05 +00:00
Casey Dahlin
f18d33c2c6 adb: Set a hostname for mDNS
am: 1fe3cae67e

Change-Id: Iea8700ec13502e58774968cd7383255f769fa105
2017-03-10 01:15:49 +00:00
Casey Dahlin
cc9c92fa95 Make ADBD announce its presence over mDNS
am: 6cd5e0b4ef

Change-Id: Ida2f133f72087f291f2d34e968503ae81c3fbd50
2017-03-10 01:15:31 +00:00
Treehugger Robot
f4f95496ce Merge changes from topic 'adb-mdnsd'
* changes:
  Make ADB over mDNS work on Windows
  Enable mDNS on Darwin
  Don't include mDNS support on platforms other than Linux
  Add mDNS device discovery for adb client
  adb: Set a hostname for mDNS
  Make ADBD announce its presence over mDNS
2017-03-10 01:09:42 +00:00
Josh Gao
9d13bc2160 Merge "adb: append the libwinpthread COPYING to adb's NOTICE."
am: c1b3c8ef26

Change-Id: I4de6f83ea394635710b4e89cc1818233b6605eca
2017-03-09 07:48:01 +00:00
Josh Gao
d3bf1a8d7e adb: append the libwinpthread COPYING to adb's NOTICE.
We statically link libwinpthread into Windows binaries, but soong
currently can't specify notice files for toolchain_libraries. Add
libwinpthread's COPYING info directly to adb's as a hack.

Bug: http://b/36073965
Test: `make PRODUCT-sdk-win_sdk` + manual inspection of NOTICE.txt
Change-Id: I58d6be0ecf5626b67308f7e94128a2cd44dab161
2017-03-08 21:27:59 -08:00
Badhri Jagan Sridharan
a37bc179de Merge "adb: Do not signal gaget stack unless descriptors are written"
am: eab4c62e22

Change-Id: Ia04e413a6f3a0e3fcb1e8e52aa822accb808f1fb
2017-03-08 19:39:43 +00:00
Badhri Jagan Sridharan
43fd1a4ea7 adb: Do not signal gaget stack unless descriptors are written
While recovering from endpoint errors, the gadget stack was being
signalled even when desriptors were NOT being rewritten. Avoid this
as this might cause enumeration loops.

Bug: 36036550
Change-Id: Iff2b2fc8cded001ef3c77dc170dce3b96848970c
2017-03-07 19:20:54 -08:00
Casey Dahlin
304150a521 Enable mDNS on Darwin
We have to disable IPv6 to get this going, but nobody was yet using
IPv6, so that should be fine for now.

Test: Verified mDNS discovery on a MacBook
Bug: 31042497
(cherry picked from 9ae65de087171072f3890a81b074ae27db319508)

Change-Id: I628f0a1e9c4784db42fa56f5faf2904b6e1cf548
2017-03-07 14:45:52 -08:00
Casey Dahlin
d6c8091e9f Don't include mDNS support on platforms other than Linux
Test: Shamu build now passes
Bug: None
(cherry picked from 122a7738606d854d6dc10fa361c1d7296cc9670a)

Change-Id: I650adf0bca96fb655163f5e9b27d9995ae448ec2
2017-03-07 14:45:52 -08:00
Casey Dahlin
2fe9b60475 Make ADB over mDNS work on Windows
Test: Verified ADB over mDNS on a Windows machine
Bug: 30482671
(cherry picked from 9fdd77101f49d03ff29342e12e23edf241f68522)

Change-Id: If955ca304db71a5b08c5a9654f1e27ab74af9af8
2017-03-07 14:45:52 -08:00
Casey Dahlin
13a269ea24 Add mDNS device discovery for adb client
Test: Was able to discover a raspberry pi.
Bug: 28074466
(cherry picked from e292cd16760321fccc99c8c261cb92fa4b6462ab)

Change-Id: Id9571576457a4a0a078e48a274a4e8eac78bfe2b
2017-03-07 14:45:51 -08:00
Casey Dahlin
1fe3cae67e adb: Set a hostname for mDNS
Now all devices won't appear as "Android." Should make it easier to
multiplex.

Test: Verified locally on a raspberry pi 3
Bug: 28887278
(cherry picked from 815b23319635d264ae0ce2c8c29a5776a57b8051)

Change-Id: Icfd0116477543af6a3049c14d818c1cff7fc3b93
2017-03-07 14:44:38 -08:00
Casey Dahlin
6cd5e0b4ef Make ADBD announce its presence over mDNS
We now request mdnsd from adb and register a service of type _adb._tcp
for clients to connect to.

Test: Verified service appears in avahi-browse
Bug: 28074466
(cherry picked from 379ac414e4d9f53388d903913022a55695292775)

Change-Id: Ie871b9c8b40e86063cc1e68e8f3e4290ead2d279
2017-03-07 14:42:06 -08:00
Josh Gao
ef501512fa Merge "adb: turn on libusb by default."
am: 817b2f3b2c

Change-Id: Iaeefdcc45a5b96243b0b47822361d71c6e154b6e
2017-03-04 00:31:11 +00:00
Josh Gao
f2f0b31850 adb: turn on libusb by default.
Bug: http://b/31321337
Test: python test_device.py
Change-Id: Idb2ff1108331bf505feeeb943b6be7bb78124618
2017-03-02 13:23:56 -08:00
Bo Hu
8c35491151 Merge "DO NOT MERGE ANYWHERE Qemu-pipe: refactor qemu_pipe.h into libqemu_pipe" 2017-03-02 18:03:30 +00:00
bohu
294d44be33 DO NOT MERGE ANYWHERE Qemu-pipe: refactor qemu_pipe.h into libqemu_pipe
Traditionally, qemu_pipe has both the declaration and implentation of each
function in one header file--qemu_pipe.h, and it is getting incovenient to
maintain.

This CL separates the implementation of functions from the header file,
and makes qemu_pipe a static library for other modules to link to.

Note that the interface and implementation of qemu_pipe are kept unchanged,
and future CLs will enhance the implementation to make it more reliable and
more compatible with old and new API levels.

Following projects are affected by this refactoring, and they are modified
accordingly:

device/generic/goldfish
device/generic/goldfish-opengl
hardware/ril/reference-ril

Change-Id: I541ecbf0cc7eadeef9d4e37ffd9ca7bfcc5c94c0
2017-03-01 16:33:44 -08:00
Colin Cross
58021d15c9 Move adb_dirname and adb_basename to libbase
adb already provides an implementation of dirname and basename that
take and produce std::strings, move it into libbase so it can be
used in the implementation of GetExecutableDirectory.

Test: out/host/linux-x86/nativetest64/adb_test/adb_test
Test: out/host/linux-x86/nativetest64/libbase_test/libbase_test
Test: adb shell /data/nativetest64/libbase_test/libbase_test64
Change-Id: Ideb1627607b14562121316d4ed27fa6fb0930684
2017-02-27 18:18:31 -08:00
Josh Gao
87eb0fc3d0 Merge "Revert "adb: remove win32 dependency on libwinpthread-1.dll."" 2017-02-24 21:02:25 +00:00
Sandeep Patil
f134fe07b8 adb: early-mount: fix verity toggle through adb for early mount
verity toggle through adb failed to work for early mount due to fstab
entries being moved into kernel/dt. This change fixes that by using the
new fs_mgr_read_fstab_default() api that will make sure all fstab
entries (from dt as well as from /fstab.{ro.hardware}) are combined
before returning the fstab object.

b/27805372

Test: early mount /system and /vendor on angler.
- test adb disable-verity && adb root to ensure rebooted instance
doesn't have 'partition.system.verified' property set. i.e. verity is
indeed disabled.

- test adb enable-verity && adb root to ensure rebooted instance does
have 'partition.system.verified' property set, i.e. verity is enabled.
also verified by trying to do 'adb remount' which correctly warns about
verity

Change-Id: Iffdcc0a0b959a65c326219bd4e9e41cba9ec7c88
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-23 16:48:52 -08:00
Josh Gao
3d4d973e82 Revert "adb: remove win32 dependency on libwinpthread-1.dll."
This reverts commit c2e984eec8.

Move the change to build/make, so that other win32 binaries get this as
well.
2017-02-23 13:16:52 -08:00
Josh Gao
5d1756ceb5 adb: add adb host-features, report libusb status.
Add a 'host-features' command to get the features of the currently
running host adb server. Abuse it to report libusb status.

Bug: http://b/34983123
Test: adb host-features; adb kill-server; ADB_LIBUSB=1 adb start-server; adb host-features
Change-Id: I0e8d503a2dbdff9002ebb6ce8a298498a9421422
2017-02-22 18:19:21 -08:00
Treehugger Robot
1d73abb443 Merge "adb: remove win32 dependency on libwinpthread-1.dll." 2017-02-22 02:06:40 +00:00
Josh Gao
c2e984eec8 adb: remove win32 dependency on libwinpthread-1.dll.
Explicitly link against the static libwinpthread.a to avoid a
dependency on the dll.

Also, make the tests link against libbase statically.

Bug: http://b/31665213
Test: wine adb.exe
Test: wine adb_test.exe
Change-Id: Ifd41afcb1756a4b9b6db12e102b4db502e73d846
2017-02-21 15:30:11 -08:00
Jerry Zhang
f3fb7de3c8 adb: set max_rw to USB_FFS_BULK_SIZE explicitly
Sometimes when endpoint_alloc returns ENODEV,
max_rw will end up being a value that is too
big.

Bug: 35634401
Test: push/pull files
Change-Id: Iaa81a3311b1855e2a835562cdf7a46ff4399feb1
2017-02-21 14:37:07 -08:00
Elliott Hughes
9eb551868b adbd's children should have SIGPIPE set to SIG_DFL.
POSIX lets you choose whether or not SIGPIPE disposition is inherited,
and Linux chose "yes". Work around that.

Bug: http://b/35209888
Test: "ps -A | head" without the toybox workaround
Change-Id: I6b5afa3d87eb2af04b24c6c37fa338ab60ad2336
2017-02-17 11:14:33 -08:00
Jerry Zhang
05fe272a87 adb: Lower EP_ALLOC retry count
Retries were causing timeouts on some devices.

Bug: 35418581
Test: Change usb config
Change-Id: Ie80d9eba1cb9af0acee49bd7312842533a94a87b
2017-02-16 10:56:05 -08:00
Jerry Zhang
b5a34a2bce adb: Add bMaxBurst to superspeed descriptors
This gives a large boost to speed on usb 3.0.

Test: adb pull/push multi GB files
Bug: 31722483
Change-Id: Iea039f1aba8b2e4d7e4a2ecb504cccb5dd1e4629
2017-02-13 18:19:41 -08:00
Jerry Zhang
2f8c60b1cc adb: Set max socket sizes to larger values.
This improves performance of push/pull.

Test: adb push/pull multi GB files.
Bug: 31722483
Change-Id: Ia01574c3db6a740d7a7e64ba1f5bc1fc279fb3f6
2017-02-13 18:19:36 -08:00
Jerry Zhang
55205a565b adb: Pre allocate kernel memory
This allows reliable use of larger buffer sizes.
Max r/w size is set only when that preallocation
is successful so that memory is guaranteed to be
available.

Bug: 31722483
Test: adb push with multi GB files
Change-Id: Ia0459ca051988abb144645871792e8f840dd3ff7
2017-02-13 14:20:47 -08:00
Elliott Hughes
2ec36b0da0 Don't print 168^W143 lines of help when someone makes a typo.
Print actual usage messages in most cases.

Add --help and --version.

Bug: http://b/28054087
Test: manual
Change-Id: I39c1cb7a84f52e0c35d24f140ec55c3a181283fb
2017-02-06 16:20:30 -08:00
Nick Kralevich
aced420f20 usb_dispatch.cpp: Lower severity of logging statement.
The first time you run adb, it starts the adbd server and annoyingly
generates the following message:

adb I 02-01 11:57:58 99717 99717 usb_dispatch.cpp:30] using native
backend

Drop the severity of the message to avoid visible spammy messages only
intended for debugging.

Test: code compiles and no more log message in normal adb use
Change-Id: I882092a6cd14bc67980d88416397d51ab8393b1b
2017-02-01 12:05:18 -08:00
Josh Gao
06766a8b29 adb: fix darwin build.
Bug: none
Test: mma on mac
Change-Id: I49ef3c4892c7942a235d317d90386c7d8a872868
2017-01-26 14:01:34 -08:00