Commit graph

2525 commits

Author SHA1 Message Date
Josh Gao
9bf624cd3a Merge "adb: switch asocket::enqueue to std::string." 2018-02-08 01:06:22 +00:00
Josh Gao
f99711fe87 Merge changes I86bcfaaa,I24d7f5d0
* changes:
  adb: restore packet data length checks.
  adb: switch asocket's intrusive linked list to vectors.
2018-02-08 00:34:40 +00:00
Josh Gao
95c4497bd4 adb: don't spew to logcat when tracing is enabled.
When persist.adb.trace_mask is used to enable verbose logging, avoid
exponential logging when a user runs `adb logcat`. As a side-effect,
set the minimum logging level to include everything when ADB_TRACE is
used on the client (which is something we want anyway).

Bug: http://b/72971016
Test: `adb shell 'setprop persist.adb.trace_mask; killall adbd'; adb logcat`
Change-Id: Id4bca1f3933a920345499dbeaeb103c8a2e220cd
2018-02-06 15:55:06 -08:00
Josh Gao
27cb7dca77 adb: switch asocket::enqueue to std::string.
Switch asocket over to taking a std::string instead of apacket* for
data. This allows us to remove asocket specific fields from apacket*.

Test: python test_device.py with x86_64 emulator, walleye
Test: adb_test on host
Change-Id: I9d157ff331a75ba49a54fdd4194e3f6cdff722f4
2018-02-06 12:59:06 -08:00
Josh Gao
5caaebdc3d adb: restore packet data length checks.
These checks were moved to after the read of the payload, which is too
late. Add a check before each read to avoid a heap buffer overflow.

Test: python test_device.py with x86_64 emulator, walleye
Change-Id: I86bcfaaa9004951cc52ad89af74680cf748e717d
2018-02-06 12:59:06 -08:00
Josh Gao
5e5076404a adb: switch asocket's intrusive linked list to vectors.
Test: python test_device.py
Change-Id: I24d7f5d0401de77d80c7a2dd5a7dcb551943342d
2018-02-06 12:59:06 -08:00
Josh Gao
b800d88b34 adb: extract atransport's connection interface.
As step one of refactoring atransport to separate out protocol handling
from its underlying connection, extract atransport's existing
hand-rolled connection vtable out to its own abstract interface.

This should not change behavior except in one case: emulators are
now treated as TCP devices for the purposes of `adb disconnect`.

Test: python test_device.py, with walleye over USB + TCP
Test: manually connecting and disconnecting devices/emulators
Change-Id: I877b8027e567cc6a7461749432b49f6cb2c2f0d7
2018-01-30 15:22:41 -08:00
Josh Gao
fb413a2304 adb: fix a leak.
Test: none
Change-Id: I469bd93180cd2a8b6408f73e8c8f164f72b3345c
2018-01-30 13:32:38 -08:00
Treehugger Robot
ef213b6d5b Merge "adb/fastboot: switch over to shared AdbWinApi." 2018-01-09 19:49:23 +00:00
Josh Gao
b0449da977 adb/fastboot: switch over to shared AdbWinApi.
Bug: http://b/71721338
Test: manually ran adb/fastboot on windows
Change-Id: I9fee6ea4c0e07cbeb69a48e456161832a5994e7b
2018-01-08 16:45:30 -08:00
Elliott Hughes
18cdd3502a Merge "Sort devices list before output." 2018-01-08 22:11:23 +00:00
Mike Frysinger
50ecaca744 adb: add missing condition_variable include
Test: build still works
Change-Id: I0e77336bab2a4a54cb2e77143162627d47aac0b1
2018-01-02 02:25:02 -05:00
Elliott Hughes
579e682628 Add std::string StartsWith*/EndsWith* overloads.
We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.

Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
2017-12-20 09:42:22 -08:00
Artem Iglikov
04398a9b23 Sort devices list before output.
Makes copy of the transport list and sorts it by type and serial before
printing.

Bug: 70748433
Test: adb devices displays all connected devices
Change-Id: I917728a102972f2f38f2e370a0c6011c1eb883c7
2017-12-19 09:22:53 +00:00
Tim Murray
de47194940 adb: disable checksum on new versions
The checksum is unnecessary. Improves adb performance by 40% on USB2.

Test: new adb works with new + old adbd, old adb works with new adbd
bug 67327728

Change-Id: I761d8a5a62deaea9bbb092ea9926b2d6d312f00d
2017-12-14 14:18:26 -08:00
Elliott Hughes
bf2062f800 Merge "Set $TMPDIR for adb shell." 2017-12-12 00:29:50 +00:00
Treehugger Robot
6f29887c71 Merge "adb: get libusb compiling on Windows." 2017-12-11 19:24:41 +00:00
Elliott Hughes
d42df42f30 Set $TMPDIR for adb shell.
Bug: http://b/19635681
Test: printenv
Change-Id: I21e89b9d7cccad23f32a3062a9e04e59b8278104
2017-12-11 10:40:57 -08:00
Josh Gao
9425996b45 adb: get libusb compiling on Windows.
This still doesn't work yet because libusb doesn't support hotplug on
Windows yet, but it's in the milestones for the next libusb release,
and this is enough to start poking around with the WinUSB device-side
stuff, so leave it broken for now.

Bug: http://b/68993980
Test: set ADB_LIBUSB=1; adb.exe server nodaemon aborts in the expected place
Change-Id: Icef7d46e31c847d6a8e724c6f58ae5db43673c16
2017-12-08 13:11:15 -08:00
Treehugger Robot
a4a9a81d38 Merge "adb: disable USB packet overflow checking on OS X." 2017-12-08 20:31:51 +00:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
Josh Gao
801048c6ea adb: disable USB packet overflow checking on OS X.
OS X appears to be misreporting the maximum packet size on some
hardware. Disable this on OS X until we figure out what's going on.

Bug: http://b/65063965
Bug: https://issuetracker.google.com/70244520
Test: python test_device.py on linux with CHECK_PACKET_OVERFLOW disabled
Test: python test_device.py on darwin (but on hardware that wasn't reproducing this)
Change-Id: I57e1adfa162e40ed79f71f97af552b3f0519324e
2017-12-06 15:34:41 -08:00
Jim Kaye
42f9a44000 Merge "Fix typos in ADB documentation"
am: 017203b140

Change-Id: I263536093d33e7e1783049834862346e47643723
2017-11-30 21:53:43 +00:00
Jim Kaye
ab74e068ee Fix typos in ADB documentation
Bug: None

Test: None

Change-Id: Ib036eefc602bf0ebac869146b04eea225cae39ef
2017-11-30 10:57:51 -08:00
Elliott Hughes
0b8a47c55a Merge "Remove a duplicate TEMP_FAILURE_RETRY."
am: 166c6a4390

Change-Id: I7bf8f8b7c68ecced7c62122f59623eefe9bab285
2017-11-29 16:12:00 +00:00
Elliott Hughes
166c6a4390 Merge "Remove a duplicate TEMP_FAILURE_RETRY." 2017-11-29 16:06:12 +00:00
Elliott Hughes
3df2fa6d8e Remove a duplicate TEMP_FAILURE_RETRY.
Bug: N/A
Test: builds
Change-Id: I19c2f50422e8a7e0c451a464586553f3e5eaadab
2017-11-28 18:05:27 -08:00
Nick Kralevich
cac2163a6b Merge "Standarize on VFS_CAP_REVISION_2"
am: af03f483d7

Change-Id: If1d0c4aa90cb712168db2252c23e621c3513acfe
2017-11-28 01:11:17 +00:00
Nick Kralevich
65b8d749f7 Standarize on VFS_CAP_REVISION_2
In https://github.com/torvalds/linux/commit/8db6c34f1dbc8 , namespaced
file capabilities were introduced. That change updated VFS_CAP_REVISION
from VFS_CAP_REVISION_2 to VFS_CAP_REVISION_3.

Android code is written assuming v2 capabilities, and the code will
break if we naively try to treat a v2 structure as a v3 structure.
So don't even try.

Android kernels prior to v4.14 will not support this extended capability
structure, so attempting to set such capabilities will ultimately fail.

With 8db6c34f1dbc8, it appears that attempting to read a v3 capabilities
xattr will always downgrade the capability to a v2 capability, so it
really doesn't make sense to look for a v3 capability.

Android capabilities are only created at /system and /vendor filesystem
creation time by host tools. Android processes, within or outside a
namespace, are not permitted CAP_SETFCAP
(https://android-review.googlesource.com/c/platform/system/sepolicy/+/547801/1/public/domain.te
line 1101). So we should never have to deal with a v3 capability other
than those that might appear on the /system / /vendor partition at a
future date by a future author.

Bug: 69617725
Test: build/test/boot/CTS passes
Change-Id: I0378b3f1195dc62dbeb771944ab378c881441118
2017-11-27 14:17:42 -08:00
Sandeep Patil
25f1631aa7 DO NOT MERGE ANYWHERE Add comments and code about ro.boot.slot back
Taimen bootloader passes androidboot.slot for now.
This reverts commit 211a4a5d5a.

Bug: 68710251
Test: taimen successfully mounts partition in first stage
Change-Id: I046afc99120e7ec9ef4b8ea7a852eb70e7231ea9
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-11-10 16:20:27 -08:00
Treehugger Robot
93e5cd85d1 Merge "Move GetDeviceTest from adb's test_device.py to adb package." 2017-11-09 00:57:32 +00:00
Josh Gao
85d4789719 Move GetDeviceTest from adb's test_device.py to adb package.
This test actually belongs with the adb python wrapper, since it's not
affected by changes to adb itself.

Bug: http://b/64260633
Test: python test_device.py
Change-Id: I58e5dff760f35923f8dbbdc7de6ffd75254880dc
2017-11-08 14:39:06 -08:00
Elliott Hughes
6b970212fd Don't include the build number in the adbd binary.
We want repeatable builds for minimal OTAs.

(cherrypick of 2e93eda69cf20d9c04d56ea6bf1e2ea62ad62eb4.)

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-11-07 10:57:36 -08:00
Josh Gao
1f3763ef4a Merge "adb: fix erase-remove_if idiom."
am: c2a2ecb7a5

Change-Id: I98bc2547b3785d8ca14565a6a9b7fac84a7c673e
2017-10-23 21:36:22 +00:00
Treehugger Robot
c2a2ecb7a5 Merge "adb: fix erase-remove_if idiom." 2017-10-23 21:28:32 +00:00
Mark Salyzyn
5966ae2c6b Merge changes I3e6e5a22,I6eb3f066
am: 75836d5e7f

Change-Id: I871260b9cdf7a1ab5f6d39cd8a491cd31cd94a4d
2017-10-23 20:45:02 +00:00
Josh Gao
4dfaa88610 adb: fix erase-remove_if idiom.
This probably doesn't have any actual effect, because there should only
be one smartsocket listener so this will happen to work, but this looks
sketchy.

Test: mma
Test: adb server nodaemon & (sleep 1; adb kill-server)
Change-Id: Id00ab1fc1fc029949c675ae6e3b1a77f3e9e4c69
2017-10-20 18:03:48 -07:00
Mark Salyzyn
8f3b8873b0 adb: cleanup some portions of client usb interfaces
Cleanup to remove open coded functions.

Test: build
Bug: 63736262
Bug: 38446744
Bug: 66912053
Change-Id: I3e6e5a22542934837b6a03523987141dc2776d48
2017-10-13 07:31:49 -07:00
Mark Salyzyn
0a78cc1b76 adb: clang-format for adb.h and client/usb_windows.cpp
Future adjustments triggered cleanup and transition of adb/adb.h and
adb/client/usb_windows.cpp to be moved to Android coding standard.

Test: build
Bug: 63736262
Bug: 38446744
Bug: 66912053
Change-Id: I6eb3f0665b9670b9b3d5f5397f271605b48f4ff0
2017-10-13 07:31:49 -07:00
Elliott Hughes
510552149c Merge "Set $HOSTNAME in adbd."
am: 2364d7ccc5

Change-Id: I40ef480380f250540d6c2856721540400c599111
2017-10-03 22:32:13 +00:00
Elliott Hughes
ba4d9fd933 Set $HOSTNAME in adbd.
bash sets this itself, but mksh doesn't.

This also makes interactive and non-interactive adb shells more similar,
because when we set this in mkshrc that wouldn't affect non-interactive
shells. (I'm not sure whether this is an improvement or not.)

This is certainly _cheaper_ than doing this in mkshrc by calling out to
getprop though.

Bug: N/A
Test: `adb shell printenv` and `adb shell`, `printenv`
Change-Id: I3ff724f19a5098313df83836253f1f7e7872d6a4
2017-10-03 08:44:27 -07:00
Josh Gao
86a919041f Merge "adb: remove SendConnectOnHost."
am: 5eaa5bc081

Change-Id: I899558eb51cda69d9c53288db86cada87a4a0e85
2017-10-02 23:32:49 +00:00
Treehugger Robot
5eaa5bc081 Merge "adb: remove SendConnectOnHost." 2017-10-02 23:27:23 +00:00
Josh Gao
4b5d4da6f6 adb: remove SendConnectOnHost.
This logic appears to be racy, and it shouldn't actually be needed, if
our devices follow the USB spec. Use libusb_set_interface_alt_setting
on device initialization as well, to add one more thing that should
reset the data toggles.

Bug: http://b/32952319
Test: python test_device.py
Change-Id: I392198af3d72c524b893e5056afa2b4617cea49c
2017-10-02 14:38:03 -07:00
Josh Gao
bc3d3625d5 Merge "adbd: improve thread names."
am: 39071a5177

Change-Id: Id41804332dfb81a2bcfd07d3a7180f16e7412bc0
2017-09-29 18:34:17 +00:00
Josh Gao
bcadc77550 adbd: improve thread names.
Name each service thread specifically to improve debuggability.

Bug: http://b/65648324
Test: adb shell debuggerd -b `adb shell pidof adbd` during a sync
Change-Id: I644e25fc2f14a26eafd19f596e4e8f3c2bb79967
2017-09-28 16:45:24 -07:00
Josh Gao
d3f7956f2f Merge "adb: partially revert b5e11415."
am: ef9426d883

Change-Id: I3f7fa1577bc79b5bdcacbeacc7b5141cc9c73cb9
2017-09-27 18:45:18 +00:00
Treehugger Robot
ef9426d883 Merge "adb: partially revert b5e11415." 2017-09-27 18:38:28 +00:00
Tom Cherry
9bc2a967cf Merge "Reland "Remove comments and code about ro.boot.slot""
am: dea5e081ac

Change-Id: Idf32e9600b6a3b93a6a2b4c414cc0193d5d65fb9
2017-09-26 00:08:55 +00:00