Commit graph

3318 commits

Author SHA1 Message Date
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
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
Treehugger Robot
070c030289 Merge "adb: fix infinite loop when attempting to push to //foo." 2019-09-25 19:59:51 +00:00
Josh Gao
06e7cb5af0 adbd: allow port configuration on host.
Test: manual
Change-Id: I68cbd9bdb253a68463cc65e63a764ad4fa410c1c
2019-09-26 03:23:05 +08:00
Josh Gao
76b64ba826 adb: fix infinite loop when attempting to push to //foo.
dirname (on glibc, at least) preserves multiple leading slashes, and we
were looping until path != "/", which would lead to an infinite loop
when attempting to push to a path like //data/local/tmp.

Bug: http://b/141311284
Test: python -m unittest test_device.FileOperationsTest.test_push_multiple_slash_root
Change-Id: I182b3e89ef52579c716fdb525e9215f1fe822477
2019-09-26 01:56:58 +08:00
Dan Shi
03ba5b9dfb Merge "Add require_root to adbd_test and libpackagelistparser_test" 2019-09-24 18:30:44 +00:00
Dan Shi
d1360f4412 Add require_root to adbd_test and libpackagelistparser_test
Bug: 141272654
Test: atest
Change-Id: I14e0d3283cba79a2a4e36e1a1274d6921be5b629
2019-09-24 09:13:32 -07:00
Colin Cross
f117f34aed Use libcrypto_static instead of libcrypto
Replace libcrypto with libcrypto_static, which can be protected through
visibility to ensure only modules that don't affect FIPS certification
can use it.

Bug: 141248879
Test: m checkbuild
Change-Id: I5f0b9acfb57f68570f6f58f2395f2bb1bc015365
2019-09-18 11:04:35 -07:00
Mark Salyzyn
6f908cefe7 adb: fix adb remount -R
A regression from commit 8c2198c809
("adb: use shell for remount to forward return codes.") where the
optional argv[1] got missed for the remount command.  This change
hands off _all_ the arguments if to a shell and activates some of
the extra features in the remount command.

$ adb remount --help
remount [-h] [-R] [-T fstab_file] [partition]...
	-h --help	this help
	-R --reboot	disable verity & reboot to facilitate remount
	-T --fstab	custom fstab file location
	partition	specific partition(s) (empty does all)

Remount specified partition(s) read-write, by name or mount point.
-R notwithstanding, verity must be disabled on partition(s).
$

SideEffects: adb remount [-h] [-R] [-T fstab_file] [partition]...
Test: adb-remount-test.sh
Bug: 138577868
Bug: 139283818
Bug: 139226412
Change-Id: I8223d4000ab20857e9b634e4d4a326eed530d7be
2019-09-18 09:40:50 -07:00
Josh Gao
1025b228ba adb: fragment host linux USB writes when needed.
We've seen USB writes failing due to inability to allocate contiguous
chunks of memory in the kernel on devices, but it looks like the same
problem can occur on the host, as well. It's a mild performance
regression (90->80 MB/s on a blueline) to split the writes always, so
attempt the full write first, and fall back to splitting it up if that
fails with ENOMEM. Once we switch over the the asynchronous transport
API, we'll be able to submit multiple writes cheaply, like on devices,
so we won't need to retry at that point.

Bug: http://b/140985544
Test: test_device.py
Change-Id: I1517c348375b829dfff6796c4e9d394802b02d5b
2019-09-17 14:48:16 +08:00
Alex Buynytskyy
7ea92d8232 Using the correct feature name for abb_exec.
Test: atest adb_test
Test: atest fastdeploy_test

Change-Id: Ib917ed8293d0f51339cade032c768a4058ba578e
2019-09-16 10:36:52 -07:00
Treehugger Robot
fd010252c2 Merge "adb: fix old host transport selection." 2019-09-12 19:58:20 +00:00
Josh Gao
727b07b260 adb: fix old host transport selection.
We regressed handling of the old host transport selection syntax, which
broke users that reimplement adb themselves (e.g. Studio via ddmlib).

Bug: https://issuetracker.google.com/140369526
Test: adb raw "host-serial:822X0028S:forward:tcp:42929;localabstract:/com.example.ndktest-0/platform-1568299082100.sock"
Test: ./test_device.py
Change-Id: Iaaec8fde952316fe9bf2a6f6c6c4a3bc9f74bf72
2019-09-13 00:26:37 +08:00
Colin Cross
537e4af235 Merge changes from topic "protobuf-3.9.1"
* changes:
  Use installed paths of vndk libraries for ld.config.txt
  Adapt to google::protobuf::int64 type change
2019-09-11 18:00:15 +00:00
Josh Gao
3b8cd67dff Add stub code to read MS OS 2.0 descriptors.
Linux doesn't seem to actually support emitting them, so we can't check
that they're actually there, but commit the code to read them so that
if and when Linux gets support, it's easier to check.

This also adds some error checking for ill-formed binary object store
entries.

Test: check_ms_os_desc
Change-Id: I4baf6a16f0f96acbec468b843db65d4ab3a589fe
2019-09-06 14:45:11 -07:00
Josh Gao
27512c9e49 adb: add host tool to check for WinUSB descriptor.
Bug: http://b/68993980
Test: manual
Change-Id: I97395c9738a671dd136c6cf66f88fdb769ec7227
2019-09-05 15:56:54 -07:00
Colin Cross
cfcc0b0337 Adapt to google::protobuf::int64 type change
Protobuf 3.9.1 redefines google::protobuf::int64 from long long to
int64_t, which is sometimes long and sometimes long long.  Use PRId64
to print it.

Bug: 117607748
Test: m checkbuild
Change-Id: I6699cfdb0f0424aa3e1c98b59d941beb9f133055
Merged-In: I6699cfdb0f0424aa3e1c98b59d941beb9f133055
2019-09-05 14:46:16 -07:00
Josh Gao
1f32a20c5c Merge changes Iacf0093a,I40be3504
am: c2f53906e8

Change-Id: I21f8c74909b218a2d35d149305d9858722911cd1
2019-08-20 13:40:55 -07:00
Josh Gao
c2f53906e8 Merge changes Iacf0093a,I40be3504
* changes:
  adb: fdevent: add fdevent_context_epoll.
  adb: extract soon-to-be-common code.
2019-08-20 20:00:34 +00:00
Josh Gao
ada40cd6b8 Merge "adb: fix mac build"
am: ef356fa5bd

Change-Id: Ia7324a9137ce296f2090c82993b1c4726bb25553
2019-08-19 16:54:43 -07:00
Adrian Roos
68c14d10b8 adb: fix mac build
Ensure that off64_t is defined when building adb for mac

Fixes: 139646013
Test: make # On mac
Change-Id: I32b68738d71c8a63a35c22434092933dcabac1ce
(cherry picked from commit 2167b9082d)
2019-08-19 10:51:00 -07:00
Dan Albert
8c2b3a8cde 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
(cherry-picked from internal commit ba4684c2b2)
2019-08-15 17:27:49 -07:00
Josh Gao
b43ad44f4c adb: fdevent: add fdevent_context_epoll.
Implement an epoll-backed fdevent_context, that reduces overhead when
we're polling many file descriptors. FdeventTest.smoke goes from ~5.2s
to ~3.3s when run on the host (after this patch's modification to change
it from chaining 10 file descriptors together to 512).

Test: adb_test on host
Test: adbd_test on blueline
Test: test_adb.py
Test: test_device.py
Change-Id: Iacf0093aa7bebea31e447c2cb012af72d8c3297e
2019-08-14 13:56:08 -07:00
Josh Gao
e22cb9f306 adb: extract soon-to-be-common code.
As a side effect, delete FDE_ACTIVE, which was always set on every
fdevent, and FDE_PENDING, which was an internal implementation detail.

This patch removes spin detection, which will be reimplemented
separately later.

Test: adb_test on host
Test: adbd_test on blueline
Change-Id: I40be3504ce03c4fae5e071fa018542a051b7511d
2019-08-14 13:56:08 -07:00
Yurii Zubrytskyi
71d621dd36 Merge "[adb] Use STL for ParseUInt() implementation"
am: 61bffa5fc0

Change-Id: Iafbacab5e2ddf180683d501cd702ad39017104f9
2019-08-14 01:41:47 -07:00
Treehugger Robot
61bffa5fc0 Merge "[adb] Use STL for ParseUInt() implementation" 2019-08-14 06:32:44 +00:00
Josh Gao
86ba5c9433 Merge "adb: use shell for remount to forward return codes."
am: edf8040152

Change-Id: I19682ef013b3d41a1085fe8e4ed632544d29d148
2019-08-13 18:38:49 -07:00
Josh Gao
edf8040152 Merge "adb: use shell for remount to forward return codes." 2019-08-14 00:26:04 +00:00
Songchun Fan
a791d59547 Merge "[adb] Add a getter for native Win32 file handle"
am: 93619e373a

Change-Id: I4e9d8ca2964bfbc9e290ff13f46e03e93f4e4447
2019-08-13 13:22:54 -07:00