Commit graph

3827 commits

Author SHA1 Message Date
Jooyung Han
60985953bd Merge "Add min_sdk_version:R to updatable apexes" 2020-04-25 04:41:43 +00:00
Joshua Duong
7833075fb5 Merge "[adb] Disable _adb._tcp. service auto-connect by default." am: 3eea62432d am: 6974e7b043
Change-Id: I6f5fc03d22e516eaf48bcb1e289f6773fa75b384
2020-04-24 06:12:48 +00:00
Joshua Duong
3eea62432d Merge "[adb] Disable _adb._tcp. service auto-connect by default." 2020-04-24 05:38:22 +00:00
Treehugger Robot
fb3cce57b0 Merge "Using ABB for install-multi." am: abc40c7c5d am: 3a9114c337
Change-Id: I27df5ad5f916bc75ead36cb439aa9370ce9431ca
2020-04-24 01:36:57 +00:00
Treehugger Robot
abc40c7c5d Merge "Using ABB for install-multi." 2020-04-24 01:15:49 +00:00
Joshua Duong
2eedc2303b [adb] Disable _adb._tcp. service auto-connect by default.
Added ADB_MDNS_AUTO_CONNECT envionment variable to control which
services to allow auto-connect. By default, only _adb-tls-connect
services can auto-connect, since these services only auto-connect once
paired. _adb services will try to auto-connect to every service found.

Bug: 152636135

Test: ADB_TRACE=1 adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=adb adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=adb,adb-tls-connect adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=adb-tls-connect adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=0 adb server nodaemon | grep whitelist
Test: ADB_TRACE=1 ADB_MDNS_AUTO_CONNECT=1 adb server nodaemon | grep whitelist

Change-Id: Ie562ea24fea3d6d96e67b376a0523b09e2778eb7
2020-04-23 16:55:52 -07:00
Alex Buynytskyy
a59e9b4e70 Using ABB for install-multi.
ABB uses single shared CMD for all operations which improves
reliability.

Bug: b/153486595
Test: atest adb_test adbd_test fastdeploy_test
Change-Id: I1e3da63882c980811ed2e9f5556732b24a041ce5
2020-04-23 16:30:49 -07:00
Josh Gao
34ce77427f Merge changes I5fd3b25d,I6c039b32,I014d7ad2 am: a675727a81 am: 8b0a69f9ad
Change-Id: Iae88f73fb69cf3f19d8090a07ef2563966cd8fc8
2020-04-23 22:20:07 +00:00
Josh Gao
0e778dc794 adb: allow filtering by file in coverage/show.sh.
Test: ./coverage.sh transport.cpp
Change-Id: I5fd3b25d9b3edd7a9131dae902e1868ced0384cc
2020-04-22 23:15:06 -07:00
Josh Gao
d5d5ba1644 adbd: don't use libc++_static.
We have dependencies that use libc++_shared, which results in ODR
violation manifesting as host adbd crashing on launch in libc++ locale
initialization.

Test: adbd on host
Change-Id: I6c039b325308fb8c36dfe5c1d090ff4ebe9e3433
2020-04-22 23:15:06 -07:00
Josh Gao
8a9277a243 adb: split transport_local.cpp into client/daemon.
Improve coverage some more.

Test: ./coverage/gen_coverage.sh && ./coverage/report.sh
Change-Id: I014d7ad25b2793d5d836ce5e526d657d46687ea4
2020-04-22 23:15:02 -07:00
Joshua Duong
f751d65fdd Merge changes from topic "adb-mdns-cmdline" am: 8cab9b6b24 am: d9c0176f1f
Change-Id: Ic290b50817b53ba09f24c5aaae9e92605afcedcc
2020-04-22 20:36:12 +00:00
Joshua Duong
13c639e0bb [adb client] Add "mdns services" command.
This command list all discovered mdns services, so we
can connect via service name later on.

Bug: 152521166

Test: 'adb mdns services'
Test: test_adb.py
Change-Id: I23d42a7933e67a65bd0c9924afd6abe5915c0a11
2020-04-22 08:43:15 -07:00
Joshua Duong
504d393176 [adb client] Add "adb mdns check" command.
This command will check if the mdns daemon is available on the host
machine.

Bug: 152510294

Test: pkill -9 mdnsd; adb mdns check; mdnsd; adb mdns check;
Test: test_adb.py
Change-Id: If644678a339763817a8a7adcbdc545626d161aba
2020-04-22 08:43:15 -07:00
Josh Gao
a57b3a73ba Merge changes I26f823e2,Iaff2b157,I82a0d54f,I7e4b6fda,I268367b8 am: 992f08e78d am: 5115758e6a
Change-Id: Ia3497eceada639d57d486ef46cf10dd6582f22f6
2020-04-22 04:05:45 +00:00
Greg Kaiser
cb885c24fc adb: Avoid extra string construction
Bug: 150827486
Test: TreeHugger
Change-Id: Ie03062a17b98866f1bc419a7e509461cf4e6bb80
Merged-In: Ie03062a17b98866f1bc419a7e509461cf4e6bb80
2020-04-21 20:34:44 -07:00
Josh Gao
073c8d2394 adbd: improve coverage by compiling less code.
Test: ./coverage/gen_coverage.sh && ./coverage/report.sh
Change-Id: I26f823e2587435b7ec2c6ca05955adef5cfc23a0
2020-04-21 17:57:29 -07:00
Josh Gao
f099105f07 adb: refactor and relocate coverage script.
Test: ./coverage/gen_coverage.sh
Change-Id: Iaff2b1577e32ba4ec8647a418a2ff4a1e9a0835d
2020-04-21 17:57:19 -07:00
Josh Gao
79d4f148d6 adbd: test TCP in coverage.
Test: ./coverage.sh
Change-Id: I82a0d54fcc1e19585a27c2d049be40289bf15f60
2020-04-21 17:57:17 -07:00
Josh Gao
e3c62cc549 adb: allow wait-for-disconnect to match offline for TCP devices.
This fixes a bug in adb root/unroot where we always fail because we're
waiting for a TCP device to disappear.

Test: test_device.py over TCP
Change-Id: I7e4b6fdaa1070cee1f9b471de46ae00bf89b3089
2020-04-21 17:57:15 -07:00
Josh Gao
03bee48659 adbd: add unit tests to coverage report.
Test: ./coverage.sh
Change-Id: I268367b857efc2125c6714a1d0b0e874fa8d143d
2020-04-21 17:57:13 -07:00
Josh Gao
46eec792ff Merge "adb: add helper binary to do a usb reset on a device." am: 67095b28de am: 39d756f1df
Change-Id: I838527e9a72f1968d59dd7336f9aa4e1b313638b
2020-04-21 23:32:42 +00:00
Josh Gao
67095b28de Merge "adb: add helper binary to do a usb reset on a device." 2020-04-21 23:01:48 +00:00
Josh Gao
177bc8e062 Merge "adbd: add a script to generate coverage information." am: 1b81360c9e am: 7c1fd1025b
Change-Id: I272e0a9b3ea19a41977f1e7deeb0a3335cdc3c3d
2020-04-21 19:56:22 +00:00
Treehugger Robot
eb1a23d855 Merge "adbd: add a log message on start." am: 524bc1fdc6 am: 2579bb7646
Change-Id: I7abdea28e4f8789ae773c80ae7ae590f770f7c9b
2020-04-21 17:24:33 +00:00
Jiyong Park
132bb5f861 Merge changes from topic "apex_available" into rvc-dev
* changes:
  adbd: add apex_available and visibility for internal libs.
  Set apex_available property
  Set apex_available property
  Set apex_available property
  Set apex_available property
2020-04-21 03:15:39 +00:00
Josh Gao
c0d8686053 adbd: add a script to generate coverage information.
Test: ./coverage.sh
Change-Id: I1a3608063e4c4e3af5ec01680f0255d8c69e7127
2020-04-20 17:37:50 -07:00
Josh Gao
98419f738b adbd: add a log message on start.
Make it easier to identify adbd's PIDs for coverage purposes by adding
an explicit log message to grep for.

Test: manual
Change-Id: I47e13417c0d9adb7d427414fd70c218f988909f5
2020-04-20 16:45:55 -07:00
Joshua Duong
aa0b72931d adb: change mdns tls service names (RFC 6763).
Even though mdnsresponder seems to allow us to use _adb_secure_connect
and _adb_secure_pairing as service names, these names violate the syntax
outlined in RFC6763, and may not be compatible with other dns-sd
implementations.

Also address some comments from a previous CL.

Bug: 154268895

Test: atest adbd_test
Change-Id: Ia872e976fc4276587b500a827a41d46d9dc755dd
Merged-In: Ia872e976fc4276587b500a827a41d46d9dc755dd
2020-04-20 21:03:15 +00:00
Greg Kaiser
89fe376d13 [adb data server] Initialize variable
servingComplete_ was left uninitialized and only set to 'true'
in the code.  We initialize it to the 'false' state to avoid
uninitialized references in SkipToRequest().

Bug: 150865433
Test: TreeHugger
Change-Id: Ia8a4d7135c432eb657543c5498fc9dbe8f4718b6
Merged-In: Ia8a4d7135c432eb657543c5498fc9dbe8f4718b6
2020-04-20 11:06:13 -07:00
Josh Gao
d11e67d88d adbd: add apex_available and visibility for internal libs.
abb links against libadbd_core for the shell protocol, and must be
on the system image because it links against cmd, so let's just
expose it to abb for now.

Exempt-From-Owner-Approval: cherry-pick from AOSP

Bug: http://b/151398197
Test: treehugger
Merged-In: Id926bc4324d3259def21ea19d3bd72320311a6e3
(cherry picked from commit b567303330)
Change-Id: Id926bc4324d3259def21ea19d3bd72320311a6e3
2020-04-20 17:21:22 +09:00
Jiyong Park
137fb1ff1e Set apex_available property
The marked library(ies) were available to the adbd APEX via the
hand-written whitelist in build/soong/apex/apex.go. Trying to remove the
whitelist by adding apex_available property to the Android.bp of the
libraries.

Exempt-From-Owner-Approval: already +2'ed by the owner (enh)

Bug: 150999716
Bug: 151398197
Test: m
Merged-In: I8b572e3c4e76bd10c0443a6c08b72e9519243ab5
(cherry picked from commit d25bb60e05)
Change-Id: I8b572e3c4e76bd10c0443a6c08b72e9519243ab5
2020-04-20 16:07:35 +09:00
Josh Gao
1efd363be5 Merge "adbconnection: silence logspam." am: ff08a51a72 am: b9a10d4538
Change-Id: I591c8d81a67d6412132e4569d9ca0e4583708f95
2020-04-18 03:22:46 +00:00
Josh Gao
ff08a51a72 Merge "adbconnection: silence logspam." 2020-04-18 02:47:11 +00:00
Treehugger Robot
34f5c7bc83 Merge "adb: change mdns tls service names (RFC 6763)." am: 22cc277bfe am: ecc11836ec
Change-Id: Ie54edd228f5263b5a64439057c19059d5dd8fae1
2020-04-18 02:24:40 +00:00
Treehugger Robot
22cc277bfe Merge "adb: change mdns tls service names (RFC 6763)." 2020-04-18 01:37:41 +00:00
Treehugger Robot
891bb8d9d1 Merge "adbconnection: delete unnecessary darwin workaround." am: 04e9d07490 am: 7bdf442375
Change-Id: Id497d2c061d183e5fae9700ce0cd12db978e4cfd
2020-04-18 00:23:30 +00:00
Joshua Duong
81f2db4d6a adb: change mdns tls service names (RFC 6763).
Even though mdnsresponder seems to allow us to use _adb_secure_connect
and _adb_secure_pairing as service names, these names violate the syntax
outlined in RFC6763, and may not be compatible with other dns-sd
implementations.

Also address some comments from a previous CL.

Bug: 154268895

Test: atest adbd_test
Change-Id: Ia872e976fc4276587b500a827a41d46d9dc755dd
2020-04-17 16:38:34 -07:00
Josh Gao
d81a805a4c adbconnection: silence logspam.
Userdebug devices enable JDWP for every process, so if adbd is turned
off manually, we get an error message for every single process on the
system.

Bug: http://b/154319466
Test: manual
Change-Id: Ia702974d371e35497573c31e22cfb2b572334590
2020-04-17 16:35:01 -07:00
Josh Gao
4a1da79208 adbconnection: delete unnecessary darwin workaround.
This shouldn't be compiling for the mac.

Test: none
Change-Id: I9aea1861365c0da041c665e14e3e86cb802ad697
2020-04-17 14:46:41 -07:00
Elliott Hughes
44daa2dde1 macOS build fix: no off64_t on darwin.
Darwin has always had a 64-bit off_t, and never added an off64_t.

Bug: 153328340
Test: builds on mac
Change-Id: I4b244dda94c67da76c9e0f47b333c2734f5a94af
2020-04-17 10:17:02 +00:00
Josh Gao
5ede605c6b Merge "adb: fix feature sets on devices that don't have them." am: 10f8f5e363 am: da03311c3f
Change-Id: I34f948bae331d20d49bd861a3976f30a1b46ff10
2020-04-17 05:12:08 +00:00
Josh Gao
fb4616b200 adb: fix feature sets on devices that don't have them.
Previously, we weren't distinguishing between nonexistent devices and
devices that don't support features, resulting in lots of stuff being
broken for pre-N devices.

Bug: http://b/154272158
Test: adb shell on a JB emulator
Change-Id: I0058b2a60678e1ad0503f5abac30157be976c9c4
2020-04-16 19:39:05 -07:00
Treehugger Robot
f41ce8be8f Merge "macOS build fix: no SOCK_CLOEXEC on darwin." am: 8fbb0d8de0 am: c933da92d6
Change-Id: Ib8a36ab117a290695e511d31a50758210882e67b
2020-04-15 23:47:14 +00:00
Treehugger Robot
8fbb0d8de0 Merge "macOS build fix: no SOCK_CLOEXEC on darwin." 2020-04-15 23:38:53 +00:00
Treehugger Robot
03f371e32e Merge "macOS build fix: no off64_t on darwin." am: 63f2be8f56 am: a1c8b995fb
Change-Id: I8b3c80e110c4978e7d94cddd26d60d1371961ac7
2020-04-15 22:45:50 +00:00
Treehugger Robot
63f2be8f56 Merge "macOS build fix: no off64_t on darwin." 2020-04-15 22:24:03 +00:00
Elliott Hughes
cbe30fb952 macOS build fix: no SOCK_CLOEXEC on darwin.
We can't use the sysdeps.h copy of this code, so for now add yet
another copy & paste. We should come up with something better in
libbase, but let's get the macOS build fixed first.

Test: builds on mac
Change-Id: Ifb059990d7091f3d91b54e684f4ee14afe69c28b
2020-04-15 21:28:01 +00:00
Elliott Hughes
31484c4d88 Merge "[incfs] Stream the hash tree for incremental installation" into rvc-dev-plus-aosp 2020-04-15 20:47:41 +00:00
Treehugger Robot
09fa233ae1 Merge "Remove host_supported from libadb_pairing_server." am: 0b708cba86 am: 61bd06d0fa
Change-Id: I8bca9c8176e9bf1bb05e22850033d69d2ca097d3
2020-04-15 18:11:49 +00:00
Treehugger Robot
513bae7660 Merge "macOS build fix: don't build libadbconnection." am: 8b4ed5f6b6 am: 072e1d3ad4
Change-Id: I224a97c89bbc0f6e8db2ef7cd9eb709b3ee362ef
2020-04-15 17:26:08 +00:00
Alex Buynytskyy
203006b72a [incfs] Stream the hash tree for incremental installation
Instead of sending the whole tree upfront use the same
streaming interface for it as for the data blocks

This improves installation speed by almost 200ms,
650-800ms -> 500-600ms

Bug: 153696423
Test: manual, adb install in various configurations

Change-Id: Ia83de2af54ca0b1969397514ea5d761719af9055
(cherry picked from commit e2e850f325)
Merged-In: Ia83de2af54ca0b1969397514ea5d761719af9055
2020-04-15 17:07:07 +00:00
Joshua Duong
5e32d2f8de Remove host_supported from libadb_pairing_server.
To fix mac build error. Shouldn't be building this for the host.

Bug: N/A

Test: mma in system/core/adb on mac.
Change-Id: I8b86d265ef9b91eeaf7a4e5d6623a5399403ecaf
2020-04-15 06:53:38 +00:00
Elliott Hughes
729f58e0b7 macOS build fix: don't build libadbconnection.
Test: builds on mac
Change-Id: I91e3bf6b06f31edf542f8f8d6529787b0bf3a6ed
2020-04-14 16:33:16 -07:00
Elliott Hughes
7d9a7a3b6e macOS build fix: no off64_t on darwin.
Darwin has always had a 64-bit off_t, and never added an off64_t.

Test: builds on mac
Change-Id: I4b244dda94c67da76c9e0f47b333c2734f5a94af
2020-04-14 15:34:01 -07:00
Elliott Hughes
e2bd0f0f6d Add missing static for macOS inline.
Also switch to #pragma once and s/__inline__/inline/g for consistency.

There are a handful of inlines that are missing static, which seems like
a bug, but I've left those for now.

Bug: http://b/153328340
Test: treehugger
Change-Id: I2353215c0a8a6154ce8b39ecde022b282f5c0cb9
Merged-In: I2353215c0a8a6154ce8b39ecde022b282f5c0cb9
(cherry picked from commit 681338dfb6)
2020-04-13 17:17:31 -07:00
Alex Buynytskyy
82c1c9711d [incfs] Stream the hash tree for incremental installation
Instead of sending the whole tree upfront use the same
streaming interface for it as for the data blocks

This improves installation speed by almost 200ms,
650-800ms -> 500-600ms

Bug: 153696423
Test: manual, adb install in various configurations

Change-Id: Ia83de2af54ca0b1969397514ea5d761719af9055
Merged-In: Ia83de2af54ca0b1969397514ea5d761719af9055
2020-04-13 13:00:01 -07:00
Alex Buynytskyy
e2e850f325 [incfs] Stream the hash tree for incremental installation
Instead of sending the whole tree upfront use the same
streaming interface for it as for the data blocks

This improves installation speed by almost 200ms,
650-800ms -> 500-600ms

Bug: 153696423
Test: manual, adb install in various configurations

Change-Id: Ia83de2af54ca0b1969397514ea5d761719af9055
2020-04-10 14:45:51 -07:00
Josh Gao
196c93242f Merge "[adb] Don't copy features set on each get()" am: 8489bfb4d7 am: 257c5ef607
Change-Id: If36be78966aacacb001ef0666d86bbbb0fcbfed1
2020-04-10 19:23:30 +00:00
Yurii Zubrytskyi
6fc26dff7c [adb] Don't copy features set on each get()
The features are already cached in a static and don't change.
Let's return the cached set instead of copying it every time.

Bug: 150183149
Test: manual
Change-Id: Ifdca852cc3b32e09e50ea4771f7878987c46cce8
2020-04-09 22:26:48 -07:00
Jooyung Han
31242c07fa Add min_sdk_version:R to updatable apexes
APEXes introduced in R need to set min_sdk_version to ensure that they
are built against correct version of stubs (libc/liblog/...).

Bug: 152655956
Test: m
Merged-In: Id3f94a2ac09bd7bf7f9a4a0c2f62b624f29509d0
Change-Id: Id3f94a2ac09bd7bf7f9a4a0c2f62b624f29509d0
(cherry picked from commit ab9dfa4321)
2020-04-09 16:08:43 +09:00
Josh Gao
b3ae997474 Merge changes from topic "adbd_lz4" am: 89cce05891 am: a047e4dbf4
Change-Id: If5e8c2607efa41a9e827abd9a2fe3d5533238e8e
2020-04-07 22:10:27 +00:00
Josh Gao
441808a139 adb: implement LZ4 compression. am: ec44d35fde am: e8d1281a48
Change-Id: I77c83a4725c4523db2015f7ab891621ab8828a77
2020-04-07 22:10:25 +00:00
Josh Gao
1b68baa26c adb: fix use of wrong union variant. am: 2165717875 am: 906ae0d9b0
Change-Id: I5433d281c9e4414e670b60b1547e3280d566a0b3
2020-04-07 22:10:24 +00:00
Josh Gao
5c4fbedebd adb: fix front_size, front_data. am: 4da40a9a5b am: 3a69cc704b
Change-Id: If3422b868a2a8ae9000188603426e336e7193176
2020-04-07 22:10:22 +00:00
Josh Gao
b58e9916fb adb: add interfaces for Encoder/Decoder. am: 49ba558aa8 am: 0864b99961
Change-Id: I64298a19fb7a36fca0f987164b58aea3f526b93c
2020-04-07 22:10:18 +00:00
Josh Gao
e8d1281a48 adb: implement LZ4 compression. am: ec44d35fde
Change-Id: Ie0ab6283ea843884a56bf0f0453036ae9f2e788c
2020-04-07 21:40:15 +00:00
Josh Gao
906ae0d9b0 adb: fix use of wrong union variant. am: 2165717875
Change-Id: I113892ca335419cb0eea8557e554497ed219aad3
2020-04-07 21:40:13 +00:00
Josh Gao
3a69cc704b adb: fix front_size, front_data. am: 4da40a9a5b
Change-Id: Ia54083330d8e8bde1f86821d9900644d73329bed
2020-04-07 21:40:12 +00:00
Josh Gao
0864b99961 adb: add interfaces for Encoder/Decoder. am: 49ba558aa8
Change-Id: If61913830dc03c54867a7bab3baadad780935aaa
2020-04-07 21:40:10 +00:00
Josh Gao
89cce05891 Merge changes from topic "adbd_lz4"
* changes:
  adb: add dry-run option to push/sync.
  adb: implement LZ4 compression.
  adb: fix use of wrong union variant.
  adb: fix front_size, front_data.
  adb: add interfaces for Encoder/Decoder.
2020-04-07 21:30:30 +00:00
Josh Gao
06369affd4 Merge "adb: add option to disable kill-server." am: edd7771583 am: a893592e56
Change-Id: I322447e7c6a02607144635d8632ca7641c1ea353
2020-04-07 21:22:08 +00:00
Josh Gao
edd7771583 Merge "adb: add option to disable kill-server." 2020-04-07 20:36:47 +00:00
Elliott Hughes
8bb8c06357 Merge "Add missing static for macOS inline." am: a0c191867f am: 838f9e14f4
Change-Id: Ia2e1fefb98067b7220ac266a577d5544c11d7cb1
2020-04-07 20:04:54 +00:00
Elliott Hughes
a0c191867f Merge "Add missing static for macOS inline." 2020-04-07 19:43:29 +00:00
Josh Gao
6cc08dbf6a Merge "Revert "Reland "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor""" into rvc-dev am: 60375b7cc6
Change-Id: I60c273c8ffd3404f4cd165932887ec9b81d9c2c8
2020-04-07 11:19:32 +00:00
Josh Gao
20f079ec66 Merge "Revert "Reland "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor""" 2020-04-07 11:08:00 +00:00
Josh Gao
9026a44bb3 Revert "Reland "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor""
This reverts commit bfe3dac36d.

This seems to be correlated with an increase in the rate of devices
going offline. Revert it to see if failure rates improve.

Bug: http://b/150863651
Test: treehugger
Change-Id: Ia6163fd9e31d2bf812628e028249662594ac2024
2020-04-06 16:49:01 -07:00
Josh Gao
b3b43be658 Revert "Reland "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor""
This reverts commit d9684d5943.

This seems to be correlated with an increase in the rate of devices
going offline. Revert it to see if failure rates improve.

Bug: http://b/150863651
Test: treehugger
Change-Id: Ia6163fd9e31d2bf812628e028249662594ac2024
2020-04-06 16:48:35 -07:00
Josh Gao
ba6d1da8ea adb: add option to disable kill-server.
In the post-apocalypse, it's increasingly common for people to use ssh
port forwarding to use an adb client with a remote adb server. This
results in `adb kill-server` being catastrophic, because the client has
no way of restarting the server on the other end. Android Studio in
particular has an unforunate habit of trying to manage adb's life cycle
such that starting or exiting Studio will result in a kill-server.

Add the ADB_REJECT_KILL_SERVER environment variable which ignores
kill-server, to make this scenario a bit better.

Bug: http://b/152251952
Test: ADB_REJECT_KILL_SERVER=1 adb start-server; adb kill-server
Change-Id: I5533a6dcbdb9220526a6fcf9ca31d9fcef1cec17
2020-04-06 14:33:14 -07:00
Elliott Hughes
681338dfb6 Add missing static for macOS inline.
Also switch to #pragma once and s/__inline__/inline/g for consistency.

There are a handful of inlines that are missing static, which seems like
a bug, but I've left those for now.

Bug: http://b/153328340
Test: treehugger
Change-Id: I2353215c0a8a6154ce8b39ecde022b282f5c0cb9
2020-04-06 09:17:08 -07:00
Jooyung Han
92bd33a286 Merge "Add min_sdk_version:R to updatable apexes" into rvc-dev am: a05e2b1a92
Change-Id: Ie396cf616dec766279bdcba26456be94fcc33bfa
2020-04-05 00:32:30 +00:00
Jooyung Han
a05e2b1a92 Merge "Add min_sdk_version:R to updatable apexes" into rvc-dev 2020-04-05 00:14:36 +00:00
Josh Gao
d527ae40dc Merge "adb: add implementation of mempcpy for deficient platforms." into rvc-dev 2020-04-04 06:45:09 +00:00
Josh Gao
0bd7d43f8b Merge "adb: add implementation of mempcpy for deficient platforms." am: d956dd78d0 am: 1264028fc7
Change-Id: Ia66bca6d22a6f573b48b319c1e00cf23f404f818
2020-04-03 19:50:28 +00:00
Josh Gao
fbf30e4155 adb: add implementation of mempcpy for deficient platforms.
Bug: http://b/150827486
Test: none
Change-Id: Ic2f4e1c85c9f02e804d849c6cb60b22e15e981d6
(cherry picked from commit 0aafa0f714)
2020-04-03 12:18:29 -07:00
Josh Gao
0aafa0f714 adb: add implementation of mempcpy for deficient platforms.
Test: none
Change-Id: Ic2f4e1c85c9f02e804d849c6cb60b22e15e981d6
2020-04-03 10:13:53 -07:00
Josh Gao
5949fccc42 adb: add dry-run option to push/sync.
Make it easier to benchmark file sync performance by ignoring the file
system.

Bug: https://issuetracker.google.com/150827486
Test: test_device.py
Change-Id: Icfa4b28eb5206f1914c0c163833d070a3748c3ea
2020-04-02 17:11:08 -07:00
Josh Gao
ec44d35fde adb: implement LZ4 compression.
Add support for LZ4 compression, which compresses and decompresses far
more quickly than brotli, at the cost of worse compression ratio.

`adb sync -d system` speeds (in MB/s) on aosp_blueline-eng:

           none    brotli    lz4
USB 3.0     120       110    190
USB 2.0      38        75     63

Bug: https://issuetracker.google.com/150827486
Test: python3 -m unittest test_device.FileOperationsTest{Uncompressed,Brotli,LZ4}
Change-Id: Ibef6ac15a76b4e5dcd02d7fb9433cbb1c02b8382
2020-04-02 17:11:07 -07:00
Josh Gao
2165717875 adb: fix use of wrong union variant.
Also, prepare to add more compression flags.

Bug: https://issuetracker.google.com/150827486
Test: none
Change-Id: I5044e5d5944aff5c18241fd7439baa48e2e09980
2020-04-02 17:11:07 -07:00
Josh Gao
4da40a9a5b adb: fix front_size, front_data.
Bug: https://issuetracker.google.com/150827486
Test: adb_test
Change-Id: I3d2c73a20a703d793efb56e592cf33149815f89b
2020-04-02 17:11:07 -07:00
Josh Gao
49ba558aa8 adb: add interfaces for Encoder/Decoder.
More groundwork to support more compression algorithms.

Bug: https://issuetracker.google.com/150827486
Test: python3 -m unittest test_device.FileOperationsTest{Uncompressed,Brotli}
Change-Id: I638493083b83e3f6c6854b631471e9d6b50bd79f
2020-04-02 17:11:07 -07:00
Josh Gao
d6998c98d8 Merge changes I90e10c74,I038d1df4,I4299bd96 am: 73d44bb6c2 am: 72138abaa7
Change-Id: Ifa3354b755dab76cff00f3e7ceb0a80e5dd6657d
2020-04-01 23:19:26 +00:00
Josh Gao
e485bdf06e adbd: delete unused variable.
Bug: https://issuetracker.google.com/150827486
Test: m adb com.android.adbd.apex
Change-Id: I90e10c74d695659c702dea4173cb33ac5ca1a102
2020-04-01 13:09:31 -07:00
Josh Gao
6e697f2f8c adb: move things around to prepare to add LZ4.
Bug: https://issuetracker.google.com/150827486
Test: m adb com.android.adbd.apex
Change-Id: I038d1df4f179ddb23102016d781c9bd90da5a546
2020-04-01 13:09:29 -07:00
Josh Gao
31d42aa73c adb: fix misindentation in Android.bp
Bug: https://issuetracker.google.com/150827486
Test: none
Change-Id: I4299bd962963a58ef5f075405b99b1d1e4c1febc
2020-04-01 13:09:16 -07:00
Jooyung Han
ab9dfa4321 Add min_sdk_version:R to updatable apexes
APEXes introduced in R need to set min_sdk_version to ensure that they
are built against correct version(30 or R) of stubs (libc/liblog/...).

Bug: 152655956
Test: /vendor/google/build/build_mainline_modules.sh
Change-Id: Id3f94a2ac09bd7bf7f9a4a0c2f62b624f29509d0
2020-04-02 03:02:16 +09:00
Josh Gao
36fb67568c Statically link libadbd into minadbd.
Bug: http://b/150317254
Test: booted aosp_walleye-eng into recovery
Change-Id: Ie479ae2fbaf1006228a531dab26c7d535ed403db
Merged-In: Ie479ae2fbaf1006228a531dab26c7d535ed403db
(cherry picked from commit 3735614b28)
2020-03-31 19:16:08 -07:00
Josh Gao
2b5fa5505f adb: temporarily kill adb_benchmark.
Temporarily delete adb_benchmark, since it seems difficult to make this
sensibly work with a single target that's used for both libadb and
libadbd benchmarking.

Bug: http://b/150317254
Test: treehugger
Change-Id: Ibf81fdff4f2b7304b586ce9a7955b4bc2c11484e
Merged-In: Ibf81fdff4f2b7304b586ce9a7955b4bc2c11484e
(cherry picked from commit c6cb89ea80)
2020-03-31 16:05:41 -07:00
Josh Gao
2783122071 Move adbd's legacy USB implementation to fastboot.
This code path is effectively dead in adbd, and fastboot's dependency on
libadbd makes it hard to refactor adbd's dependencies.

Bug: http://b/150317254
Test: built and flashed aosp_walleye-eng
Change-Id: I5118136d32fdcbbd011559ed0a4a71e1dc7bf064
Merged-In: I5118136d32fdcbbd011559ed0a4a71e1dc7bf064
(cherry picked from commit 0871824de6)
2020-03-31 16:05:36 -07:00
Yurii Zubrytskyi
26dc4cc04d Merge "adb: fix apex installation." am: f8dc296dfd am: 39f4a75392
Change-Id: I89c773a5d5169c01e9ca58f1f8f6575d4e0882a8
2020-03-31 17:34:46 +00:00
Josh Gao
cbdc9934c2 adb: fix apex installation.
Incremental doesn't support apex installation, but we were exiting
instead of returning -1 to fall back to regular installation.

Bug: http://b/151900478
Test: manual
Change-Id: Id27009250090a65fbb45bb65fc39c1799bf1f861
Merged-In: Id27009250090a65fbb45bb65fc39c1799bf1f861
2020-03-31 10:09:21 -07:00
Yurii Zubrytskyi
bc445fbab8 [adb] Use incremental installation by default
This CL turns on the incremental installation for all
"adb install ..." commands where no explicit mode has been set.
To disable this, set the ADB_INSTALL_DEFAULT_INCREMENTAL
environment variable to 0/n/no/false. Unset to enable back

+ improve the install command argument parsing a bit: allow
  --wait for all installation modes, --incr is enough for
  an incremental install (and --no-incr to disable it)

Bug: 150183149
Test: adb install with different apks and command line switches
Change-Id: I1a237f34b70d920146746ab16104e28ef555a5fd
Merged-In: I1a237f34b70d920146746ab16104e28ef555a5fd
2020-03-31 10:04:15 -07:00
Yurii Zubrytskyi
f8dc296dfd Merge "adb: fix apex installation." 2020-03-31 16:56:07 +00:00
Josh Gao
c8a8e2a35e Merge "Statically link libadbd into minadbd." am: db22f23dd3 am: b903481992
Change-Id: I44d9fa2effda1f09c80bc3855ba7e3fd4c1bb6cc
2020-03-31 08:53:38 +00:00
Josh Gao
764bffe411 Merge "adb: temporarily kill adb_benchmark." am: d6211a2dde am: a056a8f239
Change-Id: I2204d9e9deae233cf827b4b71ee950360bc433bc
2020-03-31 04:09:06 +00:00
Josh Gao
3c1803cab5 adb: fix apex installation.
Incremental doesn't support apex installation, but we were exiting
instead of returning -1 to fall back to regular installation.

Bug: http://b/151900478
Test: manual
Change-Id: Id27009250090a65fbb45bb65fc39c1799bf1f861
2020-03-31 02:08:14 +00:00
Josh Gao
3735614b28 Statically link libadbd into minadbd.
Bug: http://b/150317254
Test: booted aosp_walleye-eng into recovery
Change-Id: Ie479ae2fbaf1006228a531dab26c7d535ed403db
2020-03-30 18:51:15 -07:00
Josh Gao
ed91f30517 Merge "Move adbd's legacy USB implementation to fastboot." am: fd193bd291 am: 0a9431d0f3
Change-Id: I0cd942c1e13bf432fc91ed366266ee3227bde361
2020-03-31 00:50:44 +00:00
Josh Gao
c6cb89ea80 adb: temporarily kill adb_benchmark.
Temporarily delete adb_benchmark, since it seems difficult to make this
sensibly work with a single target that's used for both libadb and
libadbd benchmarking.

Bug: http://b/150317254
Test: treehugger
Change-Id: Ibf81fdff4f2b7304b586ce9a7955b4bc2c11484e
2020-03-30 16:43:06 -07:00
Josh Gao
0871824de6 Move adbd's legacy USB implementation to fastboot.
This code path is effectively dead in adbd, and fastboot's dependency on
libadbd makes it hard to refactor adbd's dependencies.

Bug: http://b/150317254
Test: built and flashed aosp_walleye-eng
Change-Id: I5118136d32fdcbbd011559ed0a4a71e1dc7bf064
2020-03-30 16:43:06 -07:00
Songchun Fan
f25ffde2dd Merge "[adb] use zip iteration with functor" am: 26a8ed983c am: d9ec4fc3f3
Change-Id: Id89e24dc5e57cf58c9dd069c31001297b428d279
2020-03-28 03:37:10 +00:00
Songchun Fan
26a8ed983c Merge "[adb] use zip iteration with functor" 2020-03-28 03:03:07 +00:00
Treehugger Robot
26e592437b Merge "Revert "Revert "Delay initial accept() until server initialized""" am: 551130fc2b am: 6ebfda18e9
Change-Id: I7017ca9abd2c981606a81c6046ef41333ac352a8
2020-03-28 01:52:07 +00:00
Songchun Fan
0f11895157 [adb] use zip iteration with functor
Test: manual
BUG: 151676293
Change-Id: I738811bb5ff3ecc86ae49aa64df29427fb4ec69a
2020-03-27 18:38:50 -07:00
Treehugger Robot
551130fc2b Merge "Revert "Revert "Delay initial accept() until server initialized""" 2020-03-28 01:27:38 +00:00
Treehugger Robot
3e6d867653 Merge "[adb] Use incremental installation by default" am: 02875acf84 am: ba6f4f78a1
Change-Id: Icf35e1e18145b2c29b3fbd736fb398dd3c96ff74
2020-03-28 01:13:49 +00:00
Daniel Colascione
c2612cd775 Revert "Revert "Delay initial accept() until server initialized""
This reverts commit b71b5af783.

Test: actually build device and host adb this time
Change-Id: I9f9375aa83c9d023a1e26d2f95676b734e12f926
2020-03-27 20:51:19 +00:00
Yurii Zubrytskyi
4532ea881a [adb] Use incremental installation by default
This CL turns on the incremental installation for all
"adb install ..." commands where no explicit mode has been set.
To disable this, set the ADB_INSTALL_DEFAULT_INCREMENTAL
environment variable to 0/n/no/false. Unset to enable back

+ improve the install command argument parsing a bit: allow
  --wait for all installation modes, --incr is enough for
  an incremental install (and --no-incr to disable it)

Bug: 150183149
Test: adb install with different apks and command line switches
Change-Id: I1a237f34b70d920146746ab16104e28ef555a5fd
2020-03-27 12:30:29 -07:00
Treehugger Robot
e7c25a62ac Merge "adb: Avoid extra string construction" am: 6b42d6d859 am: b8a9b8f367
Change-Id: I02366963f140a705d88b5625c907f70791d89c74
2020-03-27 15:33:27 +00:00
Greg Kaiser
030f1effdf adb: Avoid extra string construction
Test: TreeHugger
Change-Id: Ie03062a17b98866f1bc419a7e509461cf4e6bb80
2020-03-27 06:10:11 -07:00
Yurii Zubrytskyi
063b81599c Merge "[adb] generic "cast_handle_to_int" function" am: a1f41fc6f1 am: 5ce68b0941
Change-Id: Ib7974bf235f0edd40670750a3a6c5c2d67cc00eb
2020-03-27 07:47:11 +00:00
Yurii Zubrytskyi
a1f41fc6f1 Merge "[adb] generic "cast_handle_to_int" function" 2020-03-27 07:03:22 +00:00
Treehugger Robot
7d105291da Merge "adb: fix bugreport status line." am: f225aa3f24 am: cf4f2c9439
Change-Id: I2585a1ff18dff168c67456232d18ee90f0bd0df4
2020-03-27 06:42:53 +00:00
Yurii Zubrytskyi
e3e64b8f54 [adb] generic "cast_handle_to_int" function
Now one can use it without platform #ifdefs

Bug: 150183149
Test: compiles
Change-Id: I6280dcdd2faaff33014f11237d9d04231ac16b82
2020-03-26 22:25:46 -07:00
Josh Gao
82f715b7b5 adb: fix bugreport status line.
The status line char* was getting converted to bool and used as the
compression argument, and the actual status line was defaulting to
nullptr. This didn't actually really change anything, since we only use
the name during transfer, and not for the final message at the end, so
the output is slightly uglier for 50 milliseconds.

This also had the side effect of turning on compression for the
already-compressed bugreport zip, which costs a bit of throughput with
brotli.

Bug: https://issuetracker.google.com/150827486
Test: adb bugreport foo.zip
Change-Id: I74bed9c09442c655a956eb1e8318c0123632ef4c
2020-03-26 21:10:31 -07:00
Josh Gao
50ab0a6900 adb: implement compression for file sync.
This improves performance when syncing by up to 2x (remote cuttlefish
goes from 11.9 MB/s to 21.3 MB/s, blueline over USB 2.0 from 36 MB/s
to 70 MB/s).

This results in a slight drop in push speeds over USB 3.0 (125 -> 115
MB/s on blueline), presumably because we're compressing and extracting
on only a single thread, but the gains over lower bandwidth transports
make this worth it to submit this now and parallelize later.

Bug: https://issuetracker.google.com/150827486
Test: ADB_COMPRESSION={0, 1} test_device.py (with new/old adbd)
Change-Id: Ic2a0c974f1b6efecda115f87d336e3caac810035
Merged-In: Ic2a0c974f1b6efecda115f87d336e3caac810035
(cherry picked from commit 939fc19aee)
2020-03-26 16:08:41 -07:00
Josh Gao
9b567bbd6d Merge "adb: implement compression for file sync." am: 4dc73c0b58 am: 1588155e47
Change-Id: I0ff4ddf1286a01ed2faeca7fdabe5d419d7228a8
2020-03-26 21:05:30 +00:00
Josh Gao
4dc73c0b58 Merge "adb: implement compression for file sync." 2020-03-26 20:34:17 +00:00
Josh Gao
939fc19aee adb: implement compression for file sync.
This improves performance when syncing by up to 2x (remote cuttlefish
goes from 11.9 MB/s to 21.3 MB/s, blueline over USB 2.0 from 36 MB/s
to 70 MB/s).

This results in a slight drop in push speeds over USB 3.0 (125 -> 115
MB/s on blueline), presumably because we're compressing and extracting
on only a single thread, but the gains over lower bandwidth transports
make this worth it to submit this now and parallelize later.

Bug: https://issuetracker.google.com/150827486
Test: ADB_COMPRESSION={0, 1} test_device.py (with new/old adbd)
Change-Id: Ic2a0c974f1b6efecda115f87d336e3caac810035
2020-03-26 13:31:32 -07:00
Joshua Duong
c69f30ea15 Merge "Pass the os handle to the tls connection." into rvc-dev 2020-03-26 06:12:28 +00:00
Joshua Duong
dd4ca8a9a1 Merge changes from topic "adbwifi-bugfixes" am: 1e413c8a9d am: b1ce151b34
Change-Id: I1c9b7462db4f2a8082279acabb6e27263006e030
2020-03-26 02:51:51 +00:00
Joshua Duong
bba72d951b Pass the os handle to the tls connection.
This fixes the tls connection failure on Windows.

Bug: 150719467

Test: 'adb pair', 'adb connect' on Windows host machine.
Test: atest adb_tls_connection_test
Change-Id: I54b8945543ad8b430510fa51dd7bea64a119454f
2020-03-26 02:18:07 +00:00
Joshua Duong
aed3408f47 Fix pairing aes_128_gcm key initialization.
Bug: 150719467

Test: atest adb_pairing_auth_test
Test: check 'adb pair' command on all three platforms work
Change-Id: Idfc64fe7bed2d09f4da9d2f7df70f9d6ae4e8fa3
2020-03-26 02:17:34 +00:00
Joshua Duong
1e413c8a9d Merge changes from topic "adbwifi-bugfixes"
* changes:
  Pass the os handle to the tls connection.
  Fix pairing aes_128_gcm key initialization.
2020-03-26 02:16:14 +00:00
Joshua Duong
1b273ed0e3 Pass the os handle to the tls connection.
This fixes the tls connection failure on Windows.

Bug: 150719467

Test: 'adb pair', 'adb connect' on Windows host machine.
Test: atest adb_tls_connection_test
Change-Id: I54b8945543ad8b430510fa51dd7bea64a119454f
2020-03-26 02:16:01 +00:00
Joshua Duong
87c00f8c80 Fix pairing aes_128_gcm key initialization.
Bug: 150719467

Test: atest adb_pairing_auth_test
Test: check 'adb pair' command on all three platforms work
Change-Id: Idfc64fe7bed2d09f4da9d2f7df70f9d6ae4e8fa3
Exempt-From-Owner-Approval: approved in go/ag/10808153
2020-03-26 02:14:48 +00:00
Treehugger Robot
cf8d5f6fef Merge "Revert "Revert "Set apex_available property""" am: 5e4b94d44d am: eccd4aad99
Change-Id: I1ebd28d9edc9da75d1d09075faabe67e721cb209
2020-03-26 01:17:57 +00:00
Treehugger Robot
5e4b94d44d Merge "Revert "Revert "Set apex_available property""" 2020-03-26 00:42:36 +00:00
Jiyong Park
697134d1d4 Revert "Revert "Set apex_available property""
This reverts commit 56a712f6c9.

Reason for revert: forward fix is at aosp/1265379

Exempt-From-Owner-Approval: relanding of an already approved CL

Change-Id: I0d93417939d570ce21f105ee4b3bae6414194dbe
2020-03-26 00:23:56 +00:00
Yurii Zubrytskyi
47a58ecd34 [adb] file sync performance on Windows
Print not more often than once a 100ms - it is smooth enough
and speeds up transfer even more on Windows, where a single
line output may take up to 5ms.
An added benefit is getting rid of some extra heap allocation
and string formatting when in the end the identical message
filtering would've dropped the line anyway. This is also
significantly more expensive on Windows.

Bug: 151900478
Test: manual, push/pull a file and a directory

Change-Id: I9038729e8a01d5f93fd301beaeb8a086f5039b77
Merged-In: I9038729e8a01d5f93fd301beaeb8a086f5039b77
2020-03-24 10:28:24 -07:00
Alex Buynytskyy
8539004821 Adding block kind to protocol for future streaming of a tree.
Bug: b/152050621
Test: adb install --incremental megacity.apk
Change-Id: I0c977080475088bf046a521a85f78595aac994f0
Merged-In: I0c977080475088bf046a521a85f78595aac994f0
2020-03-24 10:28:19 -07:00
Yurii Zubrytskyi
b0fa864cc5 [adb] Print fewer progress messages for push/pull
Windows console IO is terribly slow. Reducing the number of
printed progress messages speeds up the transfer rate
from 80 to 130 MB/s on Windows laptop

Bug: 151900478
Test: adb push/pull
Change-Id: I223284c8a662bd8f2b8ba280cdcc8c930d3e5205
Merged-In: I223284c8a662bd8f2b8ba280cdcc8c930d3e5205
2020-03-24 10:28:14 -07:00
Yurii Zubrytskyi
4eb910e82e [adb] Optimize fdevent machinery
- Use one fewer heap allocation per fdevent object
- Lazy-init the fdevent context

Bug: 151239696
Test: various adb commands on Win/Linux

Change-Id: Ic7de207b30495e618f187e097c0276ad42c34005
Merged-In: Ic7de207b30495e618f187e097c0276ad42c34005
2020-03-24 10:28:08 -07:00
Yurii Zubrytskyi
2488c21d8b [adb] Fix incremental installation on Windows
Use only the syscalls that work with the wrapped ADB fds, or
extract the native handles for the case when need to call one
not wrapped.

Bug: 151239696
Test: adb install --incremental <apk> on Windows
Change-Id: Ia6de620171ab696b8136dcb60a2b63af6f86419f
Merged-In: Ia6de620171ab696b8136dcb60a2b63af6f86419f
2020-03-24 10:28:03 -07:00
Songchun Fan
c3eb3014f6 [adb incremental] send priority blocks first
Before this change, "Success" is returned after all data is streamed,
around 7.5 seconds for Megacity.

After this change, "Success" is returned in about 1.5 seconds, before
streaming finishes.

BUG: 151676293
Test: manual
Change-Id: Ifda7de48da8e82623c99ae0194f70cb162fd72fa
Merged-In: Ifda7de48da8e82623c99ae0194f70cb162fd72fa
2020-03-24 10:27:56 -07:00
Songchun Fan
23bd5529c1 [adb data server] wait for installation results before terminates
Currently the server often quits before installation finishes. As a
result, there is no difference in the commandline output between a
successful installation and a failed one.

Let adb client wait till installation fails or succeeds by parsing the
output from the inc-server process.

Test: $ adb install --incremental ~/Downloads/base.apk
Test: Performing Incremental Install
Test: Serving...
Test: All files should be loaded. Notifying the device.
Test: Failure [INSTALL_PARSE_FAILED_NOT_APK: Failed to parse /data/app/vmdl749343150.tmp/base.apk: Failed to load asset path /data/app/vmdl749343150.tmp/base.apk]
Test: Install command complete (ms: 91 total, 0 apk prep, 91 install)

BUG: b/150865433
Change-Id: Ie33505f9cc08fc6d60ad4a5d709526e7aa9a0ad1
Merged-In: Ie33505f9cc08fc6d60ad4a5d709526e7aa9a0ad1
2020-03-24 10:27:47 -07:00
Alex Buynytskyy
eebf9f7670 Implement the new v4 signing scheme in adb
To be submitted along with changes in apksigner tool and the framework.
Merged to AOSP after that.

Test: adb install --incremental <apk>

Bug: b/151241461
Change-Id: I26e187f8e389e31e2759037057b96fc6c9cb1e94
Merged-In: I26e187f8e389e31e2759037057b96fc6c9cb1e94
2020-03-24 10:27:39 -07:00
Yurii Zubrytskyi
cf77acf723 Merge "[adb] file sync performance on Windows" into rvc-dev am: 34fdb226f5
Change-Id: Ib8a77d9db54ec0565798ea1fe80044d6e7bd04bc
2020-03-24 06:02:51 +00:00
Yurii Zubrytskyi
34fdb226f5 Merge "[adb] file sync performance on Windows" into rvc-dev 2020-03-24 05:47:13 +00:00
Josh Gao
a8776b4913 adb: fix sync.
adbd's file sync service doesn't handle a full socket gracefully,
immediately terminating the service as soon as it fails to write a
response. This would generally be fine if the socket's buffer were as
large as it claims (212992 by default with a 64-bit kernel), but this
buffer size is a giant lie, as each write has 576 bytes of overhead
that's used up in the send buffer. When setting the send buffer size,
the kernel helpfully doubles the value to attempt to account for the
overhead, but when writing 8 byte responses, only 2% of the buffer
actually gets used for responses, so we run out of buffer after 364
files instead of the 26624 that would be expected.

Fix this by processing the responses as they become available, and
calculate a maximum limit to how many sends we dispatch before we stop
and wait for responses to come in.

Bug: http://b/150827486
Test: manually modified adbd to respond with giant error messages, and
      modified adb to not read responses until we choose to block
Change-Id: Ieb8c935662864211e2fd16c337ffed0992990086
(cherry picked from commit 672cdfeeff)
2020-03-23 17:36:15 -07:00
Josh Gao
65396f4734 adb: extract syncmsg structs.
Make it so that we can get the sizeof a member of syncmsg without having
an instance of syncmsg or doing something awful along the lines of
sizeof(reinterpret_cast<syncmsg*>(nullptr)->status).

Bug: http://b/150827486
Test: m adb adbd
Change-Id: I4830e7f90033c7706ff52cdd8d13e9cf40c73628
(cherry picked from commit eddae92928)
2020-03-23 17:36:06 -07:00
Anna Trostanetski
1c1d2bb7e0 Merge "Revert "Set apex_available property"" am: 447a1ead21 am: d731f3ed3b
Change-Id: I2352a891e0d1c762280b4b981f695189417b89e8
2020-03-23 15:00:32 +00:00
Anna Trostanetski
447a1ead21 Merge "Revert "Set apex_available property"" 2020-03-23 14:14:32 +00:00
Anna Trostanetski
56a712f6c9 Revert "Set apex_available property"
This reverts commit d25bb60e05.

Reason for revert: Breaks build_test b/152190149
Bug: 152190149

Change-Id: I6b7cb4aa4fc07fae648bcf4d9e8f60ea1c62fd9e
2020-03-23 12:02:53 +00:00
Jiyong Park
3ee525ee32 Merge "Set apex_available property" am: fb0b0d24f2 am: d0d864deef
Change-Id: I34d549ca369020acf0939cdbf1cd64fb59a8f5ad
2020-03-23 11:21:44 +00:00
Jiyong Park
fb0b0d24f2 Merge "Set apex_available property" 2020-03-23 10:51:28 +00:00
Jiyong Park
d25bb60e05 Set apex_available property
The marked library(ies) were available to the adbd APEX via the
hand-written whitelist in build/soong/apex/apex.go. Trying to remove the
whitelist by adding apex_available property to the Android.bp of the
libraries.

Exempt-From-Owner-Approval: already +2'ed by the owner (enh)

Bug: 150999716
Bug: 151398197
Test: m
Change-Id: I8b572e3c4e76bd10c0443a6c08b72e9519243ab5
2020-03-23 10:50:12 +00:00
Treehugger Robot
4b437076dc Merge "adb: fix sync." am: 4abafe2230 am: 6e9effd885
Change-Id: I8a405cf3f731c347bc8cb9f660624108785ec979
2020-03-23 06:36:48 +00:00
Treehugger Robot
141aa49eea Merge "adb: extract syncmsg structs." am: c549b122f4 am: a651084255
Change-Id: I492b747e5d49d8b537a834bc731edb36579b79d9
2020-03-23 06:36:29 +00:00
Treehugger Robot
4abafe2230 Merge "adb: fix sync." 2020-03-23 06:06:25 +00:00
Treehugger Robot
c549b122f4 Merge "adb: extract syncmsg structs." 2020-03-23 06:01:26 +00:00
Josh Gao
672cdfeeff adb: fix sync.
adbd's file sync service doesn't handle a full socket gracefully,
immediately terminating the service as soon as it fails to write a
response. This would generally be fine if the socket's buffer were as
large as it claims (212992 by default with a 64-bit kernel), but this
buffer size is a giant lie, as each write has 576 bytes of overhead
that's used up in the send buffer. When setting the send buffer size,
the kernel helpfully doubles the value to attempt to account for the
overhead, but when writing 8 byte responses, only 2% of the buffer
actually gets used for responses, so we run out of buffer after 364
files instead of the 26624 that would be expected.

Fix this by processing the responses as they become available, and
calculate a maximum limit to how many sends we dispatch before we stop
and wait for responses to come in.

Test: manually modified adbd to respond with giant error messages, and
      modified adb to not read responses until we choose to block
Change-Id: Ieb8c935662864211e2fd16c337ffed0992990086
2020-03-21 20:06:39 -07:00
Yurii Zubrytskyi
05227d99e0 [adb] file sync performance on Windows
Print not more often than once a 100ms - it is smooth enough
and speeds up transfer even more on Windows, where a single
line output may take up to 5ms.
An added benefit is getting rid of some extra heap allocation
and string formatting when in the end the identical message
filtering would've dropped the line anyway. This is also
significantly more expensive on Windows.

Bug: 151900478
Test: manual, push/pull a file and a directory

Change-Id: I9038729e8a01d5f93fd301beaeb8a086f5039b77
2020-03-20 22:48:10 -07:00
Yurii Zubrytskyi
b959a788b2 Merge "Adding block kind to protocol for future streaming of a tree." into rvc-dev am: c0a5aff0df
Change-Id: Ie9f752720280473a4634c184448cbc6b3a57812b
2020-03-20 22:27:09 +00:00
Yurii Zubrytskyi
c0a5aff0df Merge "Adding block kind to protocol for future streaming of a tree." into rvc-dev 2020-03-20 22:20:57 +00:00
Alex Buynytskyy
e7817e42d1 Adding block kind to protocol for future streaming of a tree.
Bug: b/152050621
Test: adb install --incremental megacity.apk
Change-Id: I0c977080475088bf046a521a85f78595aac994f0
2020-03-20 11:18:33 -07:00
Josh Gao
6e9bbfcc0e Merge "adbd: add apex_available and visibility for internal libs." am: 448519736b am: b802fd9b1c
Change-Id: I4f3ba750255be96a1f0a0b3a18d16b2266ccf9fa
2020-03-20 10:29:17 +00:00
TreeHugger Robot
97046b951c Merge "[adb] Print fewer progress messages for push/pull" into rvc-dev am: 934135d576
Change-Id: I3a05ae90ff85a979a1d4efc661e8c8a2f2aa13e7
2020-03-20 10:13:15 +00:00
TreeHugger Robot
934135d576 Merge "[adb] Print fewer progress messages for push/pull" into rvc-dev 2020-03-20 09:59:55 +00:00
TreeHugger Robot
50821ab80b Merge "[adb] Optimize fdevent machinery" into rvc-dev am: fd3b80c99c
Change-Id: I80e4f2baaacb88ec78a6fc0a557fe7d748536e0d
2020-03-20 06:47:42 +00:00
TreeHugger Robot
fd3b80c99c Merge "[adb] Optimize fdevent machinery" into rvc-dev 2020-03-20 06:33:47 +00:00
Josh Gao
eddae92928 adb: extract syncmsg structs.
Make it so that we can get the sizeof a member of syncmsg without having
an instance of syncmsg or doing something awful along the lines of
sizeof(reinterpret_cast<syncmsg*>(nullptr)->status).

Test: m adb adbd
Change-Id: I4830e7f90033c7706ff52cdd8d13e9cf40c73628
2020-03-19 17:24:15 -07:00
TreeHugger Robot
8d4383e728 Merge "[adb] Fix incremental installation on Windows" into rvc-dev am: ea1103cb1d
Change-Id: Id4fc8cd1430efd567f86acc22664c3f452e6fc6f
2020-03-19 22:19:48 +00:00
TreeHugger Robot
ea1103cb1d Merge "[adb] Fix incremental installation on Windows" into rvc-dev 2020-03-19 22:05:53 +00:00
TreeHugger Robot
80afce0b66 Merge "[adb data server] Initialize variable" into rvc-dev am: 126a1c2dd0
Change-Id: If01b50552b08160da93b4b6b3880133d17b3e2ed
2020-03-19 17:32:33 +00:00
Yurii Zubrytskyi
67caf0ceef [adb] Print fewer progress messages for push/pull
Windows console IO is terribly slow. Reducing the number of
printed progress messages speeds up the transfer rate
from 80 to 130 MB/s on Windows laptop

Bug: 151900478
Test: adb push/pull
Change-Id: I223284c8a662bd8f2b8ba280cdcc8c930d3e5205
2020-03-19 00:21:08 -07:00
Yurii Zubrytskyi
76820308c5 [adb] Optimize fdevent machinery
- Use one fewer heap allocation per fdevent object
- Lazy-init the fdevent context

Bug: 151239696
Test: various adb commands on Win/Linux

Change-Id: Ic7de207b30495e618f187e097c0276ad42c34005
2020-03-18 23:20:00 -07:00
Yurii Zubrytskyi
c3ac339daf [adb] Fix incremental installation on Windows
Use only the syscalls that work with the wrapped ADB fds, or
extract the native handles for the case when need to call one
not wrapped.

Bug: 151239696
Test: adb install --incremental <apk> on Windows
Change-Id: Ia6de620171ab696b8136dcb60a2b63af6f86419f
2020-03-18 22:28:01 -07:00
Josh Gao
b567303330 adbd: add apex_available and visibility for internal libs.
abb links against libadbd_core for the shell protocol, and must be
on the system image because it links against cmd, so let's just
expose it to abb for now.

Bug: http://b/151398197
Test: treehugger
Change-Id: Id926bc4324d3259def21ea19d3bd72320311a6e3
2020-03-18 18:36:01 -07:00
Josh Gao
b9059f8ad7 adb: add helper binary to do a usb reset on a device.
Bug: http://b/150863651
Test: manual
Change-Id: I70e0e5c49fb1b43f7f21d2e709f4091c41ebcfac
2020-03-18 14:59:15 -07:00
Greg Kaiser
6a2c18a88f [adb data server] Initialize variable
servingComplete_ was left uninitialized and only set to 'true'
in the code.  We initialize it to the 'false' state to avoid
uninitialized references in SkipToRequest().

Bug: 150865433
Test: TreeHugger
Change-Id: Ia8a4d7135c432eb657543c5498fc9dbe8f4718b6
2020-03-18 06:18:10 -07:00
Yurii Zubrytskyi
4e7bede912 Merge changes Ifda7de48,Ie33505f9 into rvc-dev am: c2872d831d
Change-Id: I632830b0a15bdada757230c2a1d6ec4f48ce51ee
2020-03-18 03:38:50 +00:00
Songchun Fan
8cdefd4f95 [adb incremental] send priority blocks first
Before this change, "Success" is returned after all data is streamed,
around 7.5 seconds for Megacity.

After this change, "Success" is returned in about 1.5 seconds, before
streaming finishes.

BUG: 151676293
Test: manual
Change-Id: Ifda7de48da8e82623c99ae0194f70cb162fd72fa
2020-03-17 20:19:49 -07:00
Songchun Fan
c4a9d16ef1 [adb data server] wait for installation results before terminates
Currently the server often quits before installation finishes. As a
result, there is no difference in the commandline output between a
successful installation and a failed one.

Let adb client wait till installation fails or succeeds by parsing the
output from the inc-server process.

Test: $ adb install --incremental ~/Downloads/base.apk
Test: Performing Incremental Install
Test: Serving...
Test: All files should be loaded. Notifying the device.
Test: Failure [INSTALL_PARSE_FAILED_NOT_APK: Failed to parse /data/app/vmdl749343150.tmp/base.apk: Failed to load asset path /data/app/vmdl749343150.tmp/base.apk]
Test: Install command complete (ms: 91 total, 0 apk prep, 91 install)

BUG: b/150865433
Change-Id: Ie33505f9cc08fc6d60ad4a5d709526e7aa9a0ad1
2020-03-17 20:19:47 -07:00
Automerger Merge Worker
6a0d14ac15 Merge "adbd: shrink libadbd.so, libadbd_services.so." am: cb76bf0558 am: e7d5ae30c6
Change-Id: I55dd7c315e2222584972ded39571d845a3f7fffa
2020-03-16 21:38:02 +00:00
Josh Gao
c151a1ba28 adbd: shrink libadbd.so, libadbd_services.so.
We were ending up with multiple copies of the proto runtime in the
recovery image, when we need zero.

Before:
    784K	recovery/root/system/lib64/libadbd_services.so
    832K	recovery/root/system/lib64/libadbd.so

After:
    360K	recovery/root/system/lib64/libadbd_services.so
    344K	recovery/root/system/lib64/libadbd.so

Bug: http://b/150317254
Test: treehugger
Change-Id: I39fbb3959128994f0de2ae0ea47dbc0800c516fe
2020-03-16 11:30:09 -07:00
Automerger Merge Worker
cde607bfed Merge "Implement the new v4 signing scheme in adb" into rvc-dev am: 742ef23ee9
Change-Id: I1f30ddb248fca223a47a532ad8d02e5dcc6a0c59
2020-03-14 02:35:08 +00:00
TreeHugger Robot
742ef23ee9 Merge "Implement the new v4 signing scheme in adb" into rvc-dev 2020-03-14 02:28:40 +00:00
Alex Buynytskyy
33ac1b05f9 Implement the new v4 signing scheme in adb
To be submitted along with changes in apksigner tool and the framework.
Merged to AOSP after that.

Test: adb install --incremental <apk>

go/apk-v4-signature-format

Bug: b/151241461
Change-Id: I26e187f8e389e31e2759037057b96fc6c9cb1e94
2020-03-13 11:04:17 -07:00
Automerger Merge Worker
1939280381 Merge "adb: support wait-for- with multiple states." am: 4fe694a9c1 am: a13edaac4e
Change-Id: Ia1b1aaf24eb18adf9d3905d6e43ec40367af366a
2020-03-13 15:43:21 +00:00
Elliott Hughes
4fe694a9c1 Merge "adb: support wait-for- with multiple states." 2020-03-13 15:19:34 +00:00
Jiyong Park
a94047be70 Merge "Make libselinux a stub library" into rvc-dev 2020-03-13 05:16:49 +00:00
Jiyong Park
8ce4a3067c Make libselinux a stub library
libselinux is currently being copied to APEXes. This is risky because
the library is not designed to be portable; part of it is tied to the
specific version of the Android that it was developed for.

This change fixes the problem by declaring that the library supports
a stub with the list of C APIs that are included in the stub. Then there
is only one copy of libselinux in /system/lib and other APEXes use the
copy by dynamically linking to it.

Also, adbd no longer statically links to it, because doing so brings
libselinux in it.

Bug: 151053366
Test: m com.android.adbd. It doesn't include libselinux in it.
Test: m com.android.adbd-deps-info. then inspect
out/soong/com.android.adbd-deps-info.txt. The dependency to libselinux
is shown as '(external)'.

Exempt-From-Owner-Approval: cherry-pick from AOSP

Merged-In: If418cbe3abdeacb759d59052e6dca4c2067678dd
(cherry picked from commit 3ffdad0cb5)
Change-Id: If418cbe3abdeacb759d59052e6dca4c2067678dd
2020-03-13 05:16:28 +00:00
Jiyong Park
c2a354be68 Merge "don't include liblog to APEXes" into rvc-dev 2020-03-12 04:10:15 +00:00
Automerger Merge Worker
18ee520e93 Merge "Make libselinux a stub library" am: b407502c98 am: 9281e97450
Change-Id: Ica4f4de8425f84eb6efb1321df1f5f78e3393464
2020-03-12 03:31:03 +00:00
Treehugger Robot
b407502c98 Merge "Make libselinux a stub library" 2020-03-12 02:57:14 +00:00
Automerger Merge Worker
5dc6290c24 Merge "adb: Avoid a couple std::string constructions" am: 2442e64416 am: c2d303231d
Change-Id: I768760f4439b5403025bb3a91a8acedcf6fd4d47
2020-03-12 00:41:33 +00:00
Jiyong Park
3ffdad0cb5 Make libselinux a stub library
libselinux is currently being copied to APEXes. This is risky because
the library is not designed to be portable; part of it is tied to the
specific version of the Android that it was developed for.

This change fixes the problem by declaring that the library supports
a stub with the list of C APIs that are included in the stub. Then there
is only one copy of libselinux in /system/lib and other APEXes use the
copy by dynamically linking to it.

Also, adbd no longer statically links to it, because doing so brings
libselinux in it.

Bug: 151053366
Test: m com.android.adbd. It doesn't include libselinux in it.
Test: m com.android.adbd-deps-info. then inspect
out/soong/com.android.adbd-deps-info.txt. The dependency to libselinux
is shown as '(external)'.

Change-Id: If418cbe3abdeacb759d59052e6dca4c2067678dd
2020-03-12 00:02:18 +00:00
Josh Gao
d1ee5085f3 adbd: make libadbd_services cc_library again.
For currently unknown reasons, sideloading is broken with
libadbd_services as a cc_library_static.

Partial revert of commit a9b62d5452.

Bug: http://b/151056300
Test: xunchang@ tested manually
Change-Id: Iaffad9c476ba0adcffc5db512ba4a7ee0fb5cb22
(cherry picked from commit 7f8a37c8c7)
2020-03-11 23:18:41 +00:00