Commit graph

125 commits

Author SHA1 Message Date
Joshua Duong
7be8519cdb Add mDNS service instance name parser.
This will be used for parsing user-provided names to 'adb connect' and
'adb pair' in order to check for matches in the mdns service registry.

Bug: 152886765

Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
--gtest_filter=mdns_utils*

Change-Id: Ifd74b4394212853c1c193a2ea64937f6a6a0ff24
2020-05-07 10:25:15 -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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Jiyong Park
95b6f45b0e don't include liblog to APEXes
liblog is a platform library that provides stable C API. There is no
need to include the library, especialy by statically linking to it, in
any APEX. It not only wastes the storage/ram, but also is incorrect
because the socket interface to logd which is implemented in liblog is
not guaranteed to be stable.

Fixing this issue by converting static_libs: ["liblog"] into
shared_libs: ["liblog"], in which case the dependency to the library
is satisfied via the stub variant of the library.

As a result, we could restrict the availablity of the library to
the platform and the runtime APEX.

Exempt-From-Owner-Approval: already approved when this was in internal
master (ag/10572699)

Bug: http://b/151051671
Bug: http://b/150827719
Test: m
Change-Id: I5aab863cb12b8767b6979255c247000a59355b0e
2020-03-11 09:20:08 +00:00
Tianjie Xu
0ac447ab95 Merge "adbd: make libadbd_services cc_library again." 2020-03-10 18:43:30 +00:00
Josh Gao
7f8a37c8c7 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
2020-03-09 15:20:55 -07:00
Shukang Zhou
f4ffae1055 "track-app" service showing debuggable/profileable apps
Add a "track-app" service in adbd. For every debuggable or
profileable-from-shell process, ART sends related info to
adbd and adbd surfaces the info through the "track-app"
service.

The output format of "track-app" is a line summarizing
the number of reported processes, followed by a protobuf
message in human readable form. For example,

Process count: 2
process {
  pid: 3307
  profileable: true
  architecture: "arm64"
}
process {
  pid: 3341
  debuggable: true
  profileable: true
  architecture: "arm64"
}

Bug: 149050485
Test: manually unplugged/replugged, "adb track-app",
      "adb track-jdwp"
Change-Id: Id1f1a920e1afc148c7e4d2add790baab796178e1
2020-03-06 13:56:27 -08:00
Joshua Duong
ad9d034e7d Merge "Remove pairing_auth, pairing_connection from recovery." 2020-02-29 00:47:44 +00:00
Josh Gao
52d0b67f19 adbd: add runtime-configurable logging.
Add some requested logging options that can be turned on at runtime
without having to restart adbd.

Bug: http://b/141959374
Test: manual
Change-Id: Ib97acc6d199e0b91238a6758e18b7cb75f8688d9
2020-02-28 12:58:42 -08:00
Joshua Duong
0f53d1794a Remove pairing_auth, pairing_connection from recovery.
Also remove statically linking libc++, because these libraries are not
exported native shared libraries.

We are slightly over the 12MB limit for ramdisk recovery size, so let's
remove the adb pairing libraries, since they won't be used in recovery
mode.

These are only used in normal boot mode, and currently, only by adb
client. The pairing server is used by system server.

Bug: 150317254

Test: Check size of ramdisk-recovery.img in walleye, walleye-hwasam
build to be under 12MB. Also verify installed-files-recovery.txt no
longer contains libadb_pairing*.
Also put phone into recovery mode, check system/lib64 for no
libadb_pairing*.

Change-Id: Ida7c4fdc9dda2b09091b853feac8df8f125e4274
Merged-In: Ida7c4fdc9dda2b09091b853feac8df8f125e4274
(cherry picked from commit afc2cf0dec)
Exempt-From-Owner-Approval: cherry-pick
2020-02-28 20:45:43 +00:00
Josh Gao
6d949e89a4 adbd: fix build breakage.
This broke because two CLs touching the Android.bp file both
independently passed presubmit, but failed when combined.

Clean up a misindentation while we're at it.

Bug: http://b/150032367
Test: mma in system/core/adb
Change-Id: I091ef9dec806c767ffb21a5fd73b2bb37ab29ff9
2020-02-22 00:43:55 +00:00
Josh Gao
744ba42d2d Merge "adbd: remove static dependency on libcutils." 2020-02-22 00:03:21 +00:00
Joshua Duong
d85f5c0130 [adbwifi] Add adbwifi_libs, TLS connection, and MDNS implementation.
Bug: 111434128, 119493510, 119494503

Test: Enable wireless debugging in Settings UI, click "pair with pairing code"
to generate pairing code.
On client, 'adb pair <ip_address>', enter pairing code at prompt and hit
enter. Pairing should complete.
'adb logcat'.
Change-Id: I86527bd3fc52e30a8e08ec5843dc3e100abf91fa
Exempt-From-Owner-Approval: approved already
2020-02-21 21:06:40 +00:00
Josh Gao
a9b62d5452 adbd: remove static dependency on libcutils.
We were previously statically linking libcutils into adbd for several
different reasons, which were addressed as follows:

  socket functions: extracted to a statically linked libcutils_network
  fs_config: wrapped with a shared library on /system
  ATRACE: deleted the single use in adbd

Test: treehugger
Change-Id: I821fa174cfcbfa8e29a4be10de4016b817adbaf8
2020-02-19 17:44:38 -08:00
Alex Buynytskyy
96ff54bf34 Incremental installations in adb, client/host side.
Test: adb install --incremental <apk>

Change-Id: I74e3eaf9718a16272bc533bc8298dfcf81120caa
2020-02-19 08:01:06 -08:00
Joshua Duong
ef28ca4cdc Move adb RSA utilities into its own library.
Since both the client and daemon will now be generating keys.

BUG: b/111434128

Test: atest adb_crypto_test
Change-Id: I6fac562ae5629ab30b6639fbd88d822dae6e96bd
2020-02-11 20:49:20 -08:00
Josh Gao
93dee964d4 adb: switch tests to python3.
Test: treehugger
Change-Id: Ia1f6a659e23f5d9e63c9b106c60d56b5b954b19c
2020-02-07 15:59:49 -08:00
Josh Gao
955601beb4 Merge "Add libadbd_auth to adbd's required list." 2020-02-04 10:16:41 +00:00
Josh Gao
9952258416 Add libadbd_auth to adbd's required list.
It seems like we might not be tracking dependencies properly on
devices with flattened APEXes? Add libadbd_auth to adbd's required
list to work around this for now.

Bug: http://b/148812347
Test: `ls $ANDROID_PRODUCT_OUT/system/lib/libadbd_auth.so` before and after when building a go device
Change-Id: If60abeb00797e37bf6a5a037249a21877e0b3d26
2020-02-04 07:17:19 +00:00
Josh Gao
d0854b3397 Merge "Add adbd_test to mts." 2020-02-03 23:30:12 +00:00
Josh Gao
d5bad7c021 Merge "adbd: actually dynamically link against libadbd_auth." 2020-02-03 20:15:20 +00:00
Dan Willemsen
a536b4280e The darwin linker does not support version scripts
Fixes: 148774297
Test: m nothing   on a mac
Change-Id: I4000b2076fe2dde3776b112b506ee3266a529fc6
2020-02-03 10:02:41 -08:00
Josh Gao
24b01d2de8 libadbconnection_client: apply version script to library.
Previously, we were using the version script for only the stubs in the
library, which led to symbols from libc++_static leaking out.

Bug: http://b/148504737
Test: booted a user build
Change-Id: Ie22856f7d16cc837eb961f70195d49898bf7fb49
2020-01-31 16:51:54 -08:00
Josh Gao
7f72945eff adbd: actually dynamically link against libadbd_auth.
libadbd_auth was accidentally linked as a static library, which defeats
the entire purpose.

Test: treehugger
Test: readelf -d $ANDROID_PRODUCT_OUT/apex/com.android.adbd/bin/adbd
Change-Id: Id5b66745946a8b92e368ee5f3965275ff03e056d
2020-01-30 16:18:43 -08:00
Josh Gao
7e015871db Add adbd_test to mts.
Bug: http://b/137798163
Test: mts-tradefed run mts-adbd
Change-Id: I875f224bbcd7b1f81365fffdd8de8d2df4e87c84
2020-01-30 23:53:20 +00:00
Josh Gao
bb7fc92ee1 Move jdwp connection abstraction from ART apex to adbd apex.
Test: ./art/tools/run-jdwp-tests.sh
Change-Id: I3114b8403f3548700a45df5d7bb72ebe727adec1
2020-01-24 12:31:59 -08:00
Josh Gao
7da5d8a977 Build test_com.android.adbd.apex.
Build a test apex with an INT_MAX version code for the purposes of
update/rollback testing.

Test: atest adbd_e2e_tests # in internal master
Change-Id: I0e616db03dcbc940af2741dfca5b4c5f50a5a654
2020-01-23 11:55:03 -08:00
Tom Cherry
992163021d Require liblog for libbase in all configurations
liblog will soon be required for all of libbase's logging.  This
change proactively requires liblog in all configurations instead of
just Android.

Bug: 119867234
Test: build
Change-Id: I696162fbebc78d4ef23c6032412101ac51d397a4
2020-01-09 10:43:26 -08:00
Yurii Zubrytskyi
5dda7f6cea [adb] Optimize adbd's usb reading
Try to not allocate as many blocks on the heap, and reuse
memory instead of copying it

Get rid of unique_ptr and shared_ptr where possible, move
the Block objects themselves

Overall this reduces the time spent in memcpy() from 30% to
15% of the whole 'adb push' command, and gets rid of about 5%
of the time spent in the malloc/free calls

Test: builds
Change-Id: I8995115274b6f08a4df13c58183c928ef384a767
2019-11-28 18:24:01 -08:00
Josh Gao
594f70ffb8 Move adbd to an apex.
Test: adb shell "su 0 readlink /proc/\`pidof adbd\`/exe"
Change-Id: I84dfe4d1b28b619f98c03a2c8eeef2c783d30af2
2019-11-04 15:52:16 -08:00
Josh Gao
275232667d adbd: use libadbd_auth for authentication.
Bug: http://b/137798163
Test: for i in `seq 1 100000`; do echo $i; adb wait-for-device shell "su 0 stop; su 0 start; sleep 10"; adb disconnect; done
Change-Id: Ie481e79a48c4aabf18ef797317ba18f207808c63
2019-11-04 15:46:20 -08:00
Josh Gao
2c356bb91e adb: replace reboot service with exec of /system/bin/reboot.
Test: adb reboot
Test: adb reboot fastboot
Change-Id: Ia4146dde7ef3ae00a782dbe68aff166d63eabdb9
2019-10-23 14:33:36 -07:00
Josh Gao
f61f41494e Move enable-verity/disable-verity out of adb to a helper binary.
Test: adb enable-verity
Test: adb disable-verity
Test: adb shell enable-verity
Test: adb shell disable-verity
Test: fs_mgr/tests/adb-remount-test.sh
Change-Id: I0f21a6678b332cc9166d912aa38952d50d924566
2019-10-23 14:33:36 -07:00
Josh Gao
7b7ee191dc Use adbd_system_binaries to track adbd's dependencies.
required doesn't propagate from apexes, so we need a separate phony
target to track adbd's dependenecies.

Test: m
Change-Id: I4c97047dbd1c2f9b394d864aed229798f09fc9b1
2019-10-23 14:33:36 -07:00