Commit graph

3462 commits

Author SHA1 Message Date
Anatol Pomazau
cb0bd19b35 Merge "Add header that declares atomic primitives"
am: 3e59c847cc

Change-Id: I1f3f883354c06c90d9cbf7a7aa2c59526d4e9dcc
2019-08-09 14:48:25 -07:00
Treehugger Robot
3e59c847cc Merge "Add header that declares atomic primitives" 2019-08-09 21:36:41 +00:00
Songchun Fan
25fc86357a Merge "[adb] Cache features set inside the client process"
am: 6e861740ff

Change-Id: I150ca16badd7eb07e2706d3832504adebad68005
2019-08-08 18:05:21 -07:00
Songchun Fan
3487d983d4 Merge "[adb] Speed up the streaming install"
am: 82834f1264

Change-Id: I9705ccd0b9e524b79039d52bcf60bc52af3b514c
2019-08-08 18:03:53 -07:00
Songchun Fan
6e861740ff Merge "[adb] Cache features set inside the client process" 2019-08-09 00:40:51 +00:00
Songchun Fan
82834f1264 Merge "[adb] Speed up the streaming install" 2019-08-09 00:38:50 +00:00
Anatol Pomazau
7b2ff6debc Add header that declares atomic primitives
It fixes a compilation issue:

/fdevent/fdevent_poll.cpp -o core/adb/fdevent/fdevent_poll.cpp.o
In file included from core/adb/fdevent/fdevent_poll.cpp:20:
In file included from core/adb/fdevent/fdevent_poll.h:29:
core/adb/fdevent/fdevent.h:106:10: error: no template named 'atomic' in namespace 'std'
    std::atomic<bool> terminate_loop_ = false;
    ~~~~~^

Change-Id: I5305a69a50e2638f514c5a7d47a9612b8ee38c69
2019-08-08 23:30:42 +00:00
Yurii Zubrytskyi
709dfc3524 [adb] Add a getter for native Win32 file handle
+ adb_pread() and adb_pwrite() functions for simpler cross
  platform file operations

Test: builds
Change-Id: I7e2b23e1da79acd7be974a3d7e1be0fb77d7d2c6
2019-08-08 15:52:21 -07:00
Josh Gao
479627b823 Merge changes I4d6bda45,I72576e1f
am: 6c4cfd6af5

Change-Id: I83c66644227840376d8ee31dfa250539a24f3315
2019-08-08 13:54:00 -07:00
Josh Gao
6c4cfd6af5 Merge changes I4d6bda45,I72576e1f
* changes:
  adb: fix transport acquisition for forward, reverse.
  adb: don't manually construct device selection prefix in forward.
2019-08-08 20:38:15 +00:00
Yurii Zubrytskyi
6eca0e6999 [adb] Speed up the streaming install
1. Use bigger buffer for transfers - 64kb is the default size
   for push, so let it be the same in streaming

2. Use abb when it's available for lower overhead

3. Add a posix_fadvise() on the source APK

4. Increase buffer sizes for the socketpair that's transferring
the data from adbd.

Overall this saves about 25% time for streaming installations
and makes it faster than the legacy push (at last!)

Test: manual
Change-Id: Ieb84284da2058944815e062ef6e4389b842565fa
2019-08-08 12:55:51 -07:00
Josh Gao
5ae4a90400 adb: windows: fix writev on sockets.
Bug: http://b/139078301
Test: treehugger
Change-Id: I000c12ef9dedad530a166175cf089df45378f759
2019-08-07 18:26:47 -07:00
Josh Gao
3346339fcb adb: fix transport acquisition for forward, reverse.
Previously, we were calling acquire_one_transport with all empty
parameters, which would work when only one device is connected, but fail
when there are multiple. We've already acquired a transport and put it
into the socket as part of the forward request, so just use that
directly.

Bug: http://b/136198949
Test: test_device.py with multiple devices connected
Change-Id: I4d6bda45b36b71e418ecd9ead61b7379e68aa19b
2019-08-06 17:01:11 -07:00
Josh Gao
da9c767826 adb: don't manually construct device selection prefix in forward.
Use the existing infrastructure instead.

Test: test_adb.py
Test: test_device.py
Change-Id: I72576e1fb922af71852b50ddb3f4cb5c39eb333f
2019-08-06 16:43:34 -07:00
Elliott Hughes
09529e67cb Merge "adb: fail better in install-multiple."
am: 91a531897a

Change-Id: I6ec95d607c686c380fcdcad55bf6afb7bf0c44e3
2019-08-06 12:46:22 -07:00
Elliott Hughes
62d73aba8d Merge "adb: add --abi to the adb install help."
am: dad291fc46

Change-Id: Ib6d5bef802f05abeb680ed1f406925ceb32053a7
2019-08-06 12:40:57 -07:00
Elliott Hughes
b2b26672d0 Merge "Fix adb install on very old Android releases."
am: 8c4db55f66

Change-Id: Ie7328c2ec7aa9e8983824afb6239fce5d984847d
2019-08-06 12:40:23 -07:00
Elliott Hughes
91a531897a Merge "adb: fail better in install-multiple." 2019-08-06 19:33:34 +00:00
Elliott Hughes
dad291fc46 Merge "adb: add --abi to the adb install help." 2019-08-06 19:31:54 +00:00
Elliott Hughes
8c4db55f66 Merge "Fix adb install on very old Android releases." 2019-08-06 19:31:44 +00:00
Elliott Hughes
541d7408c1 adb: fail better in install-multiple.
If we're failing out, don't print any messages from the shutdown code:
it's not interesting (and actively confusing!) to talk about the
"Success" of finalizing an aborted session.

Also fail early if stat fails the first time (we have to tell
PackageManager how much data to expect, for some reason).

Also use `bool` as the boolean type and add quotes around filenames in
error messages.

`install_multi_package` looks like the same nonsense copy & pasted, but
I don't know what that is, and haven't seen any bug reports, so I'm
ignoring that for now.

Bug: http://b/133522725
Test: manual
Change-Id: Id054dff44f21f4c4cc5877dcc2735fc1eb25f9a0
2019-08-05 17:06:04 -07:00
Elliott Hughes
c0ebd59073 adb: add --abi to the adb install help.
A bit of a break with convention, but we do already document `-t` which
is actually a PackageManager option, not an adb option, and `--abi`
seems like it'll be seeing increased usage these next few years.

Also add a pointer to `adb shell pm help` for full details of
PackageManager options.

Bug: http://b/122487331
Test: manual
Change-Id: I93f48d202e5707b27caadb5af2a65c485c6d3407
2019-08-02 17:09:30 -07:00
Elliott Hughes
94350737e3 Fix adb install on very old Android releases.
See the code comment for the gory details.

Bug: https://issuetracker.google.com/37035817
Bug: http://b/37704384
Test: manual testing on a variety of devices & emulators
Change-Id: If9e481924a8a2f3ec1e926342b2ecd522fa933a2
2019-08-02 16:10:45 -07:00
Yurii Zubrytskyi
e800af5c23 [adb] Cache features set inside the client process
Test: manual
Change-Id: I99962edd85e9694c3ca309624368cda6355da008
2019-08-02 11:37:32 -07:00
Yurii Zubrytskyi
d3d650628c [adb] Use STL for ParseUInt() implementation
Test: builds
Change-Id: I8c4d4f24e3496601362fcbbdaa071a29ab9f360a
2019-08-02 11:33:41 -07:00
Elliott Hughes
8836527a1f Merge "adb: fix track-devices-l."
am: 6bac7cd942

Change-Id: I75f4941199c402b79b21b587c30186ee9fff6ecb
2019-07-31 18:54:04 -07:00
Elliott Hughes
fc2f5f6728 adb: fix track-devices-l.
Also add a -l to the undocumented `adb track-devices` for easier
testing.

Bug: https://issuetracker.google.com/118470090
Test: manual
Change-Id: I436f6e45b249b98a073aa147ad4ed67d4d87f9bd
2019-07-31 14:14:59 -07:00
Elliott Hughes
45e2255f65 Merge "Restore default port for adb connect."
am: 690c8c8f25

Change-Id: I6e5edbe8389473c775d986e37d4774e1a8517751
2019-07-31 13:14:58 -07:00
Elliott Hughes
23b37f43b6 Merge "Allow overriding the log path."
am: 11295b7f8b

Change-Id: I7f34ba23b540850518713b88a11409946d02bd26
2019-07-31 13:14:19 -07:00
Elliott Hughes
1a58f4f36d Merge "Clarify adb sync -l help text."
am: 51406823c1

Change-Id: Ia09293aef5c8b863f43a84c963fd84297d309746
2019-07-31 13:12:54 -07:00
Elliott Hughes
690c8c8f25 Merge "Restore default port for adb connect." 2019-07-31 19:48:02 +00:00
Treehugger Robot
11295b7f8b Merge "Allow overriding the log path." 2019-07-31 19:44:58 +00:00
Treehugger Robot
51406823c1 Merge "Clarify adb sync -l help text." 2019-07-31 19:44:49 +00:00
Elliott Hughes
573e67cbeb Restore default port for adb connect.
The default port of 5555 was removed a while back, but the help text was
never updated, and other contexts still allow a default port.

Bug: https://issuetracker.google.com/128561172
Test: manual
Change-Id: I6e5e6edeb2243386a0301c0a6cad569189f9910e
2019-07-30 21:55:56 -07:00
Josh Gao
e21440e547 Merge "adb: avoid leaking pty master FDs."
am: 47757e93aa

Change-Id: If6f73cd4d04c33b5f569d59c329b314e79efe572
2019-07-30 20:20:59 -07:00
Treehugger Robot
47757e93aa Merge "adb: avoid leaking pty master FDs." 2019-07-31 02:55:35 +00:00
Joshua Gilpatrick
a84882427e Merge "Fastdeploy converted to c++ and bin2c on the jar."
am: 60fa8b8ad2

Change-Id: Ied5f860f08599c5ab236ecca084effbb90f93285
2019-07-30 15:46:02 -07:00
Josh Gao
6733b2bf38 adb: avoid leaking pty master FDs.
Reimplement openpty with O_CLOEXEC to avoid accidentally leaking pty
master FDs.

Bug: http://b/138297062
Test: manual
Change-Id: I6d83c909232a95c9f03370f078aec7b0911d7369
2019-07-30 14:48:57 -07:00
Elliott Hughes
1a9da399cb Allow overriding the log path.
Bug: https://issuetracker.google.com/112588493
Test: manual
Change-Id: Ic273d46544479332b8e031f30feadd1840f2d653
2019-07-30 12:26:31 -07:00
Elliott Hughes
4c8ea89afb Clarify adb sync -l help text.
Seems like the bug submitter thought that -l listed the partitions shown
on the line above, rather than the files. Be more explicit.

Bug: https://issuetracker.google.com/73122762
Test: treehugger
Change-Id: I6ed1027639a5b785a5992909430d739958d10ad7
2019-07-30 10:32:53 -07:00
Joshua Gilpatrick
af3ce0876c Fastdeploy converted to c++ and bin2c on the jar.
Test: Added test for DeployPatchGenerator and PatchUtils cpp files.
Bug: 138130943
Change-Id: I6a128eff4cda00dd05c1bccec71e2678a8b13324
2019-07-29 12:00:09 -07:00
Josh Gao
f2dd09ff5b Merge "adb: switch from system_clock to steady_clock."
am: 278754aeac

Change-Id: Ifd0e99d4caade013ed809d21818fa5f5fc86f1bf
2019-07-23 18:31:24 -07:00
Josh Gao
63e8d9815f adb: switch from system_clock to steady_clock.
Test: treehugger
Change-Id: I10b884dc159a5ba624bc0f7ad53a402bffb14293
2019-07-22 16:18:25 -07:00
Josh Gao
1c8ecd77cd Merge changes I35f8843e,Icd2a94f8,I6c20f3b3
am: 1f1a0009fc

Change-Id: I13b66d553915bf4bdada12e854214d3232150423
2019-07-17 11:20:59 -07:00
Josh Gao
1f1a0009fc Merge changes I35f8843e,Icd2a94f8,I6c20f3b3
* changes:
  adb: win32: don't shutdown socket when closing.
  adb: win32: silence wine test failure.
  adb: win32: fix adb_test.
2019-07-17 18:04:29 +00:00
Josh Gao
08bd13eb3d adb: win32: don't shutdown socket when closing.
This appears to be an attempt to do orderly shutdown, but it doesn't
wait until the socket becomes readable, so it doesn't actually work. We
implement orderly shutdown elsewhere already, so delete this so that we
don't accidentally shutdown a duped socket.

Test: wine adb_test
Change-Id: I35f8843e8e6dbc7886fd545f0e43375a005e160f
2019-07-16 15:22:58 -07:00
Josh Gao
2ad4c3696f adb: win32: silence wine test failure.
Wine implements sockets with their own internal socketpair, which
results in the poll disconnect test failing.

Bug: http://b/117568356
Test: wine adb_test.exe
Change-Id: Icd2a94f8297fefd5c02e6517568fe288b168032c
2019-07-16 15:22:51 -07:00
Josh Gao
efd8ae2d54 adb: win32: fix adb_test.
At some point between Q and master, adb_test.exe stopped working because
it wasn't being linked with -municode?

Test: wine adb_test.exe
Change-Id: I6c20f3b3241cee2052d31d1ca85b8a9738828f6e
2019-07-16 15:21:59 -07:00
Steven Moreland
1c9abb85cb Merge "libadbd_services: remove unused deps"
am: a1821e13f3

Change-Id: I8ebee3fde274c70f60b3419c3dc920de51a87213
2019-07-12 10:10:55 -07:00
Steven Moreland
e0d94b6493 libadbd_services: remove unused deps
Bug: 137311188
Test: library still builds
Change-Id: I52e110ddfda073c833e86194eaf7a9502b9181a6
2019-07-11 16:13:10 -07:00
Josh Gao
d057fb5345 Merge changes from topic "fdevent_refactor"
am: 88d23135d2

Change-Id: I5871b36885fbeb5db594d5bb60b043dbd41ff3bb
2019-07-09 13:38:26 -07:00
Josh Gao
77e1372ad9 adb: fdevent: extract Create/Destroy from fdevent_context_poll.
am: 33944a2742

Change-Id: Ie999135e7a60d01848e3ccee13d93135ab2170e8
2019-07-09 13:38:10 -07:00
Josh Gao
296977fed9 adb: fdevent: move TerminateLoop to fdevent_context.
am: ebaa348d32

Change-Id: Ide34c57e2614e43a735249dbaba5277015cb47d4
2019-07-09 13:37:57 -07:00
Josh Gao
57c060a4b8 adb: fdevent: move CheckMainThread logic to fdevent_context.
am: 2c95bf73a5

Change-Id: I27a9059d7009218551b65c1c59db082e87b86c60
2019-07-09 13:37:44 -07:00
Josh Gao
f46ca64f08 adb: fdevent: delete FDE_CREATED.
am: e546f6816e

Change-Id: I3f89664e32fe80af05e5ebc35d333533bfd97745
2019-07-09 13:37:32 -07:00
Josh Gao
3f06c2ba19 adb: fdevent: move run queue to fdevent_context.
am: 95eef6b097

Change-Id: I131984a407220281364c016f832aef45e0f9a457
2019-07-09 13:37:20 -07:00
Josh Gao
8935c1c89f adb: implement fdevent_reset by constructing a new context.
am: 7adca93fe9

Change-Id: Iefd84fb5453ed757feb3b8431c7b31f99e39541e
2019-07-09 13:36:59 -07:00
Josh Gao
e62c2c2485 adb: move fdevent implementation out to a separate file.
am: 95068bbd9a

Change-Id: I4000e495ab9f73863fa7cf8ce5d4742e43a4b020
2019-07-09 13:36:44 -07:00
Josh Gao
b0168bcb04 adb: de-globalize fdevent context.
am: c2cf121174

Change-Id: Ic01cd85b2742ff73399007431f696b0dc372ef50
2019-07-09 13:36:04 -07:00
Josh Gao
261569d533 adb: move fdevent to its own folder.
am: 57e09b16ca

Change-Id: I1f9e0da9a94c8889c378e8ca9dd9b37a48dca58b
2019-07-09 13:35:38 -07:00
Josh Gao
88d23135d2 Merge changes from topic "fdevent_refactor"
* changes:
  adb: fdevent: extract Add/Del/SetTimeout.
  adb: fdevent: extract Create/Destroy from fdevent_context_poll.
  adb: fdevent: move TerminateLoop to fdevent_context.
  adb: fdevent: move CheckMainThread logic to fdevent_context.
  adb: fdevent: delete FDE_CREATED.
  adb: fdevent: move run queue to fdevent_context.
  adb: implement fdevent_reset by constructing a new context.
  adb: move fdevent implementation out to a separate file.
  adb: de-globalize fdevent context.
  adb: move fdevent to its own folder.
  adb: add superfluous include.
2019-07-09 20:02:29 +00:00
Justin Yun
6069891e84 Merge "Rename product_services to system_ext"
am: 5ffffb4f30

Change-Id: I4bdddd6074461f1db7f6be85120ad5f32f45fbb3
2019-07-09 02:15:04 -07:00
Justin Yun
5d0ac62995 Rename product_services to system_ext
Update adb, fastboot and mount point

Bug: 134359158
Test: build and check if system_ext.img can be flashed
Change-Id: I6219f72242c5fe42a508008c0b1fd218d74da5b6
2019-07-09 08:56:53 +00:00
Josh Gao
33944a2742 adb: fdevent: extract Create/Destroy from fdevent_context_poll.
Test: adb_test
Change-Id: Ida308e8e281cbb2954277196a51945f124ce5823
2019-07-08 18:32:24 -07:00
Josh Gao
ebaa348d32 adb: fdevent: move TerminateLoop to fdevent_context.
Test: adb_test
Change-Id: Ib1f20aefdb36603e2ceac4197c02551f557056ee
2019-07-08 18:32:24 -07:00
Josh Gao
2c95bf73a5 adb: fdevent: move CheckMainThread logic to fdevent_context.
Test: adb_test
Change-Id: I10b93293af22d54ec739dc0f95c95df3ab082fb6
2019-07-08 18:32:24 -07:00
Josh Gao
35b29360a2 adb: fdevent: extract Add/Del/SetTimeout.
Test: adb_test
Change-Id: Ibed301f8de73289837153fdfed370a681c24ac55
2019-07-08 18:32:24 -07:00
Josh Gao
e546f6816e adb: fdevent: delete FDE_CREATED.
All fdevents must be created by fdevent_create/fdevent_context::Create
now, so this flag is meaningless.

Test: none
Change-Id: I8489afad07bdb267ddfdb0dbb25d40d3a62f55f6
2019-07-08 18:05:55 -07:00
Josh Gao
95eef6b097 adb: fdevent: move run queue to fdevent_context.
Make the run queue logic reusable between implementations of fdevent by
moving it to the abstract base class.

Test: adb_test
Change-Id: If2f72e3ddc8007304bca63aa75446fa117267b25
2019-07-08 18:05:47 -07:00
Josh Gao
7adca93fe9 adb: implement fdevent_reset by constructing a new context.
Test: adb_test
Change-Id: Ie67afafe2b73fb2a8fc08568560adac6f456eb9a
2019-07-08 17:32:14 -07:00
Alex Buynytskyy
339fcd996a Merge "Refactorings to match adb_abb to adb_shell code."
am: 463773b733

Change-Id: Ia4724a38e8474bbae94c640ccd9cb3cf7d8f1915
2019-07-08 17:19:47 -07:00
Josh Gao
95068bbd9a adb: move fdevent implementation out to a separate file.
Test: mma
Change-Id: I8af945b9ae0accac75fa93c538e44cbab357bb5d
2019-07-08 16:03:27 -07:00
Josh Gao
c2cf121174 adb: de-globalize fdevent context.
Test: adb_test
Test: adbd_test
Change-Id: If711257d831b9090b38412821466c1d358d53d2d
2019-07-08 14:37:27 -07:00
Josh Gao
57e09b16ca adb: move fdevent to its own folder.
Preparatory refactoring for platform-specific implementations.

Test: mma
Change-Id: I0f600122ac89241788c5f3300f362fd9ef02ddcd
2019-07-08 14:37:27 -07:00
Josh Gao
2d03ad42ed adb: add superfluous include.
Resolve a merge conflict between internal and aosp by making aosp look
like internal.

Test: none
Change-Id: I7bea6ab61ad45ff20a3d07abf3f73903a7c05585
Merged-In: If73b81ca73ba4d64763cf49c1bbe42de81fa1cb6
2019-07-08 14:37:27 -07:00
Alex Buynytskyy
cc2f124070 Refactorings to match adb_abb to adb_shell code.
Test: Build, flash and boot, use `adb abb` to verify

Change-Id: I30eb6e8a4fd43b1548a9398376c72e2cb31223a4
2019-07-08 18:30:26 +00:00
Josh Gao
22c98da7e7 Merge "adbd: move jdwp listening logic into ART." am: d194013097
am: 56d33633c2

Change-Id: I40666175760849bd27a94437422559f7b9caba7f
2019-06-28 12:17:22 -07:00
Josh Gao
d194013097 Merge "adbd: move jdwp listening logic into ART." 2019-06-28 19:01:38 +00:00
Josh Gao
5f2c5bbd04 adbd: move jdwp listening logic into ART.
Test: manually use jdwp
Change-Id: Ia09a5c643cba9ec5f343c9767d43d72b077bc247
2019-06-25 12:37:20 -07:00
Dan Albert
134c98814a Revert "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor"
am: ba4684c2b2

Change-Id: I030ce911424f7315cd3b9c4f299b4232ee81e9aa
2019-06-25 08:01:04 -07:00
Dan Albert
38bdc11d4b Revert "adb: turn CHECKs into an error + transport restart."
am: 2547f740ea

Change-Id: I6855ae62f61d9d1cc234dd15de5ce4a3b39d6faf
2019-06-25 08:01:00 -07:00
Elliott Hughes
7d9841a07c Merge "Revert "Reland "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND.""" am: 12794c039a
am: 6c79fd22be

Change-Id: Iafcc88c0441225d9279ff145c718be77851d639b
2019-06-24 23:34:54 -07:00
Elliott Hughes
12794c039a Merge "Revert "Reland "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND.""" 2019-06-25 05:56:53 +00:00
Elliott Hughes
fab9f30f6f Revert "Reland "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND.""
This reverts commit b00e66f754.

Reason for revert: http://b/135753060

Change-Id: I30f472427f52076b64902420f9538b4a880a2cbe
2019-06-25 05:42:55 +00:00
Dan Albert
ba4684c2b2 Revert "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor"
This reverts commit b2d79c5e48.

Bug: http://b/135753060
Test: treehugger
Change-Id: I2b1b2b7dfb7bab783e4ed40e295329525ceaa0dd
2019-06-24 14:36:43 -07:00
Dan Albert
2547f740ea Revert "adb: turn CHECKs into an error + transport restart."
This reverts commit b41d7ae1a9.

Bug: http://b/135753060
Test: treehugger
Change-Id: Ib7cd7b7eaffa55ec2884a096a1c11739b12af6d1
2019-06-24 14:36:41 -07:00
Dan Albert
782036b7af Revert "Reland "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND.""
This reverts commit c33aee8ac1.

Bug: http://b/135753060
Test: treehugger
Change-Id: Ic83a44e7c8f860a6c044ca20ec81f365a8a6ba4b
2019-06-24 14:36:31 -07:00
Josh Gao
c33aee8ac1 Reland "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND."
Read until we receive FUNCTIONFS_BIND after every USB descriptor setup,
instead of only after initial creation of the control fd, so we properly
handle a rebind caused by a change of the USB configuration.

This reverts commit 55b31933f41b1c550b788fa2054010c51f56111b.

Bug: http://b/133132986
Bug: http://b/135155652
Test: manually enabled/disabled MTP with nonblocking_ffs enabled and disabled
Change-Id: Ibb3f46b8f84854ede47a669a85e07e16a5dd6008
Merged-In: Ibb3f46b8f84854ede47a669a85e07e16a5dd6008
(cherry picked from commit b00e66f754)
2019-06-21 14:29:21 -07:00
Josh Gao
b2e5ca2328 Merge "Reland "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND."" am: 2a6ec6c332
am: 5c7c698a97

Change-Id: I94222297a504954ddca5f6ec9b3f7a077e4d0647
2019-06-20 20:02:58 -07:00
Josh Gao
2a6ec6c332 Merge "Reland "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND."" 2019-06-21 02:36:56 +00:00
Josh Gao
b41d7ae1a9 adb: turn CHECKs into an error + transport restart.
These CHECKs are expected to happen if the client does the wrong thing,
so we probably shouldn't be aborting in adbd.

Bug: http://b/133872605
Bug: http://b/134695864
Test: treehugger
Change-Id: I875b87a06ba9d399db26f8af1ad47ccf34e9445a
Merged-In: I875b87a06ba9d399db26f8af1ad47ccf34e9445a
(cherry picked from commit fc0f80ae49)
2019-06-19 15:01:02 -07:00
Josh Gao
b2ea09115c Merge "adb: turn CHECKs into an error + transport restart." am: ad0f27fe72
am: 7373282999

Change-Id: I60415fb9fefb59585e27ba4181a9a69168709758
2019-06-18 21:28:08 -07:00
Treehugger Robot
ad0f27fe72 Merge "adb: turn CHECKs into an error + transport restart." 2019-06-19 00:11:49 +00:00
Josh Gao
b00e66f754 Reland "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND."
Read until we receive FUNCTIONFS_BIND after every USB descriptor setup,
instead of only after initial creation of the control fd, so we properly
handle a rebind caused by a change of the USB configuration.

This reverts commit 55b31933f41b1c550b788fa2054010c51f56111b.

Bug: http://b/133132986
Bug: http://b/135155652
Test: manually enabled/disabled MTP with nonblocking_ffs enabled and disabled
Change-Id: Ibb3f46b8f84854ede47a669a85e07e16a5dd6008
2019-06-18 15:00:15 -07:00
Josh Gao
7c3b87ffd2 Merge "Revert "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND."" am: a6f90ce599
am: 099fc95530

Change-Id: Iaa1d67735ed8a4c582c42b630cf90c2c384fd2f6
2019-06-14 16:55:35 -07:00
Josh Gao
9dba0f5824 Revert "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND."
We're only reading FUNCTIONFS_BIND on creation upon the first creation
of the control fd, which results in an abort when rebind happens (e.g.
when MTP is enabled) and we unexpectedly read FUNCTIONFS_BIND in the
second instantiation of the connection.

This reverts commit 2b668d3906.

Bug: http://b/135155652
Test: manually enabled MTP
2019-06-14 16:21:21 -07:00
Josh Gao
fc0f80ae49 adb: turn CHECKs into an error + transport restart.
These CHECKs are expected to happen if the client does the wrong thing,
so we probably shouldn't be aborting in adbd.

Bug: http://b/133872605
Bug: http://b/134695864
Test: treehugger
Change-Id: I875b87a06ba9d399db26f8af1ad47ccf34e9445a
2019-06-13 13:16:57 -07:00
Hemant Kumar
b2d79c5e48 adb: daemon: Assign valid fd to usb_handle ep0 file descriptor
Bug: http://b/129283234
Test: treehugger
Change-Id: I2d005e17ccb45af95351c074cc53f6cfc53b5fdd
Merged-In: I2d005e17ccb45af95351c074cc53f6cfc53b5fdd
(cherry picked from commit 1cbe5edbc3)
2019-06-13 12:38:19 -07:00
Josh Gao
db51d08cc8 Merge "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND." am: cb2352a75d
am: b965eea9c6

Change-Id: I81d74942931f8ede3e0c29d1ecef08d3f4f8149c
2019-06-12 07:53:09 -07:00
Treehugger Robot
cb2352a75d Merge "adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND." 2019-06-12 14:34:14 +00:00
Josh Gao
2b668d3906 adbd: don't close ep0 until we receive FUNCTIONFS_UNBIND.
Rework the functionfs logic to avoid rebinding the USB interface
repeatedly.

Bug: http://b/133132986
Test: treehugger
Change-Id: I7f75874efd197764d40b66800a117ff4726d793b
2019-06-11 20:33:16 -07:00
Josh Gao
bcb3f13d00 Merge "adb: avoid freeing argv entries on Windows." am: 5b63cff411
am: c62f2aca24

Change-Id: Icbb6320d1399efe48efaa8c7a45789b42f63b049
2019-06-10 19:00:44 -07:00
Josh Gao
e72c44b24a adb: avoid freeing argv entries on Windows.
We assign string literals directly to argv[0], which leads to fun
explosions when we attempt to free  when the runtime can detect that
a bad free happened, which seems to happen reliably with lld.

Bug: http://b/110800681
Test: `adb shell true` on windows
Change-Id: Ica81e472c31686d80b58c41ff6d2b825baef06fb
2019-06-10 12:54:14 -07:00
Tao Bao
73a810993d Merge "adb: Allow adb rescue getprop." am: 8eea2cae86
am: a04d17174d

Change-Id: Iedcc4f3337e2c77bd21a8a8ac9f302a20f568660
2019-06-05 14:12:51 -07:00
Tao Bao
8eea2cae86 Merge "adb: Allow adb rescue getprop." 2019-06-05 20:43:55 +00:00
Josh Gao
8e707dede9 Merge changes I2d005e17,If2eec162,Icfd642e6 am: 2683d0a2ca
am: 961b03661a

Change-Id: I8a6957e1944389d2d6b162fdc8d97b430f353fbe
2019-06-04 19:31:37 -07:00
Josh Gao
a00228b646 Merge "adbd: provide MS OS descriptors for WinUSB." am: a891ffddd3
am: 91aa2ef730

Change-Id: I6c6e0675358e748c1228ce87626726fdccb2f533
2019-06-04 19:25:24 -07:00
Tao Bao
599eee1f37 adb: Allow adb rescue getprop.
Which will dump all the allowed properties, similar to `adb shell
getprop`.

Bug: 134027350
Test: Run the command under rescue mode.
Change-Id: Id668224098006d71ee192c8c2bea5d791d2423c1
2019-06-04 14:59:58 -07:00
Josh Gao
2683d0a2ca Merge changes I2d005e17,If2eec162,Icfd642e6
* changes:
  adb: daemon: Assign valid fd to usb_handle ep0 file descriptor
  adbd: respond to device-to-host control transfers.
  adbd: read, print, and ignore USB control transfers.
2019-06-04 19:22:08 +00:00
Josh Gao
a891ffddd3 Merge "adbd: provide MS OS descriptors for WinUSB." 2019-06-04 19:22:00 +00:00
Mohammad Samiul Islam
361a99a3c4 Merge "Allow adb to handle single paramter with install-multi-package flag" am: d877a96656
am: c625e74d88

Change-Id: Ibbe33e4a9290b5e3b40898f7c75e58982ce47ae7
2019-06-03 16:04:00 -07:00
Treehugger Robot
d877a96656 Merge "Allow adb to handle single paramter with install-multi-package flag" 2019-06-03 22:49:48 +00:00
chihhao.chen
c097a5786d Merge "Fix non-aio USB read issue for fastbootd" into qt-dev
am: 9122289a97

Change-Id: I0274561a806f027452bf814a8e0cafbd5a7e0a85
2019-05-29 16:34:29 -07:00
TreeHugger Robot
9122289a97 Merge "Fix non-aio USB read issue for fastbootd" into qt-dev 2019-05-29 23:11:55 +00:00
chihhao.chen
8c544b6fd8 Fix non-aio USB read issue for fastbootd
non-aio USB read function was stuck in a loop waiting for more data
because data length parameter is always set 64 for fastbootd commands.
It should be a normal case to get less data than expected
since lengths of these commands are usually less than 64.
Add logic to check this and one more parameter to distinguish
fastbootd from general adbd case.

Bug: 133189029
Test: try various fastbootd commands
Change-Id: I6690324840d78f3f1e04235040301520329976db
Merged-In: I6690324840d78f3f1e04235040301520329976db
2019-05-29 23:10:50 +00:00
chihhao.chen
5f8b966d96 Fix non-aio USB read issue for fastbootd
non-aio USB read function was stuck in a loop waiting for more data
because data length parameter is always set 64 for fastbootd commands.
It should be a normal case to get less data than expected
since lengths of these commands are usually less than 64.
Add logic to check this and one more parameter to distinguish
fastbootd from general adbd case.

Bug: 133189029
Test: try various fastbootd commands
Change-Id: I6690324840d78f3f1e04235040301520329976db
2019-05-29 12:41:55 -07:00
Mohammad Samiul Islam
b581ce93bb Allow adb to handle single paramter with install-multi-package flag
Bug: 130164367
Test: $adb install-multi-package dummy.apk
      It installs successfully.

Change-Id: I5775813d10b7a8d865518ce5480a401e8f41e876
2019-05-29 15:00:00 +01:00
Hemant Kumar
1cbe5edbc3 adb: daemon: Assign valid fd to usb_handle ep0 file descriptor
Bug: http://b/129283234
Test: treehugger
Change-Id: I2d005e17ccb45af95351c074cc53f6cfc53b5fdd
2019-05-28 17:53:24 -07:00
Josh Gao
43a0a9a5bf adbd: respond to device-to-host control transfers.
Failing to write to the endpoint results in subsequent reads on ep0 to
fail with EL2HLT, so do an empty write to fulfill the transfer.

Bug: http://b/131867920
Test: manually tested with modified auto client
Change-Id: If2eec162ca4b31a9974c7bd5802be51cee9e2708
Merged-In: If2eec162ca4b31a9974c7bd5802be51cee9e2708
(cherry-picked from internal commit af086e9a95)
2019-05-28 17:52:11 -07:00
Josh Gao
fc2e2003dd adbd: read, print, and ignore USB control transfers.
It seems like we're blowing up when receiving a control transfer that's
intended for Android Auto, because we're not expecting to get the data
for the control transfer in a subsequent read.

Bug: http://b/131867920
Test: none
Change-Id: Icfd642e6dfc02d2ccbdd60c39f89e534298c944d
Merged-In: Icfd642e6dfc02d2ccbdd60c39f89e534298c944d
(cherry-picked from internal commit 12807c7012)
2019-05-28 17:51:05 -07:00
Josh Gao
527d6dd738 Merge "adbd: respond to device-to-host control transfers." into qt-dev
am: 8ef22b102c

Change-Id: Ia371254756e7d951064607226b4f9cfc67832c0b
2019-05-22 16:15:04 -07:00
Josh Gao
db64696b7c adbd: provide MS OS descriptors for WinUSB.
Add Microsoft OS Descriptors so that on Windows, we get automatically
registered with the WinUSB driver instead of requiring a different INF
to be used with device with a different vendor ID.

Bug: http://b/68993980
Test: manually changed the vendor ID on a blueline and connected it to a Windows VM
Change-Id: Id78bae270df9805573a90a86019267b53a3c8252
2019-05-22 14:58:13 -07:00
Josh Gao
af086e9a95 adbd: respond to device-to-host control transfers.
Failing to write to the endpoint results in subsequent reads on ep0 to
fail with EL2HLT, so do an empty write to fulfill the transfer.

Bug: http://b/131867920
Test: manually tested with modified auto client
Change-Id: If2eec162ca4b31a9974c7bd5802be51cee9e2708
2019-05-21 16:39:51 -07:00
Josh Gao
26a6faf0ae Merge "adbd: read, print, and ignore USB control transfers." into qt-dev
am: 6031286936

Change-Id: I3e1a2052406b3399f7e11176ac2aca1adcb20f52
2019-05-20 17:17:31 -07:00
TreeHugger Robot
7eeed22871 Merge "adbd: reduce queue depths." into qt-dev 2019-05-21 00:05:34 +00:00
TreeHugger Robot
5b882637e1 Merge "adbd: avoid starting multiple worker threads." into qt-dev 2019-05-21 00:04:15 +00:00
Josh Gao
12807c7012 adbd: read, print, and ignore USB control transfers.
It seems like we're blowing up when receiving a control transfer that's
intended for Android Auto, because we're not expecting to get the data
for the control transfer in a subsequent read.

Bug: http://b/131867920
Test: none
Change-Id: Icfd642e6dfc02d2ccbdd60c39f89e534298c944d
2019-05-17 18:34:23 -07:00
Evgenii Stepanov
9da358d6d3 Initialize all fields of struct iocb.
Kernel does not accept non-zero value of iocb->aio_reserved2.

Bug: 132803232
Test: initialize malloc() memory to non-zero pattern and see what breaks

Change-Id: I65a7e89e3a2c1ba79df1dc2d011d6c76c41afb81
(cherry picked from commit fe7eca7b8f)
2019-05-16 12:55:41 -07:00
Evgenii Stepanov
79b1dc0106 Merge "Initialize all fields of struct iocb." am: 6e06bcce9c
am: 37c81fd6f0

Change-Id: I3c8155e222b7e7f4277d5654f85e7006a777dd16
2019-05-16 00:03:37 -07:00
Evgenii Stepanov
fe7eca7b8f Initialize all fields of struct iocb.
Kernel does not accept non-zero value of iocb->aio_reserved2.

Bug: 132803232
Test: initialize malloc() memory to non-zero pattern and see what breaks

Change-Id: I65a7e89e3a2c1ba79df1dc2d011d6c76c41afb81
2019-05-15 18:46:18 -07:00
TreeHugger Robot
82ebfca5cd Merge "adbd: don't abort on EOF on functionfs control fd." into qt-dev 2019-05-13 22:21:59 +00:00
Josh Gao
127da2ab6d Merge "adbd: don't abort on EOF on functionfs control fd." am: 41531df7b0
am: f848fac660

Change-Id: I9fda92cd15fa84318759a37606429621a0797d36
2019-05-13 11:58:57 -07:00
Josh Gao
1f7ae9d4e3 adbd: don't abort on EOF on functionfs control fd.
Also, improve the logging in the cases where we do abort.

Bug: http://b/131867920
Test: treehugger
Change-Id: If8ec9f4614ce146e6dbd21cc77587ea81658199b
(cherry picked from commit 2916e148d9)
2019-05-13 11:42:29 -07:00
Josh Gao
41531df7b0 Merge "adbd: don't abort on EOF on functionfs control fd." 2019-05-13 18:40:34 +00:00
Michael Groover
69277fb9c5 Merge "Notify the framework when an adb key is authorized" into qt-dev
am: b9c555e2cf

Change-Id: I664ba3acfb8295ccf7b773e07d2d007ff942bc40
2019-05-10 17:21:47 -07:00
Elliott Hughes
7b4bd88aa0 Merge "Clean up copy & paste from frameworks/base/cmds." am: d203a508ff
am: 9dedcc81ad

Change-Id: I2b851d9b6e8e60bd518fc209d263014c72c7c5b4
2019-05-10 17:12:42 -07:00
Treehugger Robot
d203a508ff Merge "Clean up copy & paste from frameworks/base/cmds." 2019-05-10 22:00:23 +00:00
Josh Gao
2916e148d9 adbd: don't abort on EOF on functionfs control fd.
Also, improve the logging in the cases where we do abort.

Bug: http://b/131867920
Test: treehugger
Change-Id: If8ec9f4614ce146e6dbd21cc77587ea81658199b
2019-05-10 11:37:34 -07:00
Al Sutton
4983a007cf Merge "Add deprecation warning to adb backup/restore" am: 09070afd38
am: 2cf161bcc7

Change-Id: Icaa05ed20fb043c98bc440a1a36390b2396eb227
2019-05-10 03:42:06 -07:00
Al Sutton
09070afd38 Merge "Add deprecation warning to adb backup/restore" 2019-05-10 08:40:50 +00:00
Stephen Hines
e5c452085b Merge "NFC: Fix potentially uninitialized 'port' variable." am: f0d59e24c3
am: 68b69c35b7

Change-Id: I3df8fa238dfaba119caad661914f59489d5c8207
2019-05-09 22:15:13 -07:00
Josh Gao
0bd7a96967 Merge "Revert "Revert "Add a way to turn off unique_fd's operator int.""" am: fe1d1e815f
am: 0df5a1cb66

Change-Id: I8cc21b88841d6a7b7b93efafbc89939540350214
2019-05-09 22:14:23 -07:00
Elliott Hughes
e98971c06e Clean up copy & paste from frameworks/base/cmds.
Test: treehugger
Change-Id: I337e6f7e48d4debfce010ad4b6f9fcb860c13fb7
2019-05-09 22:05:13 -07:00
Treehugger Robot
f0d59e24c3 Merge "NFC: Fix potentially uninitialized 'port' variable." 2019-05-10 01:34:56 +00:00
Michael Groover
7eeda6ba03 Notify the framework when an adb key is authorized
Bug: 124076524
Test: atest AdbDebuggingManagerTest
Change-Id: If73b81ca73ba4d64763cf49c1bbe42de81fa1cb6
2019-05-09 16:05:40 -07:00
Stephen Hines
391c40b9ec NFC: Fix potentially uninitialized 'port' variable.
Bug: http://b/131390872
Test: Builds with -Wconditional-uninitialized.
Change-Id: Ie699ec39307fb3b66ade8248cdbe3d6de42533a7
2019-05-09 12:55:41 -07:00
Al Sutton
31d335f39f Add deprecation warning to adb backup/restore
Test: Manual execution and verification of the message
Fixes: 131891013
Change-Id: Idc38fcdace2d79668a4daac0b99fb87d04fb4cb8
2019-05-09 16:14:05 +00:00
Josh Gao
27241a7a96 Revert "Revert "Add a way to turn off unique_fd's operator int.""
The original commit broke aosp-master-with-phones, because of
vendor libraries the depended on the int versions of libbase functions.

This patch reverts the revert, and also adds ABI-compatibility shims for
the replaced functions.

This reverts commit 2c58e1924a.

Bug: http://b/131312539
Test: treehugger
Test: forrest run of aosp-master-with-phones
Change-Id: I75cc84ec8d963e20862f7662e8e2f409471f41cc
2019-05-06 16:18:02 -07:00
Mark Salyzyn
5c812e7a13 Merge "adb: enable/disable verity expected overlayfs errors." am: be9c2c0310
am: 3809014902

Change-Id: Icb7f4cd3c20af1f80fa3ca2b05b906b38111b1e2
2019-05-06 08:38:56 -07:00
Treehugger Robot
be9c2c0310 Merge "adb: enable/disable verity expected overlayfs errors." 2019-05-06 14:36:51 +00:00
Elliott Hughes
f774bcc942 Merge "libbase: add ConsumePrefix/ConsumeSuffix." am: 7046bcb461
am: 9f6f62a485

Change-Id: Ie328e1a6da12ace87ebb2da65cbc649a1c972039
2019-05-03 17:48:43 -07:00
Josh Gao
a31aa2e749 Merge "adbd: move posix_fadvise after open." am: 19322dddc6
am: c97b258c42

Change-Id: I10f91ee1cedd16c1f803c3bdff9253fe3bca6841
2019-05-03 17:25:51 -07:00
Elliott Hughes
7046bcb461 Merge "libbase: add ConsumePrefix/ConsumeSuffix." 2019-05-04 00:03:14 +00:00
Treehugger Robot
19322dddc6 Merge "adbd: move posix_fadvise after open." 2019-05-03 23:23:59 +00:00
Mark Salyzyn
5828b77a3d adb: enable/disable verity expected overlayfs errors.
Expect EBUSY for overlayfs teardown, and ENOENT for setup.

Test: adb-remount-test.sh
Bug: 131614849
Change-Id: I0fb351d6d5fe758021c9e9043f57863c7a194c12
2019-05-03 14:44:49 -07:00
Elliott Hughes
b4dc7be6c5 libbase: add ConsumePrefix/ConsumeSuffix.
adb was already using ConsumePrefix, and now we have another would-be
user in cutils. (There appears to be one place in adb that should use
ConsumeSuffix, so I'm assuming we'll want that sooner or later.)

I've kept these inline because adb and google3's versions both were, and
I'm easily led.

Test: treehugger
Change-Id: I29d99032f6f6ccbfaefece59725db8afb02a4c87
2019-05-03 12:49:31 -07:00
Josh Gao
d594359e7f Merge "adbd: avoid starting multiple worker threads." am: 5ddd49eeae
am: dcfc785d20

Change-Id: Id5fbaba786214b2d5b9dcab7f433ce12f850d35d
2019-05-02 14:33:26 -07:00
Josh Gao
94fb36bf77 adbd: avoid starting multiple worker threads.
A previous patch intended to make receiving multiple FUNCTIONFS_ENABLEs
non-fatal, but failed to do so because we would try to spawn another
worker thread and hit a different assertion.

Bug: http://b/130638368
Test: echo mem | adb shell "su 0 sh -c 'cat > /sys/power/state'"
Change-Id: I53456112244d8b4f7d26df6ec6961389fca70498
(cherry picked from commit 910ce0ff08)
2019-05-02 14:13:14 -07:00
Treehugger Robot
5ddd49eeae Merge "adbd: avoid starting multiple worker threads." 2019-05-02 21:09:04 +00:00
Josh Gao
1f37bbb38c Merge "adb: increase adb [un]root timeout." am: 6bc132846a
am: bead01860d

Change-Id: I9c5d7e914d27705f3f021a476ac9adf19ec7039a
2019-05-02 09:19:02 -07:00
Treehugger Robot
6bc132846a Merge "adb: increase adb [un]root timeout." 2019-05-02 15:53:20 +00:00
Josh Gao
15cc1d641e Merge "adbd: compile a static version." am: 7a7c71b2b6
am: d8ccd6b57c

Change-Id: I9a305af5eaf20cfb136cb74833a4a5c6f41e69e0
2019-05-01 22:09:05 -07:00
Josh Gao
ef4a999343 adb: increase adb [un]root timeout.
3 seconds isn't generous enough, because if we're rapidly restarting
(e.g. `adb root; adb unroot`), init will wait 5 seconds to restart us.

Test: `adb root && adb unroot`
Change-Id: I353e8d1ee14f3b08416445ff627dea4a49afd9a4
2019-05-01 18:53:43 -07:00
Josh Gao
bde8c848d8 adbd: compile a static version.
Test: mma
Change-Id: I785de074f9b5cc63d1804420b734c4b07081a716
2019-05-01 18:25:52 -07:00
Josh Gao
910ce0ff08 adbd: avoid starting multiple worker threads.
A previous patch intended to make receiving multiple FUNCTIONFS_ENABLEs
non-fatal, but failed to do so because we would try to spawn another
worker thread and hit a different assertion.

Bug: http://b/130638368
Test: echo mem | adb shell "su 0 sh -c 'cat > /sys/power/state'"
Change-Id: I53456112244d8b4f7d26df6ec6961389fca70498
2019-05-01 17:27:27 -07:00
Josh Gao
b5d1d19269 adbd: move posix_fadvise after open.
Test: treehugger
Change-Id: I531e452eda46d7df3106fd59192e9936e64876b1
2019-05-01 13:40:01 -07:00
Josh Gao
60a5541e04 Merge "adb: restore generation of public key in adb keygen." am: fe6cc3e2d3
am: 6848befe69

Change-Id: I018c396127b0bb68358b74a72ecd33532440df5d
2019-04-29 16:04:00 -07:00
Treehugger Robot
fe6cc3e2d3 Merge "adb: restore generation of public key in adb keygen." 2019-04-29 22:31:17 +00:00
xunchang
40bf0f0772 Support adb rescue wipe command
Support `adb rescue wipe` command on the host side. This command runs
under the rescue mode and wipes data (and cache/metadata).

Bug: 131037235
Test: run adb rescue wipe

Change-Id: Ib3a3f2d564cc19d0446540d616cc21489ba558c2
(cherry picked from commit c2265c5343)
2019-04-29 15:21:50 -07:00
Josh Gao
032989a2ba adb: restore generation of public key in adb keygen.
We don't need the public key to be generated at ~/.android/adbkey.pub,
but it's still useful to be able to generate the public key for use with
ADB_VENDOR_KEYS.

Bug: http://b/119634232
Test: manual
Change-Id: Iecd6ff1bba4af4ba142456034f3faf52bb9e017d
2019-04-29 12:36:32 -07:00
Tianjie Xu
0eff930825 Merge "Support adb rescue wipe command" am: 56311071fe
am: 979f05c621

Change-Id: I8bc2ffef336c57b47972b7f37ccfc70ab7a19158
2019-04-29 11:06:03 -07:00
Tao Bao
fbeac4605c adb: Support rescue install and getprop.
Bug: 128415917
Test: Enter rescue mode on taimen. Send the following commands:
      `adb rescue getprop ro.build.fingerprint`
      `adb rescue getprop ro.build.date.utc`
      `adb rescue getprop ro.build.invalid`
      `adb rescue install /path/to/package.zip`
Test: Sideload on taimen w/ `adb sideload /path/to/package.zip`.
Change-Id: Ia246b30314fbcd2bd4cc71a8085a280e33041967
Merged-In: Ia246b30314fbcd2bd4cc71a8085a280e33041967
(cherry picked from commit 11cf30b5ed)
2019-04-26 12:27:39 -07:00
Tao Bao
25fe126fb0 adb: Recognize rescue mode.
This CL adds client support to recognize the rescue mode (which will be
served by recovery image). It also allows waiting for a device to enter
rescue mode. The support for the actual rescue commands will be added in
follow-up CLs.

Bug: 128415917
Test: `adb devices` recognizes devices under rescue mode.
Test: `adb wait-for-rescue` waits for device to be in rescue mode.
Change-Id: I367d7339fe68006aba09a1e3db6370d472296676
Merged-In: I367d7339fe68006aba09a1e3db6370d472296676
(cherry picked from commit 55d407ec4a)
2019-04-26 12:27:17 -07:00
xunchang
c2265c5343 Support adb rescue wipe command
Support `adb rescue wipe` command on the host side. This command runs
under the rescue mode and wipes data (and cache/metadata).

Bug: 131037235
Test: run adb rescue wipe

Change-Id: Ib3a3f2d564cc19d0446540d616cc21489ba558c2
2019-04-26 10:37:13 -07:00
Ian Kasprzak
19187f1bfc Merge "Revert "Add a way to turn off unique_fd's operator int."" am: e30fe5fe89
am: e285dbeae3

Change-Id: I8a4911e8b6970c3b0defef66dc109358ff2d6748
2019-04-25 10:30:15 -07:00
Ian Kasprzak
e30fe5fe89 Merge "Revert "Add a way to turn off unique_fd's operator int."" 2019-04-25 17:16:55 +00:00
Ian Kasprzak
2c58e1924a Revert "Add a way to turn off unique_fd's operator int."
This reverts commit 93d63c010a.

Reason for revert: b/131312539 - All aosp-master-with-phones phones failing boot / health check.

Change-Id: Id4239f93484b7d6b8d9bcd355a59cbd40d9766e2
2019-04-25 15:59:28 +00:00
Josh Gao
ed0033b4c0 Merge "adbd: reduce queue depths." am: 0fcd9292c4
am: 1c6d4f3663

Change-Id: I95bc10b35cf00f02833978d762c21be4b8e9b5e2
2019-04-24 18:29:59 -07:00
Josh Gao
d0feaf9f79 adbd: reduce queue depths.
Each operation we submit results in a contiguous allocation in the
kernel which can trigger OOM-killing. Tune the queue depths to reduce
the chances of this happening, with a minimal impact on performance.

Bug: http://b/126582877
Test: ./benchmark_device.py with blueline
Change-Id: I4b0f83d54a9a9a69f0ab48322d78fb137c94dd35
(cherry picked from commit 28293f16a8)
2019-04-24 18:12:17 -07:00
Josh Gao
0fcd9292c4 Merge "adbd: reduce queue depths." 2019-04-25 01:09:23 +00:00
Josh Gao
8c856f3e10 Merge "Add a way to turn off unique_fd's operator int." am: 971bae0bcf
am: 7653723999

Change-Id: I06811b1e5ff3d45e4b0490bf00d1608bdf1ce1c4
2019-04-24 16:07:09 -07:00
Josh Gao
76de9a471d Merge "adb: silence warning from libusb." am: ee5083b3c7
am: 4a749cc3f1

Change-Id: Ic2ab02abe3b2d1f001ee52c9ced9c0cb4db1e129
2019-04-24 16:06:21 -07:00
Josh Gao
b83f920abf Merge "adb: fix double close in wait-for-*." am: e923e5ef62
am: a8a1f75147

Change-Id: Id73338791ef4cd3aa08c2bc0b00b8b1410dd8461
2019-04-24 16:05:33 -07:00
Josh Gao
971bae0bcf Merge "Add a way to turn off unique_fd's operator int." 2019-04-24 22:58:00 +00:00
Treehugger Robot
ee5083b3c7 Merge "adb: silence warning from libusb." 2019-04-24 22:46:28 +00:00
Treehugger Robot
e923e5ef62 Merge "adb: fix double close in wait-for-*." 2019-04-24 22:38:31 +00:00
Josh Gao
28293f16a8 adbd: reduce queue depths.
Each operation we submit results in a contiguous allocation in the
kernel which can trigger OOM-killing. Tune the queue depths to reduce
the chances of this happening, with a minimal impact on performance.

Bug: http://b/126582877
Test: ./benchmark_device.py with blueline
Change-Id: I4b0f83d54a9a9a69f0ab48322d78fb137c94dd35
2019-04-24 15:05:21 -07:00
Josh Gao
93d63c010a Add a way to turn off unique_fd's operator int.
unique_fd's implicit conversion to int has led to tons of problems (see
all of the overloads for close, fdopen, fdopendir, etc.). Add a switch
that can turn it off, and reduce the ridiculous amount of work to fix up
callers by introducing a borrowed_fd type that can be constructed from
either int or unique_fd.

Test: treehugger
Change-Id: If77cf5cbcaddacdaec5919a15b3520fb68f51a62
2019-04-24 12:59:42 -07:00
Tao Bao
de8d0dfdc0 Merge "adb: Support rescue install and getprop." am: 6688eaf23f
am: 3ad39fa24b

Change-Id: Ic2fe41f624999762eb9c34e7d97727919ce821ab
2019-04-22 15:46:32 -07:00
Tao Bao
11cf30b5ed adb: Support rescue install and getprop.
Bug: 128415917
Test: Enter rescue mode on taimen. Send the following commands:
      `adb rescue getprop ro.build.fingerprint`
      `adb rescue getprop ro.build.date.utc`
      `adb rescue getprop ro.build.invalid`
      `adb rescue install /path/to/package.zip`
Test: Sideload on taimen w/ `adb sideload /path/to/package.zip`.
Change-Id: Ia246b30314fbcd2bd4cc71a8085a280e33041967
2019-04-19 12:51:57 -07:00
Josh Gao
499601b94f adb: fix double close in wait-for-*.
unique_fd's implicit conversion to int allows the following code to
compile without error, leading to a double close:

  std::function<void(unique_fd)> func = [](int x) { close(x); };
  func(unique_fd(42));

Test: treehugger
Change-Id: I948ecda3a12738b3af6444fe2902d2f7b80e1b4c
2019-04-18 16:58:30 -07:00
Tao Bao
2b82b147c8 Merge "adb: Recognize rescue mode." am: f072aaffe0
am: ff460d7fa8

Change-Id: Id617e014b74d0f090aaf0ce04c44f4de743595d0
2019-04-18 15:11:11 -07:00
Tao Bao
f072aaffe0 Merge "adb: Recognize rescue mode." 2019-04-18 21:45:50 +00:00
Josh Gao
08ccc735a3 adbd: reduce the USB buffer sizes to 16k.
Some USB controllers only support 16k writes, so drop down to that.

Bug: http://b/130622010
Test: treehugger
Change-Id: I836d5b2d0d6fcae05f290af11a6a19c6e8d7c1ba
(cherry picked from commit 770a6a4d46)
2019-04-17 17:53:34 -07:00
Josh Gao
4710e53fe5 adb: silence warning from libusb.
Test: mma
Change-Id: I3f254f3432020937e0f22b04baf7df61336c500b
2019-04-17 16:57:43 -07:00
Josh Gao
039cc7d1f8 Merge "adbd: reduce the USB buffer sizes to 16k." am: f05fbe6957
am: 949a903ff5

Change-Id: I887c8b43ac51eef60b5d0ec2a489277ad8a0c092
2019-04-17 16:15:35 -07:00
Tao Bao
55d407ec4a adb: Recognize rescue mode.
This CL adds client support to recognize the rescue mode (which will be
served by recovery image). It also allows waiting for a device to enter
rescue mode. The support for the actual rescue commands will be added in
follow-up CLs.

Bug: 128415917
Test: `adb devices` recognizes devices under rescue mode.
Test: `adb wait-for-rescue` waits for device to be in rescue mode.
Change-Id: I367d7339fe68006aba09a1e3db6370d472296676
2019-04-17 13:47:02 -07:00
Josh Gao
770a6a4d46 adbd: reduce the USB buffer sizes to 16k.
Some USB controllers only support 16k writes, so drop down to that.

Bug: http://b/130622010
Test: treehugger
Change-Id: I836d5b2d0d6fcae05f290af11a6a19c6e8d7c1ba
2019-04-16 15:14:24 -07:00
Alex Buynytskyy
7e1d397d1a Binding err to inout for raw protocol for in-process execute.
As raw protocol does not allow for splitting err - it has to be redirected to inout.
Before this change it was not done for in-process and all err data was lost.

Bug: 130086616
Test: manual + atest adbd_test
Change-Id: I6cd11c940673d73e2993a6eb23c46d31bd8bf504
(cherry picked from commit 704c97d6c2)
2019-04-10 11:13:39 -07:00
Josh Gao
a7f6cd0470 adb: defuse CHECK on IOVector::append of an empty block.
Bug: http://b/129706741
Test: treehugger
Change-Id: I35a35d20d179a155adb4fe83078739fcaf517136
(cherry picked from commit 3443b77415)
2019-04-10 11:13:35 -07:00
Alex Buynytskyy
88f48b125a Merge "Binding err to inout for raw protocol for in-process execute." am: 265af10e6e
am: 4daf72da7a

Change-Id: I38919f3b0c01590ba4a80beef7a1cf5e34e3a298
2019-04-09 12:28:14 -07:00
Alex Buynytskyy
704c97d6c2 Binding err to inout for raw protocol for in-process execute.
As raw protocol does not allow for splitting err - it has to be redirected to inout.
Before this change it was not done for in-process and all err data was lost.

Bug: 130086616
Test: manual + atest adbd_test
Change-Id: I6cd11c940673d73e2993a6eb23c46d31bd8bf504
2019-04-08 19:16:05 -07:00
Josh Gao
02dc0fcda0 Merge "adb: defuse CHECK on IOVector::append of an empty block." am: 5c58e092f3
am: c923599e0c

Change-Id: Iab58ded15e69a08176e586d2cdee46b3f742e56a
2019-04-04 14:22:15 -07:00
Treehugger Robot
5c58e092f3 Merge "adb: defuse CHECK on IOVector::append of an empty block." 2019-04-04 21:02:02 +00:00
Josh Gao
3443b77415 adb: defuse CHECK on IOVector::append of an empty block.
Bug: http://b/129706741
Test: treehugger
Change-Id: I35a35d20d179a155adb4fe83078739fcaf517136
2019-04-03 12:56:22 -07:00
Josh Gao
fff6760db5 Merge "adb: fix mac build breakage." am: 52c6f1b6de am: 94a23604c7
am: 0a2e8e94ae

Change-Id: Ic2966482db39cdb15eacb192606bca44b0fd5f6f
2019-04-02 22:17:39 -07:00
Treehugger Robot
52c6f1b6de Merge "adb: fix mac build breakage." 2019-04-03 03:14:28 +00:00
Josh Gao
296ac3f024 adb: fix mac build breakage.
Bug: http://b/129786641
Test: none
Change-Id: Ibe051a0db2f912d1f7e55369e25a5bd38bf86fd5
2019-04-02 16:31:32 -07:00
Josh Gao
804ffede3e Merge "adbd: demote CHECKs to warning logs." am: 16f4a033c3 am: 887e8f4bfd
am: 8cecb02a2c

Change-Id: Id2ab6435ad2953cd4bb6348fc5166a07a598832f
2019-04-02 15:27:18 -07:00
Josh Gao
87afd52fb5 adbd: demote CHECKs to warning logs.
It seems like we don't actually always get these events in order, so
demote them to a log and restart the connection instead of aborting.

Bug: http://b/129464137
Test: mma
Change-Id: I7dffbf62f9dea665cf9f9f9e1bd18d444b6905ec
2019-04-02 10:56:07 -07:00
Josh Gao
73a9681319 Merge "adb: make adb reconnect perform a USB reset." am: 3b25a17a8a am: 0d9d5ef1bb
am: e5a5a5b18f

Change-Id: If54f9d0b4c8a003ab7cd5557a4d0b0a48fc3654d
2019-04-01 15:34:48 -07:00
Josh Gao
3b25a17a8a Merge "adb: make adb reconnect perform a USB reset." 2019-04-01 21:42:57 +00:00
Josh Gao
3705b346b9 adb: make adb reconnect perform a USB reset.
Bug: http://b/128941083
Test: manual
Change-Id: Iaf46d2c46cc82b590768004486d119244591c8e2
2019-03-28 15:47:44 -07:00
Josh Gao
2a1fb09335 Merge "adbd: wait for FUNCTIONFS_BIND for up to a second, then retry." am: bfcb981b32 am: 80268fd592
am: 51ca488977

Change-Id: Ia4a29eedde07ea29b0a7650179330386ecf19af1
2019-03-28 14:02:31 -07:00
Josh Gao
19dc296305 adbd: wait for FUNCTIONFS_BIND for up to a second, then retry.
Occasionally, after we open the functionfs endpoint and write our
descriptors to it, we end up in a state where we never receive any
events from ep0, presumably due to a race against some other part of
the system, since adding sleeps reduces the likelihood. Add an
(arbitrarily chosen) timeout for the initial FUNCTIONFS_BIND we read,
and retry on failure.

Bug: http://b/128679787
Test: unplug and replug a blueline 14,000 times with a usb switch board
Change-Id: I4b3d5d552179ee7f3fefcc15f9575f793926f784
2019-03-27 18:04:45 +00:00
Greg Kaiser
e0a1be42cb Merge changes Ia84ed9ec,I1c0fde72 am: 10533c57ed am: b6bc0075f4
am: d095e07371

Change-Id: I85cb7c71f37565e220a16ea6f21548887ef8e20c
2019-03-26 18:17:41 -07:00
Josh Gao
3d26a86676 Merge changes I80af5f4b,I2fd0034e am: 2decb2fc3a am: c9a893c1eb
am: 448aed3c73

Change-Id: I783537a4b2ec10659c563b4461186d2230895e35
2019-03-26 18:08:11 -07:00
Treehugger Robot
10533c57ed Merge changes Ia84ed9ec,I1c0fde72
* changes:
  fastboot: Avoid extra std::string copies
  adb: Avoid extra std::string copies
2019-03-27 00:33:05 +00:00
Josh Gao
6933d54e09 adbd: listen to all functionfs events.
Monitor for FUNCTIONFS_UNBIND as well, so that in the case where we get
FUNCTIONFS_BIND, FUNCTIONFS_UNBIND, FUNCTIONFS_BIND, we don't trigger an
assertion failure from seeing two FUNCTIONFS_BINDs.

Bug: http://b/129134256
Test: manual
Change-Id: I80af5f4b833513e932262638b9f8d76bbcb35504
2019-03-26 13:38:41 -07:00
Josh Gao
63b52ec13b adbd: increment writes_submitted_ before submitting writes.
If we fail to submit writes for some reason (e.g. the USB cable was
unplugged), another thread that's waiting on the write mutex can enter
SubmitWrites and attempt to resubmit the writes that we already failed
to submit, leading to a failed assertion of !IoBlock::pending.

Increment writes_submitted_ before actually calling io_submit, so we
skip over these writes and fall through to exit.

Bug: http://b/129134256
Test: manually unplugged a blueline
Change-Id: I2fd0034e45db22c8f637c81039ce686b7aa6a03b
2019-03-26 13:06:38 -07:00
Greg Kaiser
e2125fdeb1 adb: Avoid extra std::string copies
When a function argument takes a std::string, it's inefficient to
pass std::string::c_str(), since that creates an additional copy.
So we change these calling sites.

Test: TreeHugger
Change-Id: I1c0fde7275eb3ebd3baf05ec62581b0243655608
2019-03-26 12:00:19 -07:00
Josh Gao
f31a12aa71 Merge "adbd: support ro.adb.nonblocking_ffs." am: affe351420 am: c94cec6d9d
am: 1e43373c62

Change-Id: Icdafb535240608d0e7ba927583c79199ef78747a
2019-03-19 13:10:35 -07:00
Josh Gao
affe351420 Merge "adbd: support ro.adb.nonblocking_ffs." 2019-03-19 19:44:00 +00:00
Josh Gao
c57206a541 Merge "adb: fix uninitialized variable." am: 588a87d68e am: 966b39b34c
am: 4ba1491a38

Change-Id: I5765725c70d659e73b5b852cad0095a9d0d52522
2019-03-18 20:49:51 -07:00
Treehugger Robot
588a87d68e Merge "adb: fix uninitialized variable." 2019-03-19 03:14:17 +00:00
Josh Gao
8038e35fdf adbd: support ro.adb.nonblocking_ffs.
Allow disabling ro.adb.nonblocking_ffs via an ro system property, which
gets overridden by the currently supported persist.adb.nonblocking_ffs.

Bug: http://b/128679787
Test: mma
Change-Id: I28891d2da129e9654bf63ab8a4c330c4d2f5b336
2019-03-18 17:59:24 -07:00
Josh Gao
b019574476 adb: fix uninitialized variable.
Previously, we were initializing IoBlock::pending when submitting a read,
but leaving it uninitialized when doing a write, which would sometimes
result in an assertion firing when we received a previously allocated
block of memory that happened to have a nonzero value in pending.

Test: treehugger
Change-Id: I434c65f554ceed313fea9cfcc98788908f3ca8bc
2019-03-18 17:12:19 -07:00
Greg Kaiser
446f4655cb Merge "adb: Fix return value in error case" am: 2925a580e9 am: 73308830a6
am: 507be15cf8

Change-Id: I2e8d88291ee2f26fda59607eb64e8d6accf69968
2019-03-18 14:46:27 -07:00
Greg Kaiser
5fe40a66b2 adb: Fix return value in error case
When we introduced __adb_check_server_version() as a function
returning a 'bool', we missed missed converting once instance
of "return -1;" to "return false;".  Thus, we're returning 'true'
in this case as our non-zero value gets implicitly converted to
'true'.

We fix this case as well with this CL.

Test: TreeHugger
Change-Id: I90b01567d927f36d2d963561b676b3bfabfcee49
2019-03-18 07:00:00 -07:00
Josh Gao
8738462218 Merge "adb: avoid sign extension of shell return code." am: b5ac15a936 am: a6397564b6
am: 3811ab5afa

Change-Id: I334ee2c20a76a6a081b7b752d8e7ca558da3f1da
2019-03-15 21:22:52 -07:00
Josh Gao
bcde100b00 Merge "adb: attempt to exec newer adb servers on Linux." am: eecd5cc532 am: e60f681f7c
am: b333e684d1

Change-Id: I23041966e50fd61dc0e034a609e2534d1f58c1ad
2019-03-15 16:06:29 -07:00
Josh Gao
1e1ae45a8c adb: avoid sign extension of shell return code.
Windows has int32_t return codes, which results in return codes 128-255
being sign extended into a negative number. Manually truncate the return
codes we get to preserve their values.

Test: test_device.py on windows
Change-Id: If41d6d469350301704f6ecff72ad17b412db3e04
2019-03-15 14:54:32 -07:00
Josh Gao
eecd5cc532 Merge "adb: attempt to exec newer adb servers on Linux." 2019-03-15 21:54:10 +00:00
Jiyong Park
c9a07bcbb4 Revert "Handle adb sync with Bionic under /bionic" am: fc97d2a116 am: 8b9fa0a44d
am: ebe1460df5

Change-Id: I24a5a49a8cd894b93664c65b76534db614d891e2
2019-03-15 02:43:37 -07:00
Jiyong Park
8b9fa0a44d Revert "Handle adb sync with Bionic under /bionic"
am: fc97d2a116

Change-Id: I8c8780f0009795d281b93efa691791427402ef45
2019-03-15 02:18:42 -07:00
Treehugger Robot
4cd0914048 Merge changes from topic "apex_earlymount_no_bionic_bindmount"
* changes:
  /bionic path is gone
  Revert "Handle adb sync with Bionic under /bionic"
  Don't bind-mount bionic files
2019-03-15 09:02:18 +00:00
Bowgo Tsai
76f9dc6f31 Merge changes from topic "adb_root_in_user" am: da1251d6a5 am: ac5d9460f2
am: c613c0d130

Change-Id: I46e9d64a103c7a983d908e7b6f131332aafe1b72
2019-03-14 22:05:05 -07:00
Josh Gao
d10b7c4e02 adb: attempt to exec newer adb servers on Linux.
Test: manual
Change-Id: Iebdfa292f21b2871e6010ab6cc964134fec447e9
2019-03-14 15:41:41 -07:00
Bowgo Tsai
9b30c0a7e6 adbd: allowing adb root when the device is unlocked
As there is no security guarantee when the device is unlocked,
allowing adb root gives us more rooms to debug a USER build images.

Also, this makes it possible to run VTS on a USER build GSI, with
setting ro.debuggable=1 and unlocking the device.

This basically re-lands a reverted change:
https://android-review.googlesource.com/c/platform/system/core/+/437815

Which isn't needed after we moved /sbin/adbd to /system/bin/adbd in
USERDEBUG GSI. But it's still needed for USER build GSI.

Bug: 126493225
Test: unlock a USER build device, check 'adb root' can work
Change-Id: I93f12c8a3fe65c96c947e4602795eadfe591c521
2019-03-15 03:04:46 +08:00
Jiyong Park
fc97d2a116 Revert "Handle adb sync with Bionic under /bionic"
This reverts commit 7c7189c469.

Bug: 125549215
Test: system/core/fs_mgr/tests/adb-remount-test.sh
Change-Id: I4ee40cda9c3b94b116dc822c7b9736cfe2c9c9f0
2019-03-14 07:35:54 +09:00
Josh Gao
8c73ee5afc Merge "adb: make root/unroot wait for the device to come back." am: 59d4c8a352 am: 983e1a5af2
am: 2ef1948cd0

Change-Id: I7b0b6974ad6e90b8143515d486299d75ca8d1a64
2019-03-11 21:17:46 -07:00
Josh Gao
2986dd4dfc Merge "adbd: properly handle FUNCTIONFS_BIND without ENABLE." am: 22ff8e1909 am: b90db0840a
am: 313d214ec0

Change-Id: I63965d5bf49bdf63383bdd6aaac703c06fab5179
2019-03-11 17:15:56 -07:00
Josh Gao
3c99b0f94f adb: make root/unroot wait for the device to come back.
Test: manually unplugged a device after adb root
Change-Id: I588283a666cc5e19d809d7ce81b5300398e8be2d
2019-03-11 15:59:09 -07:00
Josh Gao
007a4dc7a6 adbd: properly handle FUNCTIONFS_BIND without ENABLE.
If a device is unplugged, a BIND will happen without an ENABLE until the
device is plugged in, which would previously result in adbd crashing
every 5 seconds due to an attempt to join a thread that hadn't been
started.

Bug: http://b/128255355
Test: manually observed adbd via serial cable while unplugged
Change-Id: I90d6384e7e829df1ffaf73a95f2418a2ff97fb03
2019-03-11 13:06:17 -07:00
Josh Gao
9909c13ad9 Merge "Restrict scanning port range, not emulator count" am: e6413fcd94 am: b4954166ac
am: 4b868d648b

Change-Id: I79ce65ada9dd071b1eba7743d5e3d5212ce68fef
2019-03-08 12:27:57 -08:00
Josh Gao
e6413fcd94 Merge "Restrict scanning port range, not emulator count" 2019-03-08 19:29:43 +00:00
Josh Gao
b1aa106e44 Merge "Revert "Revert "adbd: switch the default USB implementation.""" am: f97193d96f am: d9e3421558
am: 3fafb971d9

Change-Id: Ie98d0d8b581fb53d0e7ecc64f55744fa851e3174
2019-03-07 21:14:18 -08:00
Treehugger Robot
f97193d96f Merge "Revert "Revert "adbd: switch the default USB implementation.""" 2019-03-08 03:29:41 +00:00
Tim Baverstock
25173c808a Restrict scanning port range, not emulator count
Our servers can comfortably run more than 16 emulators, and this is
much easier than messing with hypervisors or docker port allocation.

Assumes you know how to avoid clashes with Google Wear's default port.

Test: manual - still registers emulators.

Change-Id: I47cfd28725a550de0bd77fd11fcd94cdd11d2cc2
2019-03-07 12:28:31 +00:00
Josh Gao
2d918cde58 Merge "adbd: cleanups in remount/verity." am: 98efc485de am: d659bb49be
am: b7dc01a570

Change-Id: Ia1f05becfdbba49606fb9bd47123e81c73d55e97
2019-03-06 18:46:04 -08:00