Commit Graph

3328 Commits

Author SHA1 Message Date
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
Josh Gao 3ed90b75da adbd: cleanups in remount/verity.
1. Don't clear O_CLOEXEC on an fd we're duping to stdin/out/err: dup2
   does that for us if oldfd != newfd, and we know the fd can't be
   stdin/out/err.
2. Use unique_fd.
3. Remove gotos by breaking the remount logic into its own function.

Test: mma
Change-Id: If9929e7f20de445322fd498e1379a2d4e572cb52
2019-03-06 13:03:30 -08:00
Mark Salyzyn 2085759c6d Merge "adb: use /system/bin/remount command" am: d458066bc7 am: bc0887add7
am: be17923ece

Change-Id: Iaf7574caa4b4ee23acc864d7eeaf3a095394c215
2019-03-04 14:51:39 -08:00
Mark Salyzyn 2f6c180749 adb: use /system/bin/remount command
Replace direct logic in support for 'adb remount' with an exec out to
/system/bin/remount to do the heavy lifting.  Remount success and
failure strings are reported by the adb remount service in response
to the various reported errors, freeing up the remount command itself
from the legacy of script expectations.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: I686fa465f463b881bbb38f709d780a95e463be80
2019-03-04 11:12:54 -08:00
Josh Gao 291f29613c Merge "adbd: fix a case where we can fail to join a thread." am: b530537d46 am: ace5a7c799
am: ee76606206

Change-Id: Ic09c38e919a1d1d12308504b4cbe2d388b94c42d
2019-03-01 02:30:19 -08:00
Josh Gao b67e5cd91d Merge changes I4d351f56,Ib9e91157 am: 7669ea5a44 am: 68f136b407
am: a7140a1222

Change-Id: I403b2d6c59dcc16a8853ffccdc40eba5984699f4
2019-03-01 02:29:03 -08:00
Josh Gao b530537d46 Merge "adbd: fix a case where we can fail to join a thread." 2019-03-01 10:16:46 +00:00
Josh Gao 5841a96afc adbd: tune USB read/write sizes and queue depths.
Reduce the operation sizes to sizes that are small enough that the
kernel will run the OOM killer to try to make them succeed. Compensate
for the smaller operation sizes by increasing the queue depth.

Bug: http://b/126582877
Test: benchmark_device.py
Change-Id: I4d351f56c8f83fea882614238cc3fec8ba1e9bf9
2019-02-28 15:53:48 -08:00
Josh Gao b416f2252e adb: add benchmarks for sink/source.
Test: ./benchmark_device.py
Change-Id: Ib9e911574be3afa94efcfd9bc5be0a5cf7b9e2c0
2019-02-28 15:53:48 -08:00
Josh Gao e778b3ad71 adbd: fix a case where we can fail to join a thread.
Bug: http://b/126703621
Change-Id: I3061d24bbdc154ebf1f9e3f5a903f01382fa518f
2019-02-28 13:53:24 -08:00
Josh Gao ae084ea9e4 Merge "adbd: limit the sizes of aio writes." am: 50cb647e7d am: c423d790b7
am: 57ba09aea9

Change-Id: Ib6c09a5dbddea768eed6fa4570067c4d8bb42045
2019-02-27 23:43:03 -08:00
Josh Gao 02e94a4f76 Revert "Revert "adbd: switch the default USB implementation.""
This reverts commit 0d780391a1.

Reason for revert: cause for original revert probably fixed by https://android-review.googlesource.com/c/platform/system/core/+/914673

Change-Id: I9a7eead54fca3a1a9dfd93f650f01c056d39339e
2019-02-28 07:26:20 +00:00
Josh Gao 50cb647e7d Merge "adbd: limit the sizes of aio writes." 2019-02-28 07:25:21 +00:00
Josh Gao 86b33be035 adbd: limit the sizes of aio writes.
The kernel does a kmalloc of the write size for each write during
io_submit, which can lead to failure if the kernel's heap is fragmented
such that it can't allocate a contiguous 1MB chunk. Partition writes
into 16 page chunks which are much more likely to succeed.

Bug: http://b/126582877
Test: test_device.py
Change-Id: Ib2d48561594e1d81f1a2f62e34eaa40265ac47c4
2019-02-27 15:45:59 -08:00
Dario Freni e2bec0d338 Merge "Support splitAPK in install-multi-package." am: 455f12446e am: a7f85cfeb4
am: 0057231d1b

Change-Id: I77ea80c87044c8b532b2eb84a36093366db8020f
2019-02-27 11:40:41 -08:00
Dario Freni 455f12446e Merge "Support splitAPK in install-multi-package." 2019-02-27 19:00:14 +00:00
Josh Gao 7975e1812d Merge "Revert "adbd: switch the default USB implementation."" am: c2970282cb am: b7d775866c
am: 093d5c34a5

Change-Id: I70c93faf116d9acdaf9852d286ecc64e87ecc05c
2019-02-26 14:39:12 -08:00
Josh Gao c2970282cb Merge "Revert "adbd: switch the default USB implementation."" 2019-02-26 22:15:40 +00:00
Josh Gao 0d780391a1 Revert "adbd: switch the default USB implementation."
This reverts commit 12f328489b.

Reason for revert: possibly causing b/126388431

Change-Id: Ida7c30a92f552f923f3bcb153d945d58ebbc4257
2019-02-26 22:10:33 +00:00
Josh Gao 0537179493 Merge changes I86c3ec0f,I57d1a30a,Ib50d289b,I791a4f82,I316a8799, ... am: 216d158daf am: ff7b56f917
am: d575bc93a5

Change-Id: I610dd6851e7725c45fd64875eef758175fb19b0b
2019-02-26 13:30:18 -08:00
Josh Gao 216d158daf Merge changes I86c3ec0f,I57d1a30a,Ib50d289b,I791a4f82,I316a8799, ...
* changes:
  adb: switch sockets.cpp to ConsumePrefix.
  adbd: switch abb to ConsumePrefix.
  adb: increment server version.
  adb: wait for device to disconnect upon `adb root`.
  adb: implement wait-for-disconnect.
  adb: tell the client what transport it received.
  adbd: switch daemon/services to ConsumePrefix.
  adb: switch host_service_to_socket to string_view.
  adb: switch handle_host_request to string_view.
  adb: switch adb_io.h to string_view.
  adb: add helper to consume a prefix on a string_view.
  adb: make ParseUint reject garbage at the end by default.
2019-02-26 20:55:19 +00:00
Josh Gao 88c3bd5c83 Merge "adbd: switch the default USB implementation." am: 5782600271 am: 269ef5d068
am: d4c49c4b44

Change-Id: I85adc4e8d270a6c71dbd0266ba330df6c37b2faf
2019-02-26 01:21:38 -08:00
Josh Gao 5782600271 Merge "adbd: switch the default USB implementation." 2019-02-26 06:47:46 +00:00
Alex Buynytskyy 04bcfcb380 Merge "Adding EXEC version of calling ABB." am: e257772bb2 am: b590a59bc4
am: 5c18315e47

Change-Id: I5bdfd0ceb489b28954bf49dbf08390460b70393d
2019-02-25 19:27:59 -08:00
Julien Desprez 4306ad0096 Merge "Temporarily @ignore test_reconnect" am: 9bfa166ad9 am: 84d796dac4
am: b1687ed7e3

Change-Id: Ieec56ca6069294770c1d0303d466a2d67fbf9e2c
2019-02-25 15:28:52 -08:00
Josh Gao 43f3805950 adb: switch sockets.cpp to ConsumePrefix.
Test: mma
Change-Id: I86c3ec0fd90fe45e59c0187f664d46020bad2c0f
2019-02-25 13:59:00 -08:00
Josh Gao ccc584523a adbd: switch abb to ConsumePrefix.
Test: mma
Change-Id: I57d1a30a526c97c5b5a2718740b76220da6eea39
2019-02-25 13:59:00 -08:00
Josh Gao aa4f31a124 adb: increment server version.
Increment the server version for adb_connect with transport id, and
wait-for-disconnect.

Bug: http://b/124244488
Test: none
Change-Id: Ib50d289b68fce4befbf1f5d9507d7e6f9cc1f4f5
2019-02-25 13:59:00 -08:00
Josh Gao 2020dd6f2e adb: wait for device to disconnect upon `adb root`.
Previously, there was a race where if adb root took longer than 3
seconds to take effect, we'd return early and allow subsequent commands
to be targeted at the still-not-dead transport, and spuriously fail.

Bug: http://b/124244488
Test: test_device.py
Change-Id: I791a4f82946eb28e4d37729ab0ed3b7fc05b42a2
2019-02-25 13:59:00 -08:00
Josh Gao 1e9e471c9c adb: implement wait-for-disconnect.
Bug: http://b/124244488
Test: manual
Change-Id: I316a87994924c51c785e46a4900380c58e726985
2019-02-25 13:59:00 -08:00
Josh Gao 79797ecbb1 adb: tell the client what transport it received.
Prerequisite for making `adb root` wait for the device that it told to
restart to disappear: the client needs to know which transport to wait
on.

Bug: http://b/124244488
Test: manual
Change-Id: I474559838ad7c0e961e9d2a98c902bca3b60d6c8
2019-02-25 13:49:25 -08:00
Josh Gao 2df76b7ee7 adbd: switch daemon/services to ConsumePrefix.
Test: mma
Change-Id: Ib4bb7d3352219a9883a5089e08225fb17145c2ee
2019-02-25 13:49:25 -08:00
Josh Gao 0ecc4020d6 adb: switch host_service_to_socket to string_view.
Test: manual
Change-Id: I09b83cc82edb10c1a51ecc5ebb8d9fe5294222c3
2019-02-25 13:49:25 -08:00
Josh Gao 769f853f96 adb: switch handle_host_request to string_view.
Test: test_adb.py
Test: test_device.py
Change-Id: Ideae5262a6dff2e27c50f666144d48f874837290
2019-02-25 13:49:25 -08:00
Josh Gao 342b661e81 adb: switch adb_io.h to string_view.
Test: mma
Change-Id: Ifa16502bac18429491426c45ece562657cff1689
2019-02-25 13:49:25 -08:00