Commit graph

141 commits

Author SHA1 Message Date
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
Idries Hamadi
7f51e007a2 Address style and efficiency post-merge feedback from previous change (ed409eaec2).
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: I44105a78c78c6d3c77a6b3b5e14f53cd1707b704
2018-08-23 17:24:07 +01:00
Treehugger Robot
f6d707ba93 Merge "adb: fix spurious usb write failure on Windows." 2018-08-23 03:12:30 +00:00
Josh Gao
7e7ab56e8e adb: don't spew push/pull progress to dumb terminals.
Bug: http://b/113070277
Test: adb push 100mb /data/local/tmp | cat
Test: adb sync | cat
Change-Id: I252bdbdbde825bba903f43bd892262786a58c4e4
2018-08-22 17:28:33 -07:00
Josh Gao
5d799cd454 adb: fix spurious usb write failure on Windows.
We were accidentally returning 0 instead of the number of bytes written
whenever we wrote a USB packet that had a size that was a multiple of
the USB packet size, which resulted in the device getting kicked.

Bug: http://b/113070258
Test: python test_device.py
Change-Id: Ib3d6415545e90e1f4730afc8ad8713d10bb1534a
2018-08-22 17:11:40 -07:00
Josh Gao
ec54ef7a8d Merge "Fix MacOS SDK build error caused by deprecated stl call." 2018-08-21 20:06:55 +00:00
Idries Hamadi
1d197931b7 Fix MacOS SDK build error caused by deprecated stl call.
Test: lunch sdk-eng && cd system/core/adb && mm
Test: adb install -r -f --force-agent --local-agent ~/example_apks/example.apk
Change-Id: Idf59cc30b7bc2150fc0d68289c3230c6a1057908
2018-08-21 19:25:01 +01:00
Treehugger Robot
15eb065bbb Merge "Integrate adb with fastdeploy" 2018-08-21 06:28:49 +00:00
Josh Gao
043fbec646 adb: add environment variables to disable usb, emulators, mdns.
Provide a way to selectively disable USB, automatic emulator
connection, and mDNS, to make reading through ADB_TRACE logging easier.

Test: manual
Change-Id: Ic6a06cdce14235415520cbf2d51c7f7031b7a7b3
2018-08-10 14:27:51 -07:00
Josh Gao
e032387480 adb: minor cleanup.
Test: mma
Change-Id: I874b10c2821ffe702fecd7e854bca2fbf4d701c3
2018-08-10 14:24:19 -07:00
Josh Gao
362e696bbf adb: report connection status when we're unauthorized.
Previously, connecting to devices that end up as unauthorized would
wait 10 seconds before reporting failure to the user. After this
change, notification happens as soon as the adb server realizes.

Test: manual
Change-Id: If7c8d38f22da3d98b952eee6a334abc8566bb751
2018-08-08 17:40:15 -07:00
Idries Hamadi
ed409eaec2 Integrate adb with fastdeploy
Test: lunch sdk-eng && make sdk -j44
Test: lunch aosp_walleye-eng && cd system/core/adb && 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: Ia1c2160f87ea584656f8fdd67e314a260d39d607
2018-08-06 13:57:47 +01:00
Calin Juravle
f03eebdd59 Accept DexMetadata files (.dm) for install-multiple
Allow .dm files (DexMetadata) to be passed to adb install-multiple.

Do not rename the input files based on their indices as the naming matters
for associating an .dm file to an .apk file.

Test: adb install-multiple -p com.android.cts.classloadersplitapp base.apk
     split.apk split.dm

Bug: 30934496
Change-Id: I2ac39e00d64eae938124250033f79e02f3c3f9c0
(cherry picked from commit aa7753871e)
2018-08-03 11:21:06 -07:00
Treehugger Robot
52126a414b Merge "adb: win32: fix Unicode console output" 2018-08-01 05:25:09 +00:00
Josh Gao
258d4a91c9 adb: fix error message for adb {forward,reverse}
Test: `adb reverse`
Change-Id: I6fa078ea7a0e019df5c6309df99ffdf2a3219194
2018-07-31 15:57:52 -07:00
Spencer Low
771ba0c057 adb: win32: fix Unicode console output
commandline.cpp includes commandline.h which defines
StandardStreamsCallbackInterface which calls fwrite(). In the
compilation unit for commandline.cpp, fwrite is getting remapped to
adb_fwrite (good), but the compilation unit for bugreport.cpp includes
sysdeps.h pretty late, which prevents fwrite from getting remapped to
adb_fwrite.

Apparently when linking, the version of StandardStreamsCallbackInterface
that gets used is the one from bugreport.cpp's compilation unit, which
doesn't call adb_fwrite().

And it's necessary to call adb_fwrite() to get Unicode console output on
Windows.

The fix is to #include "sysdeps.h" earlier in bugreport.cpp. I searched
the other object files for other unremapped calls to printf/fwrite/etc.
and didn't find any.

Bug: https://issuetracker.google.com/issues/111972753
Test: mma, manual test on Windows 10 x64

Change-Id: I322dff75a878397f5e10227e746e77b0024129d0
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-07-30 19:53:23 -07:00
Josh Gao
86acb863ff adb: split shell_service.h into client/daemon/protocol parts.
Test: treehugger
Change-Id: I67042f6b29a8a07619b8d56e7376d49b956a840c
2018-07-25 18:08:44 -07:00
Josh Gao
edec033b26 adb: split file_sync_service.h into client and daemon parts.
Test: treehugger
Change-Id: I648c7001903a91448c69986e08a6cd2dd76ed793
2018-07-25 18:08:32 -07:00
Luis Hector Chavez
6150a37dbe adb: Remove most C-style allocations
This change gets rid of most malloc/calloc/free calls. The future is
now!

Bug: None
Test: test_device.py
Change-Id: Iccfe3bd4fe45a0319bd9f23b8cbff4c7070c9f4d
2018-07-19 09:41:40 -07:00
Jerry Zhang
cb140c04c9 Merge changes I31e444f3,If07ff05f,If3ba190d
* changes:
  adb: Add io size and zero packet to usb_handle
  adb: Have device usb_handle return io size
  adb: Expose device usb_handle through libadbd
2018-07-17 22:35:36 +00:00
Jerry Zhang
16b78db945 adb: Have device usb_handle return io size
Previously, read and write would return 0
on success. Now it will return the number
of bytes read/write. This is more consistent
with other usb handles and is needed in order
to handle partial packets (for fastbootd).

Update usb_write in other usb handles
to return amount written.

Change transport_usb accordingly.

Test: adb works
Bug: 78793464
Change-Id: If07ff05fbc8120343f20661475d34f4e5ff805de
2018-07-17 11:53:30 -07:00
Yi Kong
aed415cc47 [adb] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: Ia8c4deacafed2f3b7dbc3d4c3c77c6c632e3de81
2018-07-13 18:21:00 -07:00
Josh Gao
0cee7ccc59 adb: work around adbd push bug.
We shipped (well, are about to ship) an adbd that spuriously fails to
create directories upon push. Work around this in the adb client by
running a mkdir on all of the directories we would have otherwise
created.

On devices where we perform the workaround, this coincidentally fixes
a historic bug where we failed to push empty directories.

Bug: http://b/25566053
Bug: http://b/110953234
Test: python test_device.py
Change-Id: I690ec356c206fed4e5ab2c681c5570c8b231e26b
2018-07-10 13:20:40 -07:00
Elliott Hughes
d8a4c60276 Simplify __attribute__((__printf__)) use.
We don't need this now everyone's using clang...

Bug: http://b/69933068
Test: ran tests
Change-Id: I88f0cf03981ade47e210387fd6f3a2706dfeb9b8
2018-06-26 13:07:21 -07:00
Josh Gao
172d0d44bc adb: add adb raw to connect to an arbitrary service.
Add a command to connect to an arbitrary service, for debugging
purposes.

Test: `adb raw shell:ls`
Change-Id: I69d4d585e5ecfa7cb8c7a543a2a27df7033b26c7
2018-06-18 14:51:56 -07:00
Elliott Hughes
31f0f1bcee Fix adb logcat return code.
`adb shell logcat` works, and `adb logcat` should too.

Bug: http://b/110202648
Test: suspended the logd process and manually removed the socket
Change-Id: If14de7c2eb178c7b4210d6bdb44df084615db33a
2018-06-14 10:47:00 -07:00
Treehugger Robot
ae74e42d25 Merge "Fix exit-time-destructor warning" 2018-06-06 23:28:07 +00:00
Pirama Arumuga Nainar
8b47d316d2 Fix exit-time-destructor warning
By initializing the global handle_list on the heap.

Test: Run Clang-built adb_test.exe under wine
Change-Id: I2326011b7e44c6d0cb4721d4b68fde7188b87c38
2018-06-06 14:41:26 -07:00
Josh Gao
7a223584c5 Merge changes I465804fd,Ib5a684bb,If5e66570,I8471cc00,I8ba0a70a
* changes:
  adb: convert fdevent over to unique_fd.
  adb: move towards using unique_fd.
  adb: delete FDEVENT_DONTCLOSE.
  adb: remove fdevent_install, fdevent_remove.
  adb: fix uninitialized variable in AsyncServiceRef.
2018-05-23 00:01:29 +00:00
Josh Gao
71f775a944 adb: remove fdevent_install, fdevent_remove.
Remove fdevent_install and fdevent_remove in favor of using
fdevent_create and fdevent_destroy, so that we can put RAII types (i.e.
unique_fd) into fdevent without worrying about -Wexit-time-destructors
or structs that are freed instead of deleted.

Bug: http://b/79786774
Test: python test_device.py
Change-Id: I8471cc00574ed492fe1b196944976cdaae8b7cff
2018-05-22 14:54:49 -07:00
Luis Hector Chavez
454bc7c0be adb: Add a way to reconnect TCP transports
This change adds a reconnect handler that tracks all TCP transports that
were connected at some point, but became disconnected. It does so by
attempting to reconnect every 10s for up to a minute.

Bug: 74411879
Test: system/core/adb/test_adb.py
Test: adb connect chromebook:22  # This runs with sslh
Test: CtsBootStatsTestCases
Test: emulator -show-kernel ; adb -s emulator-5554 shell

Change-Id: I7b9f6d181b71ccf5c26ff96c45d36aaf6409b992
2018-05-16 15:20:48 -07:00