Commit graph

3347 commits

Author SHA1 Message Date
Tom Cherry
f633b62b63 Merge "Require liblog for libbase in all configurations" 2020-01-15 23:20:07 +00:00
Kevin Brodsky
0b633d8800 Remove leftover support for target-as-host
Support for target-as-host was removed by 4626b71057 ("Fix win_sdk
build."), so ADB_HOST_ON_TARGET is never defined.

Test: build
Change-Id: I5ab27e68208677266e2e4272bc2bae7d6a097c5d
2020-01-13 14:48:49 +00:00
Treehugger Robot
a6379cd2df Merge "Add /system/lib to the permitted paths for ns of APEXes" 2020-01-13 08:19:23 +00: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
Treehugger Robot
f5a329f1a4 Merge "adb: fix adb connect help typo." 2020-01-09 04:34:27 +00:00
Treehugger Robot
97186600b5 Merge "adb: avoid consuming input in adb remount." 2020-01-08 23:52:40 +00:00
Josh Gao
9e75634082 adb: avoid consuming input in adb remount.
Bug: https://issuetracker.google.com/146163747
Test: dd if=/dev/zero bs=1024 count=1 | (adb remount; wc)
Change-Id: I700090cd0bbae2d76569008f3c1a116336951c0a
2020-01-08 12:43:34 -08:00
Elliott Hughes
65474fd78c adb: fix adb connect help typo.
Bug: http://b/130380645
Test: adb connect
Change-Id: I04205ff0120bcfd865dc5fa95846694d0ff6de80
2020-01-08 10:02:43 -08:00
Jiyong Park
016059dd46 Add /system/lib to the permitted paths for ns of APEXes
With b/144533348, there will be symlinks from libs in APEXes to the libs
in the system partition. This is to reduce the size of APEXes when the
APEX is bundled with the platform.

Adding the /system/lib to the permitted paths so that the realpaths of
the symlinks are allowed for the namespaces.

Note that this however does not open all libs in the system partition to
the APEX namespaces, because searching of the libs are NOT done in
/system/lib, but in /apex/<module>/lib directory.

Bug: 144533348
Test: m
Change-Id: I4bb1d6cb5dbf647ae669f49aa5ccb178f5488b5e
2020-01-07 19:53:38 +09:00
Kiyoung Kim
0513f0e266 Update ld.config.txt for adbd apex
ld.config.txt for ADBD APEX works properly, but it can be reduced into
simpler way. This change updates ADBD APEX linker configuration which
reduces complexity and limit library usage from system partition.

Test: m -j && confirmed adbd works from cuttlefish
Change-Id: Ifcf1323082148aec4b6417c0ba7df0d9fe8ffeb0
2020-01-03 13:37:29 +09:00
Josh Gao
27fa358d41 Merge "adb: use poll instead of select in shell_service." 2019-12-19 20:22:13 +00:00
Treehugger Robot
1cdcc5f7e8 Merge "adb: fix use after free of atransport." 2019-12-18 22:39:48 +00:00
Josh Gao
63da8e6272 adb: use poll instead of select in shell_service.
Bug: http://b/141955761
Test: test_device.py
Test: adbd_test
Change-Id: I8976304a1011e81e85f8d90d95d36ecd82834f5f
2019-12-18 14:02:57 -08:00
Elliott Hughes
264a37d12f Merge "Fix SEGV in libziparchive with malformed zip file." 2019-12-18 16:14:54 +00:00
Treehugger Robot
90e9217aca Merge "Enable "localfilesystem" UNIX domain socket for ADB." 2019-12-18 05:34:30 +00:00
Elliott Hughes
fba2a1a1ec Fix SEGV in libziparchive with malformed zip file.
d77c99ebc3 changed MappedFile to return a
bogus zero-length mapping on failure rather than nullptr. None of the
calling code was changed, though, and it seems like doing so would be a
bad idea. Revert that part of the change.

Add missing tests, and tidy up some of the logging. Also remove
single-use or obfuscatory constants from the tests.

The new "empty.zip" was created by using zip(1) to create a zip file
with one entry, then using `zip -d` to remove it.

The new "zero-size-cd.zip" was created by using zip(1) to create a zip
file containing a single empty file, and then hex editing the two byte
"size of the central directory" field in the "end of central directory
record" structure at the end of the file. (This is equivalent to, but
much smaller than, the example zip file provided by the bug reporter.)

Bug: http://b/145925341
Test: treehugger
Change-Id: Iff64673bce7dae886ccbc9dd6c2bbe18de19f9d2
2019-12-17 08:39:09 -08:00
Elliott Hughes
dfe6c84709 adb: improve help for -t/-tt.
Test: adb help
Change-Id: Ic75bf184dfc51e57b422666d85e3b7a5139b3853
2019-12-13 16:43:10 -08:00
Josh Gao
607fd5424a adb: fix use after free of atransport.
libadbd_auth might report authentication success for a transport that's
already been destroyed. Fix this by storing a weak pointer to the
atransport that gets cleared upon destruction instead of a raw pointer.

Bug: http://b/144704376
Test: ./test_adb.py
Test: ./test_device.py
Change-Id: Idffe027381e6b2e37f06aa0166e97cafc98eaf3b
2019-12-13 13:28:21 -08:00
Jack Pham
b310da608b adbd: Update DeviceInterfaceGUID for WinUSB
The MS OS extended property descriptor is used to convey additional
information to Windows hosts, in this case the DeviceInterfaceGUID
which allows the inbox WinUSB driver to get automatically installed.

However, the ADB windows client looks for USB devices by enumerating
devices with a specific GUID {F72FE0D4-CBCB-407D-8814-9ED673D0DD6B},
and as a result fails to find the device since it was installed with
a different DeviceInterfaceGUID. Update the OS descriptor to pass
back the same GUID the client already uses.

Change-Id: If664cdd9be821c502e8c2048ff79e79e311936f5
2019-12-12 00:13:56 -08:00
Josh Gao
f4ddee0f32 Merge changes I6ff85723,Ia7d743d5
* changes:
  adb: add ls_v2.
  adb: rename syncmsg::*::time to mtime.
2019-12-12 01:39:20 +00:00
Treehugger Robot
d692530a71 Merge "adb: remove atransport ref counting." 2019-12-12 00:47:28 +00:00
Josh Gao
9a8366b3d9 adb: remove atransport ref counting.
The reference count is always 0 or 1.

Test: ./test_adb.py
Change-Id: I669f98f4996f4e41ac037f1add9c47819d4003d4
2019-12-11 13:40:41 -08:00
Daniel Colascione
3ec7be7a84 Revert "Revert "Support socket activation of adb server""
Test: actually build both device and client adb this time

This reverts commit c77904e3c5.

Change-Id: I8c2b8f24884ff36ff2460dab2500bad777100dfd
2019-12-11 08:20:20 +00:00
Jason Jeremy Iman
8bde191202 Enable "localfilesystem" UNIX domain socket for ADB.
This patch introduce "service.adb.listen_addrs", a new
string type property, while keeping the old properties.
The new property added in this patch is used to listen
on UNIX domain socket "localfilesystem".

"service.adb.listen_addrs" can be used to listen on
multiple addresses, such as tcp:5555 and tcp:5556.
It is separated by ',' (comma) character.

In the process of introducing the new socket type, the
method tcp_connect is removed and combined into
socket_spec_connect.

Without specifying using the new property, adb will
try to listen on both tcp and vsock (following the
previous implementation).

Some examples of the new property value are:
  - "tcp:5555"
  - "vsock:5555"
  - "localfilesystem:/tmp/test"
  - "tcp:5555,vsock:5555"

Bug: 133378083
Test: On master-arc-dev:
        adb root;
        setprop service.adb.listen_addrs localfilesystem:
	    <path_to_socket>;
        adb connect localfilesystem:<path_to_socket>;
        adb -s localfilesystem:<path_to_socket> shell;
	    inside Chrome OS.
Test: On aosp_bluefin:
        setprop service.adb.listen_addr tcp:5555;
        adb connect <IP>:5555; adb shell;
Test: On aosp_bluefin:
        setprop service.adb.tcp.port 5555;
        adb connect <IP>:5555; adb shell;
Test: On aosp_bluefin:
        setprop service.adb.listen_addrs tcp:5555,tcp:6666;
        adb connect <IP>:5555; adb shell;
        adb connect <IP>:6666; adb shell;
Test: On aosp_bluefin:
        ./adb_test;
Test: On cuttlefish:
        launch_cvd;
        adb -s 127.0.0.1:6520 shell;
Test: Ran host tests:
        ./adb_test;
        ./adb_integration_test_adb;
        ./adb_integration_test_device;

Change-Id: I8289bf0ab3305cf23ce5695ffba46845d58ef6bb
2019-12-04 10:05:05 +09: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
80a734f146 Merge "Allow the adb server to bind on ::1" 2019-11-21 21:51:07 +00:00
Tianjie Xu
b6d7ea15b7 Handle the reboot in the recovery user mode
We have switched to "/system/bin/reboot" to perform the reboot. But
accessing the shell for user build under recovery is not allowed by
sepolicy. So adding a special routine to handle this reboot case.

Bug: 141247819
Test: run `adb reboot` in user mode recovery
Change-Id: Ia37438e52c67fd2bd54e923a0fea5817a1455a08
2019-11-13 14:23:09 -08:00
Elliott Hughes
ef6d913027 Merge "fastdeploy: fix tests." 2019-11-08 21:11:45 +00:00
Elliott Hughes
74f0fc6b18 fastdeploy: fix tests.
Actually log results of adb commands, so we can see why this fails.

Fix the asan-detected use of a value from a reused part of the stack.

Test: atest FastDeployTest on Linux (with an asan adb)
Change-Id: I4d2bbae62a301e16065d604a2c9918077489cafb
2019-11-08 15:39:50 +00:00
Callum Ryan
8539cb3f75 Allow the adb server to bind on ::1
Currently the adb server can only bind on 127.0.0.1 or * if -a is
provided. This diff adds the ability for adb to bind on ::1 as
well for use cases where you might want to force adb to be IPv6
only.

To bind the adb server on ::1
```
$ ./adb -L tcp:[::1]:1234 server
$ lsof -nPi :1234
COMMAND ... NODE NAME
adb     ...  TCP [::1]:1234 (LISTEN)
```
The original behaviour is also retained, so this would only affect
users explicitly specifying ::1 in the socket spec
```
$ export ANDROID_ADB_SERVER_PORT=1234
$ ./adb server
$ lsof -nPi :1234
COMMAND ... NODE NAME
adb     ...  TCP 127.0.0.1:1234 (LISTEN)
```

Note: I've only implemented this behaviour for posix base systems,
due to my limited understanding of networking on windows. If
needed I can do some research to implement it there as well, but
there is currently no IPv6 support at all on the windows side.

Test: New unit test and the commands in the summary

Change-Id: I23e4531e8dfda4de9348124ad7491d728aecdbf7
2019-11-07 08:32:01 -08:00
Daniel Colascione
2aabeed1fd Merge "Properly finish daemon init when initial USB scan complete" 2019-11-05 23:44:25 +00:00
Josh Gao
e24a4b37b4 Merge changes from topic "adbd_apex"
* changes:
  Move adbd to an apex.
  adbd: use libadbd_auth for authentication.
2019-11-05 23:36:39 +00:00
Tianjie Xu
a933b43c02 Grant adb auth under recovery for unlocked & userdebug devices
During automatic tests, we sometimes want to reboot the device out of
the rescue party remotely. And per http://go/recovery-adb-access, we
need to grant the adb authorization to enable the adb access. The auth
are only granted for userdebug devices and those with an unlocked
bootloader. Since the user can always flash a custom recovery image if
the bootloader is unlocked.

This cl ignores the ro.adb.secure property under recovery. The other
option is to default this property to 0 when building the boot/recovery
image.

Bug: 141247819
Test: unlock bootloader, run adb under recovery in user build
Change-Id: I424cfed5bf51a1e31d8687256ae4c6eaaa5e6249
2019-11-04 16:12:00 -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
Daniel Colascione
3aef5c82f7 Properly finish daemon init when initial USB scan complete
Call adb_notify_device_scan_complete when we finish enumerating USB
devices. The original intent of the code appears to have been to have
adb_wait_for_device_initialization return as soon as we've finished
looking around at the system USB environment on daemon startup, but at
some point, we forgot to actually notify the init thread that we
finished scanning all the USB devices, forcing the wait on init_cv to
time out after three seconds on every daemon initialization.

After this change, the daemon starts in a few milliseconds on my Linux
machine

Test: killall adb && sleep 1 && time adb server && adb shell ls
Change-Id: I0bc1da7a597d2077dd2b591560d03798b05905b7
2019-11-04 11:43:20 -08:00
Josh Gao
18bbb2d821 Merge changes from topics "adbd_reboot", "adbd_verity"
* changes:
  adb: replace reboot service with exec of /system/bin/reboot.
  Move enable-verity/disable-verity out of adb to a helper binary.
  Use adbd_system_binaries to track adbd's dependencies.
2019-10-24 20:29:25 +00: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
Josh Gao
c9e09e69b9 deployagent: set sdk version.
Not specifying a platform version in a java binary will result in code
generation tools being built to create framework.jar, which currently
fails when building with BUILD_HOST_static=1.

Specify an SDK version to avoid this.

Bug: http://b/142536936
Test: m -j adb BUILD_HOST_static=1
Change-Id: Ifb9556c7c6cc43417c3f56137edee21f145f8b17
2019-10-17 16:20:26 -07:00
Josh Gao
baea773324 Merge changes from topic "apex_remount"
* changes:
  adbd: replace remount_service with an exec of /system/bin/remount.
  Move remount to PRODUCT_PACKAGES_DEBUG.
2019-10-17 19:14:26 +00:00
Josh Gao
8d1d87e460 adbd: replace remount_service with an exec of /system/bin/remount.
Test: fs_mgr/tests/adb-remount-test.sh
Test: treehugger
Change-Id: Idd581c3927fd8a8bbdf70e90e8f928b7e98e032a
2019-10-16 16:29:10 -07:00
Treehugger Robot
2fd9d735ea Merge "adbd: allow port configuration on host." 2019-10-16 23:22:44 +00:00
Josh Gao
6ce44041b5 Move remount to PRODUCT_PACKAGES_DEBUG.
required seems to conflict with apex with the following error:

    build/make/core/main.mk:1338: warning: build/make/target/product/aosp_x86_64.mk produces files inside build/make/target/product/mainline_system.mks artifact path requirement.

Test: treehugger
Change-Id: If1fbb9c4a4be340750ee6daea7aa4621177d8d56
2019-10-10 13:12:21 -07:00
Elliott Hughes
7fb1407125 adb: log more detail on failure to read keys.
Before we just got "Failed to read key". After:

  adb E 10-07 08:20:14 258249 258249 auth.cpp:176] Failed to read key \
    from '/usr/local/google/home/enh/.android/adbkey'
  94390117965240:error:0900006e:PEM routines:OPENSSL_internal:NO_START_LINE:\
    external/boringssl/src/crypto/pem/pem_lib.c:622:Expecting: ANY PRIVATE KEY

Also fix the misleading "Failed to generate" message from adb_auth_init.

Bug: http://b/141715453
Test: manually corrupted key; see above
Change-Id: I6732ee6b683c8548d596d7c22eeddab8ce9a3cea
2019-10-07 08:25:42 -07:00
Alex Buynytskyy
665f3ff5a7 FastDeploy refactor: 2+GB APK support, optimizations, tests.
- removed 2GB apk size cap,
- removed zip archive parsing on device (1.1M->236K agent size reduction),
- optimized matching entries search,
- added more robust matching entries search based on hash of CDr entry,
- reduced patch size by reusing Local File Header of matched entries,
- removed extra manifest parsing and extra agent calls,
- added device-side tests for agent,
- fix for Windows patch creation.

Test: atest adb_test fastdeploy_test FastDeployTests

Total time for 0-size patch reduction for 1.7G apk: 1m1.778s->0m36.234s.

Change-Id: I66d2cef1adf5b2be3325e355a7e72e9c99992369
2019-10-02 13:25:03 -07:00
Josh Gao
ea3f43ccf2 adb: disable failing test.
Bug: http://b/141943968
Bug: http://b/141923622
Test: python -m unittest test_device.FileOperationsTest
Change-Id: Ie384c71c3d6875db74982a398fb66f035ce9f408
2019-10-01 14:15:31 -07:00
Colin Cross
2a62d42704 Merge "Use libcrypto_static instead of libcrypto" 2019-09-26 14:32:33 +00:00
Josh Gao
3a22e8cf73 Merge "adb: fragment host linux USB writes when needed." 2019-09-25 21:20:54 +00:00