Commit graph

171 commits

Author SHA1 Message Date
Cody Schuffelen
af0e220fb1 Combine tcp_connect and socket_spec_connect.
This will make it easier to add new types of transports by combining the
logic the adb server and adb daemon use to connect to things.

Bug:121166534
Test: adb connect against a cuttlefish instance over the shm proxy.
Change-Id: Ic7fc848c60a85eef968c3735838c87cb7fdaf38b
2019-01-17 15:58:41 -08:00
Dario Freni
bc54c3670f Multi-package support for APEX.
This CL introduces two changes to adb install-multi-package:
- If there is at least one apex package in the list of packages, use the
  --staged parameter for both the parent and the child sessions
- When the package being sent is an apex, use the --apex parameter

Bug: 118865310
Test: Printed out the resulting commands and verified that both
non-staged and staged workflow are accepted by PackageManager. Tried
scheduling install sessions for a mix of APK/APEX, only APKs, only APEX.
Change-Id: I8d1a6a7c5408fb95c10d79e38ddaf115a46f5d8b
2019-01-16 21:59:34 +00:00
Treehugger Robot
6410fd2434 Merge "adb: switch install to unique_fd." 2019-01-16 05:45:26 +00:00
Treehugger Robot
e5f61a9bcd Merge "Admit that there's more adb install help available." 2019-01-12 06:21:31 +00:00
Josh Gao
61f872f2a8 adb: switch install to unique_fd.
Test: mma
Change-Id: I9474c003e0eb4a8cb183090a2e525d78932d3bea
2019-01-11 13:57:36 -08:00
Elliott Hughes
0d4bf80968 Admit that there's more adb install help available.
Test: adb --help
Change-Id: I1e4d4250ef8bc55cfa660f87ebdbd7d664509266
2019-01-11 13:50:05 -08:00
Patrick Baumann
dc58b0a388 Adds atomic install support to adb
This change adds an install-atomic command to adb that is shorthand for
creating an atomic install session and an individual session for each
APK supplied to the command.

Bug: 109941548
Test: run command with multiple APKs, observe atomic install
Change-Id: I2817a1ed2d312925d9c7bd621e6c82670a6275fd
2019-01-11 18:13:36 +00:00
David Anderson
22a8462336 Merge "adbd: Automatically disable verity in adb remount." 2019-01-09 19:48:47 +00:00
Alex Buynytskyy
640407d632 Adding Android Binder Bridge (abb) utility launched from adbd.
Once launched, abb will listen for incoming Binder cli requests.
Executing in-process provides 6x latency improvement (125ms vs 25ms on
PixelXL) for commands like 'package path'

Intended usage by Android Studio for fast deployment and patching of APKs.

Test: manual
BUG: 111621042

Change-Id: Ica84eb2ec9628efa441ecd627b119f3361feaf9f
2019-01-07 15:45:11 +00:00
Josh Gao
5021cfc135 adb: switch usb_linux helper to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: Iccbeb61905852b72fceec1bca498895b38a2e7d4
2018-12-21 01:43:34 -08:00
Josh Gao
0f29cbc750 adb: switch unix_open to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: Ieecc9b1b7f2111f4da45d4bbd1b7703535fe7d4d
2018-12-21 01:43:31 -08:00
David Anderson
a5db1d72cf adbd: Automatically disable verity in adb remount.
Before overlayfs, we supported deduplicated filesystems by undoing
deduplication in recovery. This required an extra reboot cycle, so we
changed "adb remount" to disable verity and boot to recovery in one
command.

After overlayfs, adb remount is still trying to undo deduplication,
which leads to very confusing messages. This patch makes things a bit
clearer. "adb remount" will disable verity, which installs overlayfs.
"adb remount -R" will do the same except automatically reboot.

Bug: N/A
Test: adb remount on dynamic partitions device
Change-Id: Id72f6b9e2297c2f4d5722d5679f6264fe660e631
2018-12-17 13:15:05 -08:00
Treehugger Robot
17d41711c6 Merge "Change --fastdeploy behaviour" 2018-12-17 11:10:18 +00:00
Henry Daitx
ee01c80afe Change --fastdeploy behaviour
--fastdeploy does not require -r anymore, and reverts to a normal install
if the application is not already on the device.

Bug: 120828611

Test: mm -j72
Test: adb install --fastdeploy --force-agent --local-agent /mnt/raid/boat-attack-apk/boat-attack-swappy.apk
Change-Id: Ice2a71493a34ee7d0debabcce6a9aebb0af79e62
2018-12-14 15:25:15 +00:00
Josh Gao
e89a55dd41 adb: make adb raw bidirectional.
Test: adb raw shell:
Change-Id: I973f42c55c71ffd125e58f76d29100a2d5b0c308
2018-12-12 12:54:28 -08:00
Treehugger Robot
bcc2d60826 Merge "Removes ASEC-related install flags" 2018-12-07 18:11:09 +00:00
Patrick Baumann
24439442a8 Removes ASEC-related install flags
Bug: 109941548
Test: install still works
Change-Id: Ibaf87e678217a1ce140b4024d16ceb8d27fadec0
2018-12-07 16:15:31 +00:00
Henry Daitx
f21edf3edd Fix adb not correctly reading return code from DeployAgent
Certain error conditions were getting lost because adb was wrongly
reading DeployAgent's return code as always 0.

Test: mm -j 72
Test: adb install -r --fastdeploy --force-agent --local-agent /mnt/raid/boat-attack-apk/boat-attack-swappy.apk

Bug: 120197330
Change-Id: If835fd6ca2051be8e5ff6c957e08b1e458053989
2018-12-06 15:46:38 +00:00
Treehugger Robot
fa105049d8 Merge "adb: stop using adbkey.pub." 2018-11-27 21:35:44 +00:00
Josh Gao
2dc4cabe06 adb: stop using adbkey.pub.
An adbkey/adbkey.pub pair that doesn't match up results in a
hard-to-diagnose scenario where "Always allow from this computer"
doesn't work. The private key contains all of the information that's
in the public key, so just extract the public key out of the private
key instead of storing them separately.

Bug: http://b/119634232
Test: rm ~/.android/adbkey.pub; adb kill-server; adb shell true
Test: rm ~/.android/adbkey*; adb kill-server; adb shell true
Change-Id: I0ae9033dbcd119c12cfb2b3977f1f1954ac800c1
2018-11-15 17:50:57 -08:00
Mark Salyzyn
9f1cf25332 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I4f7ad84743e974b4b4d1d7256088f6c8b749a237
2018-11-14 09:35:34 -08:00
Josh Gao
cd85556151 adb: libusb: don't set interface alternate setting.
Match behavior with the legacy implementation.

Test: ADB_TRACE=1 adb server nodaemon
Change-Id: If1451871f252ef4499b3bb887e947169f8d2432f
2018-11-12 14:08:40 -08:00
Josh Gao
b35ee22887 adb: pin USB interface versions on darwin.
It's possible to build against an SDK that's newer than the OS that
we're actually running via Xcode update, and Apple increments the
unversioned IOKit interface IDs to the newest version on every release,
which leads to mysterious failures to acquire an interface.

Pin the interface versions to IOUSBFamily 5.0.0, which shipped on OS X
10.7.3.

Bug: http://b/119264733
Test: ./test_device.py
Change-Id: Id26760bc62c89a1f7ef67511b21f9d9252ab69f3
2018-11-08 16:49:46 -08:00
bohu
09faa66006 adb: print emulator console output
It is very helpful to see the output of the following adb command:
adb emu <emulator commands...>

Change-Id: I7905370fb955de4d457a323a7e9e780aaca5d45e
2018-10-30 14:36:33 -07:00
Victor Hsieh
02ef4bb190 adb install-multiple to also accept .fsv_sig
.fsv_sig will be fs-verity signature in PKCS#7 format.

Test: adb install-multiple foo.apk foo.apk.fsv_sig
Bug: 112037636
Change-Id: I4a9b2203334d4974602c7f138222ade1aa319ccb
2018-10-29 16:55:06 -07:00
bohu
ea0c3cbc18 adb: correct tcpip help message
'adb tcpip <mode>' is meant to affect adbd, not
the host adb server.

BUG: 111434128
Change-Id: I78c958bfbede60b20fb7e0f2444e5b21ecb90f7a
2018-10-24 10:38:33 -07:00
Josh Gao
fb08510784 Add feature flag for b/110953234 fix.
Bug: http://b/110953234
Bug: http://b/117946501
Test: adb features
Test: test_device.py
Change-Id: I340a30544a6d0ab1b2545e5371c8f98d04158c56
2018-10-23 18:28:46 +00:00
Dario Freni
29814deaa7 Accept apex packages as argument.
Bug: 112669193
Test: Successfully reaches PackageManager. Doesn't break existing flows.
Change-Id: If4a173e290ebf0b70beb97111a6d75400da7ec8d
2018-10-23 11:07:16 +01:00
Elliott Hughes
d2aaede610 adb: don't use <error.h>.
This should fix the bloody Mac build, which doesn't have <error.h>. Since
we weren't entirely happy with error(3) anyway, switch to the toybox
style of error_exit and perror_exit, which are slightly briefer and quite
a bit more intention-revealing.

Bug: N/A
Test: builds
Change-Id: Ic8e411906c363af51657da5ce947b25a0b6bb1f3
2018-10-22 17:04:32 -07:00
Elliott Hughes
4679a39610 adb: rationalize fatal/error logging.
Let's use LOG(FATAL)/PLOG(FATAL) for actual fatal stuff.

Add a Windows error(3) and move folks who didn't really mean "abort"
fatal over to it. Also get rid of syntax_error which wasn't adding a
lot of value, and most of the places it was adding "usage: " didn't seem
entirely appropriate anyway.

In particular, we seemed to have confused fastdeploy.cpp into aborting
in most user error cases, and none of the reviewers noticed. Clearly
we'd all lost track of far too many options.

(I've also cleaned up a few random instances of fprintf(3) + exit(2).)

Bug: N/A
Test: manual
Change-Id: I3e8440848a24e30d928de9eded505916bc324786
2018-10-19 14:04:24 -07:00
Treehugger Robot
11cbf7d711 Merge "adb: add reboot-fastboot command" 2018-10-12 03:38:05 +00:00
Mark Salyzyn
d8e94bd3f2 adb: add reboot-fastboot command
Alias reboot-fastboot to reboot fastboot

Test: manual
Bug: 117604012
Change-Id: I5f7842e420fbc0b1d9ae8e1231887fb8644b29e9
2018-10-11 13:21:16 -07:00
Pirama Arumuga Nainar
a2ccce870c Merge changes from topic "windows-libcxx"
* changes:
  Do not enable -Wold-style-cast for Windows
  Add sys/types.h in utf8.h
  Adapt to switch to libc++ for Windows
2018-10-11 17:00:53 +00:00
Idries Hamadi
86554e949b Merge "Reverted aapt dependency to be a dependency on libandroidfw" 2018-10-11 06:15:04 +00:00
Idries Hamadi
269a4b422b Reverted aapt dependency to be a dependency on libandroidfw
Removed call to external aapt2 process
Replaced several layers of error handling with calls to fatal()
Changed output messages for failures to be more useful for diagnostics

Bug: 116753196
Test: mm
Test: adb install -r --fastdeploy --force-agent --local-agent ~/example_apks/example.apk
Test: adb install -r --fastdeploy --no-streaming --force-agent --local-agent ~/example_apks/example.apk

Change-Id: I6006d8aa584e789a086a31e79a41d1416e54402a
2018-10-05 17:55:05 +01:00
Victor Hsieh
8e27656a9a Restore lost .dm support of adb install-multiple
Apparently some changes are lost in
https://android-review.googlesource.com/c/platform/system/core/+/600457.

Test: adb install-multiple foo.apk foo.dm
Bug: 117092647
Change-Id: I87a6e1509de809624254c77073d922617f222ed2
2018-10-04 10:46:56 -07:00
Elliott Hughes
cabfc3dc80 Support > 2GiB seeks in adb_lseek.
Also stop using size_t (which will be 32-bit on Win32) for offsets in
adb_sideload_host, and stop truncating large file sizes in our
"sideload-host" messages.

Bug: http://b/112003354
Test: builds
Change-Id: If5b7cc9d1fc7ff7ca6eaebd20418f7b061846203
2018-09-26 14:48:05 -07:00
Pirama Arumuga Nainar
29e3dd8548 Adapt to switch to libc++ for Windows
Bug: http://b/91353691

- libcxx has ETXTBSY for Windows
- adb/sysdeps/memory.h is no longer needed

Test: Build and test Windows binaries under Wine.

Change-Id: I9c27087d46c49cb25b391c4adae8d9e24724784d
2018-09-21 10:46:25 -07:00
Idries Hamadi
4af6ee4784 Small clean ups for issues raised in reviews of fastdeploy
Removed support for -f shortcut flag as this conflicts with some package manager flags
Renamed use_localagent global to match conventions
Fixed case where tmp files were created unnecessarily
Removed dead code (delete_host_file)
Cleaned up multiple layers of error handling by using fatal() as soon as error conditions occur

Fix: 113631900

Test: mm
Test: adb install -r --fastdeploy --nostreaming --force-agent --local-agent ~/example_apks/example.apk
Test: adb install -r --fastdeploy --no-streaming --force-agent --local-agent ~/example_apks/example.apk
Test: observe that fast deploy works as usual

Test: adb install -r -f --nostreaming --force-agent --local-agent ~/example_apks/example.apk
Test: adb install -r -f --no-streaming --force-agent --local-agent ~/example_apks/example.apk
Test: observe that fast deploy is no longer invoked by -f
Change-Id: Ic719df1003ac319e48b32f7f377f6f91d17f6a6f
(cherry picked from commit 0584689beaff604ceeccaf706dc368213d07b977)
2018-09-07 15:35:19 +01:00
Idries Hamadi
7575cd90e5 Modified fastdeploy dependencies to ensure that fast deploy is build as part of 'sdk' target
deploypatchgenerator is now a dependency of adb
deployagent is now a java_binary target and uses the built in 'wrapper' parameter to bundle deployagent.sh
fastdeploy.cpp code in adb modified to reference deployagent rather than deployagent.sh (required to work with built in wrapper functionality).
removed near-redundant fastdeploy_init and TFastDeployConfig singleton as per:
https://android-review.googlesource.com/c/platform/system/core/+/740521/12/adb/client/fastdeploy.cpp#36
relocated kFastDeployMinApi to more appropriate location

Test: rm -rf $ANDROID_ROOT/out
Test: make sdk -j40

Test: find out/ -iname deploypatchgenerator
Test: observe that deploypatchgenerator.jar has been built as a dependency of the sdk target

Test: mm
Test: adb install -r -f --force-agent --local-agent ~/example_apks/example.apk
Test: adb install -r -f --no-streaming --force-agent --local-agent ~/example_apks/example.apk

Change-Id: I4e52d32f87774b44845bf6b5be0bae331a0b2324
2018-09-06 10:05:54 +00:00
Idries Hamadi
5b6bf94716 Remove fastdeploy dependency on libandroidfw
Call aapt2 to determine package name instead of parsing APK within process.

Test: mm
Test: adb install -r -f --force-agent --local-agent ~/example_apks/example.apk
Test: adb install -r -f --no-streaming --force-agent --local-agent ~/example_apks/example.apk
Change-Id: I99b2c64f0617a9bb27a5c54a2e8f39efd5028f36
2018-09-05 15:59:20 -07:00
Treehugger Robot
28c9539697 Merge "adb: static constexpr." 2018-09-05 21:57:41 +00:00
Treehugger Robot
91a25771e0 Merge "adb: really make kill-server wait for server death" 2018-09-05 20:02:34 +00:00
Elliott Hughes
86ab9ff8a2 adb: static constexpr.
Also inline some single-use constants.

Bug: N/A
Test: ran tests
Change-Id: I1ac028667772599291da402120a270d0667fed04
2018-09-05 12:13:11 -07:00
Anton Hansson
1f8147fb19 Merge "Make sync and remount support product_services." 2018-09-05 11:00:35 +00:00
Treehugger Robot
4931a29f6d Merge "adb: win32: fix Ctrl-C of adb server nodaemon" 2018-09-05 04:47:28 +00:00
Anton Hansson
7f3c01c1d4 Make sync and remount support product_services.
Test: adb remount; touch /product_services/x
Test: adb sync
Bug: 80741439
Bug: 113657113
Change-Id: I8d85964428e5c43811bb5e807b523a0175dd3f5b
2018-08-31 16:18:03 +01:00
Spencer Low
c8ad0ca69d adb: really make kill-server wait for server death
It doesn't seem like b3c14ec693 was really
waiting for adb server death because the server would write OKAY to the
socket, causing the client to return from ReadOrderlyShutdown() before
the socket was actually closed.

The fix is to read the OKAY and then call ReadOrderlyShutdown() which
will then wait for the socket to be closed.

Test: Made the server hang in adb_server_cleanup() during kill-server
and kill-server would hang (as desired).
Test: To test resilience, tried preventing the server from sending OKAY and
adb kill-server still worked properly.

Change-Id: I4f0f11b86bbdc983670273ef5d3bb1dff7ab3697
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-08-29 15:46:47 -07:00
Ivan Afonichev
0a10040289 adb should #include <sys/sysmacros.h>
On modern systems <sys/sysmacros.h> no longer being included by <sys/types.h>
To use major(), minor() we should include <sys/sysmacros.h> explicitly.
See https://koji.fedoraproject.org/koji/taskinfo?taskID=29356781
Similar changes merged last year:
https://android-review.googlesource.com/c/platform/system/core/+/398913
https://android-review.googlesource.com/c/platform/system/core/+/399050
2018-08-30 01:12:56 +04:00
Spencer Low
84fc27159a adb: win32: fix Ctrl-C of adb server nodaemon
On Windows, when running adb server nodaemon and pressing Ctrl-C,
adb_server_cleanup (an atexit handler) would call kick_all_transports()
which would eventually fail a CHECK because the current thread was not
equal to the main thread. This is because Ctrl-C is implemented in
Windows by the OS creating a new thread in the process and calling the
Ctrl-C handler from there.

The CHECK fail would print out the CHECK expression and call abort()
which would record a crash in the Windows Event Log, plus would
potentially upload a crashdump to Microsoft's Watson service.

This might be a regression from d51c6df1ef.

The fix is to share more code between platforms, removing the call to
Win32 SetConsoleCtrlHandler() and just use the C Runtime's signal()
implementation which is built upon SetConsoleCtrlHandler(). The signal
handler still ends up being called from another thread, but the handler
is thread-safe enough so this seems to work.

Test: On Win10 and Vista, run adb server nodaemon and then try Ctrl-C,
Ctrl-Break and close console window.

Change-Id: I6603970616098d2b3ce68f2a3d4e5515ec859811
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-08-25 23:46:48 -07:00