Commit graph

2885 commits

Author SHA1 Message Date
Treehugger Robot
c2501fda60 Merge "adbd: fix remount on non-system-as-root devices." 2018-09-14 23:24:44 +00:00
Josh Gao
96d445d846 adbd: fix remount on non-system-as-root devices.
The system image is now a root image, even on devices that don't use
system-as-root. Fix remount to always remount /, to account for this.

Bug: http://b/115751838
Test: `adb remount; adb shell mount | grep " / "`
Change-Id: I2d89a795bd0bc53af33fe69c9d049bbb64d26f3b
2018-09-14 14:32:27 -07:00
Peter Collingbourne
fc0373706d libadbd_services: Link libselinux dynamically instead of statically. 2018-09-13 14:34:04 -07:00
Idries Hamadi
5e26856b98 Merge "Small clean ups for issues raised in reviews of fastdeploy" 2018-09-08 12:11:48 +00:00
Treehugger Robot
756e28ee0c Merge "adb: win32: test for Unicode console output" 2018-09-08 01:35:29 +00:00
Josh Gao
c8d3853a14 Merge "adb: win32: set thread names" 2018-09-07 22:18:18 +00: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
662a3a6cc3 Merge "Remove fastdeploy dependency on libandroidfw" 2018-09-06 07:26:36 +00:00
Treehugger Robot
a23ba9f61a Merge "adb: win32: test USB kick on resume from sleep/hibernation" 2018-09-06 04:27:23 +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
484f72abbf Merge "adb: win32: fix ReportServerStartupFailure" 2018-09-05 21:24:33 +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
Elliott Hughes
60ba9943ed Merge "adb: syntax_error: add compile time format string checking" 2018-09-05 15:56:10 +00: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
Spencer Low
a00f91b4c1 adb: syntax_error: add compile time format string checking
Test: mma

Change-Id: I8eccd17a1feac0dd98fb317d30ab27489b803669
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-09-04 18:08:49 -07:00
Spencer Low
50beee3a2c adb: win32: set thread names
Use a new Windows 10 API, SetThreadDescription(). Background info from a Chrome developer:

https://randomascii.wordpress.com/2015/10/26/thread-naming-in-windows-time-for-something-better/

Test: Win10, Vista, adb shell
Test: Ran windbg -pn adb.exe, used .dump /ma to create a dump, ran
`dx -g @$curprocess.Threads' on the dump and it showed the thread names.

Change-Id: I14ea7121605cb3fa45ce7b59e2ba5882a215b59f
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-09-03 16:11:33 -07:00
Spencer Low
40babf0709 adb: win32: fix ReportServerStartupFailure
The code was passing an fd from adb_open() to android::base::ReadFdToString() which actually
takes a C-Runtime fd (on Windows), so it wasn't working.

The fix is to use APIs that deal with C-Runtime fds:
* unix_open()
* android::base::unique_fd
* unix_lseek() (added in this change)

I also removed an unnecessary call to GetProcessId() since we already have the process id
from the structure returned by CreateProcess().

Test: adb start-server on Win10 and Ubuntu (with a failing server)
Test: mma

Change-Id: Id6e2dd5532a02fe5d9caf96aa007a1b3434a0b59
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-09-02 19:26:25 -07:00
Spencer Low
8f6bdc9eb5 adb: win32: test USB kick on resume from sleep/hibernation
Unittest for a5b06b0ff8. Works by
simulating resume from sleep/hibernation by sending a Windows message.

Test: python3 -m unittest test_adb.PowerTest

Change-Id: I78510f30c012f68eda39764da522dbf8d03f2576
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-08-31 19:49:46 -07: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
Dan Willemsen
4d8929773b Merge "Convert fastboot to Soong" 2018-08-30 23:36:54 +00:00
Josh Gao
fc2e56ffd7 adb: don't try to reconnect emulators.
Bug: http://b/113533872
Test: ./test_adb.py
Change-Id: Id591f43b487cc3928390e30f11645990e34a51bf
2018-08-30 11:37:00 -07:00
Dan Willemsen
ab971b5e7e Convert fastboot to Soong
Also fix adb's version number to match.

See build/soong/README.md for more information.

Test: cd system/core/fastboot; mma
Test: fastboot --version
Test: adb --version
Test: out/host/linux-x86/nativetest/fastboot_test/fastboot_test
Test: out/host/linux-x86/nativetest64/fastboot_test/fastboot_test
Change-Id: I65ea39af9183c602e84f3bc0e4a0d066a30fc464
2018-08-30 11:28:18 -07: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
Mark Salyzyn
7c2020bf64 adb: use fs_mgr_has_shared_blocks
Use fs_mgr_has_shared_blocks in fs_mgr for adb.

Test: compile
Bug: 109821005
Change-Id: Idccaa252c7630375e49f58727a014e61b50a96d6
2018-08-27 16:29:58 +00: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
Treehugger Robot
ddb2bfeae4 Merge "adb: don't spew push/pull progress to dumb terminals." 2018-08-23 02:20:21 +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
860cc5ae39 adbd: use unique_fd for the usb file descriptors.
Test: adb shell
Change-Id: I8b5e31377bbda9b02e522e3a4b75ac908197912f
2018-08-22 15:33:08 -07:00
Treehugger Robot
6d2ace3684 Merge "adb: fix test_adb.py's adb server spawning on Windows." 2018-08-22 00:09:56 +00:00
Treehugger Robot
627a74b714 Merge "adb: add better logging for connection failure." 2018-08-21 21:41:02 +00:00
Josh Gao
92cd59fc31 adb: fix test_adb.py's adb server spawning on Windows.
Test: test_adb.py on windows vm
Change-Id: I918678be7ececd167969789ecff7cfb58829fa1d
2018-08-21 14:28:56 -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
Tao Bao
308129d274 Merge "adb: Drop the unneeded dependency on libfec_rs.so." 2018-08-15 18:14:16 +00:00
Treehugger Robot
3231be66ce Merge "Add sideload, fastboot as reboot targets in init" 2018-08-14 21:25:50 +00:00
Tao Bao
0caf3c1617 adb: Drop the unneeded dependency on libfec_rs.so.
It was only needed when we statically linked libfec into libadbd in
past.

Test: `mmma -j system/core/adb`
Test: `m -j installclean && m -j bootimage` with aosp_taimen-userdebug.
      Check the installed files in recovery image.
Change-Id: I8627d5f98568ab1d71e6a47cb1b2540a33bffdab
2018-08-14 06:05:04 +00:00
Josh Gao
45e3e95de0 adb: add better logging for connection failure.
Test: manual
Change-Id: I1babee0e01376955529dc1e7d5e3257a7f51f33d
2018-08-13 16:33:54 -07:00
Josh Gao
902dace132 adb: make disconnect stop reconnection immediately.
Make `adb disconnect` remove transports immediately, instead of on
their next reconnection cycle.

Test: adb connect unreachable:12345; adb devices; adb disconnect; adb devices
Change-Id: I35c8b57344e847575596d09216fc636be47dde64
2018-08-13 16:33:54 -07:00
Spencer Low
69d8c39502 adb: win32: test for Unicode console output
Unit test for adb on Windows writing Unicode to an actual console
Window, as opposed to a pipe or file.

Test: Ran test on Ubuntu and Windows 10, tested version of adb with
incorrect Unicode handling and verified that test failed

Change-Id: Ibdda46d0fee83004537bcbb48a5c2fd6d3e1d593
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-08-11 00:16:16 -07:00
Josh Gao
8a40c8a109 adb: switch reconnect_queue to std::set.
We can't remove from the middle of a priority_queue, which a followup
commit wants to do, so switch to std::set, with the side benefit of
making operator< point the right direction.

Test: mma
Test: ./test_adb.py
Change-Id: I784c1dcc91f0a9cf760e9fa1710202e37e85432b
2018-08-10 15:58:11 -07: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
18eae78c09 Merge changes If7c8d38f,I7117dd19,Iaa5006e3,I3a568361,I37df06e4, ...
* changes:
  adb: report connection status when we're unauthorized.
  adb: disable test_device.FileOperationsTest.test_pull_symlink_dir.
  adb: fix test_device.FileOperationsTest.test_push_empty
  adb: switch test_adb.py over to double quotes.
  adb: make test_adb.py work on windows.
  adb: switch test_adb.py to python3.
2018-08-09 22:12:46 +00:00
Mark Salyzyn
d88b52e7f4 Merge changes from topic "squashfs+overlayfs"
* changes:
  init: add fs_mgr_overlayfs_mount_all to FirstStageMount
  adb: add overlayfs handling for readonly system filesystems
  fs_mgr: get fs_mgr_mount_all to call fs_mgr_overlayfs_mount_all
  fs_mgr: add overlayfs handling for squashfs system filesystems
2018-08-09 20:44:20 +00: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
Josh Gao
a8db274a69 adb: disable test_device.FileOperationsTest.test_pull_symlink_dir.
selinux prevents us from doing this.

Test: python test_device.py
Change-Id: I7117dd19348b0764638977b7c958331a4839ea4f
2018-08-08 17:40:15 -07:00
Josh Gao
6c1b42ccd0 adb: fix test_device.FileOperationsTest.test_push_empty
Test: python test_device.py
Change-Id: Iaa5006e39c3d61374de11c05bcaffb4f30b7512e
2018-08-08 17:40:15 -07:00
Josh Gao
b3610734f8 adb: switch test_adb.py over to double quotes.
Test: ./test_adb.py
Change-Id: I3a568361d54f32cc895cea439de0f2c38aee5e2d
2018-08-08 17:40:15 -07:00
Josh Gao
676f375d9b adb: make test_adb.py work on windows.
Switch from os.pipe to socket.socketpair for the fake adbd termination
termination signaller, that we can select on it on windows.

Test: test_adb.py on windows (2 failures on windows)
Change-Id: I37df06e465ec8be28cfb18a5c21ef30125195004
2018-08-08 17:40:15 -07:00
Josh Gao
9b6522b357 adb: switch test_adb.py to python3.
Currently, test_adb.py doesn't work on Windows, because we're selecting
on a pipe, which doesn't work on Windows. Python 3.5 adds socketpair
support to Windows, so switch over to Python 3 to make it so we can use
that.

Test: python3 test_adb.py
Change-Id: I0fbd1bca0b28324658831d5ef8ee08aefe2b0596
2018-08-08 17:40:15 -07:00
Treehugger Robot
7b1d163cb8 Merge "Add adb integration test to general-tests" 2018-08-09 00:05:51 +00:00
Mark Salyzyn
c60153f742 adb: add overlayfs handling for readonly system filesystems
adb verity-on setup overlayfs directories, do not skip if verity
feature not configured for device.

adb verity-off teardown overlayfs directories, do not skip if verity
feature not configured for device.

adb remount setup overlayfs directories and mount if possible, and
do so without a reboot if possible.

Test: compile
Bug: 109821005
Bug: 110985612
Change-Id: I28c4c23fea44b886c5523f0286a523f0b0485df0
2018-08-08 15:42:44 -07:00
Julien Desprez
75fea7ec3b Add adb integration test to general-tests
In order to run them continuously, add them to general-test
zip.

Test: make general-tests
Bug: 112104122
Change-Id: I7a1143ac638626069ed78ddd450063e9489e22e8
2018-08-08 12:08:50 -07:00
Josh Gao
4039051d6d adb: clean up handle_host_request.
Previously, we were returning the result of SendOkay/SendFail in a few
places after handling a host request, which is incorrect for two
reasons. First, the return type of SendOkay/SendFail is bool, and
handle_host_request was expected to return 0 on success. Second, we
don't care if the SendOkay fails; if we got to that point, we're done
with the request, regardless of whether we succeeded to report our
result. The result of this was a spurious failure result reported after
the initial result, which was ignored by the adb client.

Test: manually straced adb server
Test: python test_adb.py
Test: python test_device.py
Change-Id: I7d45ba527e1faccbbae5b15e7a0d1557b0a84858
2018-08-07 14:24:36 -07:00
Josh Gao
50973d1865 Merge changes from topic "fdsan_debuggerd"
* changes:
  adb: actually enable fdsan.
  adb: move AdbCloser to its rightful place.
  libdebuggerd: extract and print the fdsan table.
  crash_dump: pass the address of the fdsan table.
2018-08-07 10:02:16 +00:00
Josh Gao
297d9bf8ea adb: actually enable fdsan.
adb was using a custom unique_fd closer that didn't have an
implementation for fdsan, which meant that none of our FDs were
actually tracked. Guard this behind ifdefs so that we only use this
on Windows, and delete our implementation of Pipe in favor of the one
in libbase while we're at it. libbase's implementation always sets
O_CLOEXEC, so fix up the instance of Pipe that doesn't expect that.

Test: mma
Test: adb start-server
Test: debuggerd `pidof adbd`
Change-Id: Ic29d641a2f93fb42384b00c51775048c8bcbe152
2018-08-06 18:50:10 -07:00
Josh Gao
9d100f1043 adb: move AdbCloser to its rightful place.
Test: mma
Change-Id: Ie74c49e8abf72f594a35d04b2b0d99b96f58f8d0
2018-08-06 18:50:10 -07:00
Tao Bao
eca59ae895 adb: adbd uses shared libraries.
This CL builds the former `libadbd` as a shared library, and moves
`adbd` to using shared libraries.

We can't switch `libadbd` from static to shared library directly, due to
the circular dependency between `libadbd` and `adbd`. In particular,
daemon_service_to_fd() can't be compiled into `libadbd`, as it needs to
be overridden by recovery/minadbd.

This CL creates a static library `libadbd_core` as the common base,
which contains everything from the former `libadbd`. Both of the two
shared library targets `libadbd` and `libadbd_services` depend on
`libadbd_core`.

The `adbd` on device (under both of normal boot and recovery) now
depends on `libadbd.so` and `libadbd_services.so`. recovery/minadbd will
depend on `libadbd.so` and `libminadbd_services.so` in future (after
fully converting recovery to Soong).

Bug: 78793464
Test: `m dist`
Test: Run adbd_test on marlin.
Test: Build and flash marlin on device. Check basic adbd functionalities
      (`adb shell` and `adb sync`) under normal boot and recovery.
Test: `adb sideload` on marlin.
Change-Id: Iacbd4db524ef94abd175cd1d27688f4faf3db024
2018-08-06 11:40:47 -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
Treehugger Robot
d560f39fd7 Merge "Accept DexMetadata files (.dm) for install-multiple" 2018-08-03 20:14:28 +00: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
Hridya Valsaraju
71fb82a271 Add sideload, fastboot as reboot targets in init
Rebooting to these targets requires writing bootloader
messages and thus root. Moving them into init means that
adb, reboot don't need root to use these targets.

Test: try rebooting to these targets
Bug: 78793464
Change-Id: Ia002d1e3b1cb0c0616f60435fb9af4dce162cf84
2018-08-03 10:03:41 -07:00
Treehugger Robot
acc0a90869 Merge "adb: delete hellish hodgepodge." 2018-08-02 23:46:50 +00:00
Josh Gao
3b4de3c355 adb: delete hellish hodgepodge.
This code was unreachable, since all of the callers were calling
register_socket_transport with foo.c_str() as the serial. Lift this
assumption into the type system by switching from char* to std::string
for the argument type.

Bug: http://b/112147760
Bug: https://www.viva64.com/en/b/0579/
Test: mma
Change-Id: I5a6ee265feee6b83bc933a64d895eed39fce68e7
2018-08-02 14:51:05 -07:00
Josh Gao
6fb9461103 adbd: when rebooting, don't close socket before pausing.
An accidental side-effect of the change to unique_fd was that we
started closing the reboot service socket before pausing and waiting
for our death. This results in the client immediately returning, which
means they might get a chance to run other commands before we actually
manage to reboot.

Bug: http://b/112104037
Test: adb reboot; adb devices
Change-Id: Id61321da0c08ebd1ab57f1ce926bafd9109dd9c2
2018-08-02 12:52:26 -07:00
Treehugger Robot
52126a414b Merge "adb: win32: fix Unicode console output" 2018-08-01 05:25:09 +00:00
Josh Gao
def91c0abf adb: disable ReconnectHandler in adbd.
Previously, when a TCP connection was disconnected from adbd, we were
registering it with ReconnectHandler, which led to the transport
sticking around after the socket was closed. Due to the naming of
TCP transports in adbd (host-<fd number>), this results in incoming
connections being immediately closed if their file descriptor number
ends up being the same as a TCP transport that had previously
disconnected.

Guard all of the reconnect logic with ADB_HOST, to fix this.

Bug: http://b/112054041
Test: while true; do adb connect <device>; adb connect <device>; adb shell true; done
Change-Id: Ib55d304d7e07d6d744e8321d34671bb6d4b91afe
2018-07-31 18:28:32 -07: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
Josh Gao
e445a6d8a2 adb: more immediately try to reconnect connections.
Most disconnects we're likely to encounter are cases where either we
notice immediately and can start reconnecting almost immediately (adbd
restarting because of `adb root`, etc.), or where we won't notice for a
while anyway, so a 10 second sleep is somewhat meaningless.

Test: adb root; time adb wait-for-device shell
Change-Id: I18e9213dc4e84d735e9240118a368dcb38f21c78
2018-07-31 15:57:49 -07:00
Josh Gao
95af641bd6 adb: don't pass time_point::max to condition_variable::wait_until.
libstdc++ implements wait_until by calculating the offset between its
default clock and the clock that it's given by calling now() on each
and subtracting, and then adds that offset to the time_point argument.
When time_point::max is used, this overflows, resulting in the
reconnection thread spinning.

Test: wine adb.exe server nodaemon
Change-Id: Ife58f0aad14bc44c0804483d3ff2351c28b3d576
2018-07-31 15:56:31 -07:00
Josh Gao
1906243017 adb: move list-forward, kill-forward back into handle_forward_request.
The daemon-side reverse functions depended on handle_forward_request:
move them back instead of duplicating the logic we had in
handle_host_request. Accomplish what we originally wanted to do in this
change by changing the transport argument of handle_forward_request to a
std::function that acquires a transport, either via
acquire_one_transport or immediately returning a value that we already
have.

As a side effect, fix a bug where we would emit spurious errors for host
service requests.

Bug: http://b/112009742
Test: echo "001chost:connect:127.0.0.1:5555" | nc localhost 5037
Test: python test_device.py
Test: python test_adb.py
Change-Id: Iccc555575df6dbd7de10382854c4ea2c6f4beeaa
2018-07-31 15:36:55 -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
David Anderson
6dc508671b adb: Correctly detect deduplicated ext4 partitions.
The fs_has_shared_blocks function had two problems. One, it called
statfs() on the mount point, which will return information about the
file system the mount point is on, rather than the filesystem mounted at
that location. Second, the check for EXT4_SUPER_MAGIC was inverted.

Bug: N/A
Test: adb remount -R works on an ext4 deduplicated device
Change-Id: I2e5ef895ea274cb7cc3c35295120da90a026d0d2
2018-07-30 16:08:29 -07:00
Treehugger Robot
d81c4f07fb Merge "adbd: fix check of remount -R." 2018-07-28 01:00:36 +00:00
Josh Gao
1ba2e6a27f Merge "adb: split daemon services out of service_to_fd." 2018-07-27 23:17:18 +00:00
Josh Gao
2712192e12 adbd: fix check of remount -R.
The check was accidentally flipped when refactoring from strcmp to
std::string::operator==, inverting the behavior of `remount -R`.

Test: `adb remount` with verity enabled
Change-Id: Ib43889f1f4cc2f8fe1fd5d6e17e47d538dbe91bd
2018-07-27 16:08:56 -07:00
Mark Salyzyn
c29bf192b5 adb: use WriteFdExactly when no format
Minor cleanup

Test: compile
Bug: 109821005
Bug: 110985612
Change-Id: I15e33a9136675afe7a9498516301ad4960ad2a82
2018-07-27 10:53:54 -07:00
Josh Gao
997cfac89f adb: split daemon services out of service_to_fd.
Let minadbd override daemon services by pulling out the daemon services
into a separate translation unit, that isn't compiled into libadbd.

Bug: http://b/111831478
Test: mma
Change-Id: Iecfebea371e03864108eca9a4d2e9cfd5db34749
2018-07-25 18:49:37 -07:00
Josh Gao
954adcc541 adbd: turn on fdsan warnings.
Test: mma
Test: python test_device.py
Change-Id: Ic90fac0b731b0aa9fa934f4472b0c40f1263c340
2018-07-25 18:49:37 -07:00
Josh Gao
6523309151 adb: add error-generating overload of adb_close(unique_fd).
Test: mma
Change-Id: Id9c1230394afe980ba90dbd5150b65e8bf997b6c
2018-07-25 18:49:37 -07:00
Josh Gao
56300c9d00 adb: fix register_socket_transport related double-closes.
Multiple codepaths were closing the fd they passed into
register_socket_transport on failure, which would close the fd itself.

Switch things over to unique_fd to make it clear that we don't actually
have to close on failure.

Test: mma
Change-Id: I2d9bdcb1142c24931d970f99ebdf9a8051daf05c
2018-07-25 18:49:37 -07:00
Josh Gao
e261f6b410 adb: fix double close in local_connect_arbitrary_ports.
register_socket_transport takes ownership of the fd, leading to a
double close if the registration fails.

Test: mma
Change-Id: I9d699af1a979bedc1dc466427436d47f09d0a88f
2018-07-25 18:08:45 -07:00
Josh Gao
73a5ee4df5 adb: use adb's unique_fd instead of android::base.
Replace all usages of android::base::unique_fd with the unique_fd from
adb_unique_fd.h, which calls adb_close instead of close on Windows.

Most of these changes are no-ops, except for the ones to
create_service_thread, which was probably pretty broken on Windows.

Test: python test_device.py
Test: adb_test
Test: wine adb_test.exe
Change-Id: Ia4d03f9e2e7ddc88c97dc64172d721f93f3bf853
2018-07-25 18:08:45 -07:00
Josh Gao
2deb787ee2 adb: move remount_service.h into daemon.
Test: treehugger
Change-Id: I1a895d52da2c2ef281d562be778cfe0a01854a4f
2018-07-25 18:08:45 -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
Treehugger Robot
32acd3171a Merge "adb: fix forward --list, --remove(-all) with multiple devices." 2018-07-24 00:47:47 +00:00
Josh Gao
91c25c0159 adb: fix forward --list, --remove(-all) with multiple devices.
Also, fix error reporting when forward fails because we can't get a
transport, because there's either zero, or more than one transport that
matches the request.

Bug: http://b/111021517
Bug: http://b/111374366
Change-Id: Ia4c3bf6215c3ff4e9023ba1af556f5b10463bd6d
Test: manual
2018-07-23 14:11:26 -07:00
Luis Hector Chavez
46b55e83c5 adb: Fix adb remount
This change makes `adb remount` work again in some devices.

Bug: None
Test: `adb remount` in taimen
Change-Id: I04ec043fdb868f18a53a012c82e239c862ae7eff
2018-07-21 22:49:14 -07:00
Treehugger Robot
c23280a1e3 Merge changes Iccfe3bd4,I6380245b,I20d9f2fe
* changes:
  adb: Remove most C-style allocations
  adb: Modernize the service creation
  adb: Preserve the original mount flags when remounting
2018-07-20 18:35:25 +00:00
Treehugger Robot
74be24d696 Merge "Adb and fastboot completion supports zsh users." 2018-07-20 10:27:27 +00: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
Luis Hector Chavez
095792c300 adb: Modernize the service creation
This change removes the void* argument passing and instead uses C++11
features to avoid having to handle memory manually.

Bug: None
Test: python ./system/core/adb/test_device.py

Change-Id: I6380245b2ca583591810e3e363c67c993a107621
2018-07-18 20:38:10 -07:00
Luis Hector Chavez
c20c85008d adb: Preserve the original mount flags when remounting
This change preserves any additional flags mount flags (e.g. MS_NODEV)
that any of the mounts would have. This avoids unnecessarily opening up
permissions, and also allows kernels that have additional restrictions
about what mount flags can be used to be happy with the remounts.

Bug: 111618714
Test: `adb remount` works in Chrome OS
Test: `adb remount` works in sailfish_aosp

Change-Id: I20d9f2feaf3a47b93bfcdfb4164ee61546ec0b68
2018-07-18 19:48:08 -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
cda7c3b27c adb: Add io size and zero packet to usb_handle
Fastboot protocol doesn't include zero packets,
so make it possible to configure that.

Allow fastbootd to see how many bytes the handle
can read/write at once.

Test: adb works
Bug: 78793464
Change-Id: I31e444f384d9d0cdf1ea936439b2028f8151c3b8
2018-07-17 11:54:38 -07: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
Jerry Zhang
b156c60ad4 adb: Expose device usb_handle through libadbd
Fastbootd will reuses adb's functionfs transport
implementation.

Move it to daemon/include as well so it can be accessed
with "adbd/usb.h". Otherwise usb.h will conflict with
other imports.

Test: adb builds and works
Bug: 78793464
Change-Id: If3ba190d5c74b5f3633411f0484195e5a2a34d44
2018-07-17 11:53:06 -07:00
Jim Tang
0bd3432c5b Adb and fastboot completion supports zsh users.
Builtin command "type" in zsh doesn't support -t option and this
is resolved by checking the shell type prior to sourcing them.
Instead of using "type -t" explicitly, check_type() knows the the
type of the current shell and behaves accordingly.

Bug: 110629292
Test: (zsh) source build/envsetup.sh && lunch aosp_arm
      (bash) source build/envsetup.sh && lunch aosp_arm

Change-Id: Ie39e130e9cc87135cfd522abedba11ad5ac25261
2018-07-17 14:19:35 +08: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
Elliott Hughes
771f2c2a3e Merge "Remove unused #include." 2018-07-11 20:16:21 +00:00
Treehugger Robot
3eb5d77913 Merge "adb: work around adbd push bug." 2018-07-11 18:37:39 +00:00
Elliott Hughes
cd0f5c33fa Remove unused #include.
Bug: N/A
Test: builds
Change-Id: I792bfdb38672f7a51991c19a9838dd12500036c7
2018-07-11 11:21:36 -07:00
Ryan Prichard
e4fded2c48 adb: fix escape_arg for multiple quotes
escape_arg reuses the same index for the source (s) and the destination
(result), so it breaks on strings containing more than one quote, e.g:

 * a'b'c    ==> 'a'\''b'c'
 * a'bcde'f ==> 'a'\''b'\'cde'f'

Also make the function more efficient by doing fewer string copies. This
code is based on the android::base::Split code.

Use EXPECT_EQ because the tests can keep going if one fails.

Bug: none
Test: adb_test --gtest_filter=adb_utils.escape_arg
Change-Id: I6ca6e905fa53cc61b9a87276cb7116a5df7e8017
2018-07-10 23:32:09 -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
Josh Gao
4c0078d67a adbd: fix spurious failure to create dirs when pushing.
When pushing to a path, we first try to ensure the directory path
exists and has the permissions expected by fs_config. Due to a change
that changed the fs_config check from a blacklist to a whitelist, we
started doing this for /data (which doesn't begin with /data/), and the
UID/GID for that path was accidentally being reused for following path
segments that didn't exist, leading to a failed attempt to chown
/data/local/tmp/foo to be owned by system.

Bug: http://b/110953234
Test: python test_device.py
Change-Id: Ie798eec48bcf54aea40f6d90cc03bb2170280ee8
2018-07-09 14:25:51 -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
Treehugger Robot
b8f4fe4fd4 Merge changes from topic "mingw-clang"
* changes:
  Do not customize __format__ for Windows/MinGW to gnu_printf
  Adapt to switch to Clang for Windows host builds
  Update cflags for building Windows modules with Clang
2018-06-26 19:47:53 +00:00
Pirama Arumuga Nainar
a2df1ef441 Do not customize __format__ for Windows/MinGW to gnu_printf
Bug: http://b/69933090
Bug: http://b/69933068

MinGW uses gnu_printf to force C99 printf analysis with GCC, but clang
does not support gnu_printf.  So just use the default that's used for
other platforms.  This also mirrors upstream commit
015e637b4b/.

Test: m native-host-cross with Clang.
Change-Id: I3deb266d70e25296c4ae1d58637afbabc3d949c1
2018-06-25 11:52:54 -07:00
Treehugger Robot
409465a241 Merge "adb: fix obsolete documentation." 2018-06-23 00:57:20 +00:00
Elliott Hughes
accc95dc6b adb: fix obsolete documentation.
Bug: http://b/110564383 Obsolete adb document, inconsistent with current implementation
Test: N/A
Change-Id: If12ba8546991ee6f2a89ca0ff8036b598742dc11
2018-06-22 13:12:19 -07:00
Josh Gao
04b9ca8c31 Revert "adb: detect some spin loops and abort."
This seems to be falsely triggering.

This reverts commit 3bbc8164b1.

Test: none
2018-06-22 13:07:22 -07:00
Pirama Arumuga Nainar
7982178b7b Update cflags for building Windows modules with Clang
Bug: http://b/69933068

- Add -Wexit-time-destructor globally after fixing one warning
- Enable -Wthread-safety only for non-windows targets.  The version of
libstdc++ we use for Windows doesn't have the correct thread-safety
annotations.

Test: Run Clang-built adb_test.exe under wine
Change-Id: I76a43060342e7d1dc370ce3e117f3563c82b7751
2018-06-19 20:27:37 -07:00
Treehugger Robot
9674bcbd23 Merge changes Ibfa5e7e6,I706b57a9,I53d21134,I69d4d585
* changes:
  adb: detect some spin loops and abort.
  adb: add an id field to fdevent.
  adb: delete unused members in fdevent.
  adb: add `adb raw` to connect to an arbitrary service.
2018-06-19 02:39:28 +00:00
Josh Gao
3bbc8164b1 adb: detect some spin loops and abort.
Track pending fdevents, and abort if we see an fdevent ready for
read/write for 5 minutes continuously.

Also, add a service that intentionally starts spinning, to test this.

Test: manually changed timeout to a minute, `adb raw spin`
Change-Id: Ibfa5e7e654996587f745887cb04987b982d79bed
2018-06-18 17:46:34 -07:00
Treehugger Robot
812ba6a469 Merge "adb: add nonblocking fd Connection." 2018-06-18 21:59:12 +00:00
Josh Gao
ded557fa58 adb: add an id field to fdevent.
Tracking fdevents by pointer is dangerous because an fdevent can be
destroyed and recreated at the same address. Add a monotonically
increasing id field to fdevent for this purpose.

Test: treehugger
Change-Id: I706b57a9e669290ef2db258f85489a5155fc1152
2018-06-18 14:55:27 -07:00
Josh Gao
e44d38d680 adb: delete unused members in fdevent.
Forgot to clean this up after removing fdevent_install...

Test: treehugger
Change-Id: I53d21134a4bc8bf7b16210318c6fac5075445b39
2018-06-18 14:54:40 -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
5587aba58d Merge "Fix adb logcat return code." 2018-06-14 19:38:08 +00: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
Josh Gao
6082e7dafb adb: add nonblocking fd Connection.
Implement a nonblocking version of FdConnection. The initial
implementation will be somewhat slower than the blocking one for large
packet sizes, due to an extra copy when coalescing an IOVector into an
apacket, but is still substantially faster for small packets.

Test: adb_benchmark
Change-Id: I4900c9ddf685d3bd557b8cb43958452ecb23db53
2018-06-12 17:04:34 -07:00
Jiyong Park
011ee12b1d Shared libs are supported in recovery mode
adbd has been built as a static executable since the same binary was
copied to the recovery partition where shared library is not supported.
However, since we now support shared library in the recovery partition,
adbd is built as a dynamic executable.

In addition, the dependency from adbd to libdebuggerd_handler is removed
as debuggerd is handled by the dynamic linker.

A few more modules in /system/core are marked as recovery_available:
true as they are transitive dependencies of the dynamic linker.

This change also includes ld.config.recovery.txt which is the linker
config file for the recovery mode. It is installed to /etc/ld.config.txt
and contains linker namespace config for the dynamic binaries under
/sbin.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: Select 'mount /system' in the recovery mode, then `adb shell`.
$ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from
the /lib directory.

Change-Id: I363d5a787863f1677ee40afb5d5841321ddaae77
2018-06-10 08:32:24 +09: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
David Anderson
07445f4a71 adb: add remount -R for deduplicated ext4
When using "adb remount" on a deduplicated filesystem, the current
response is a warning that the remount will not work. This patch
allows the user to specify an -R option. This option will reboot to recovery,
run e2fsck to undo deduplication, and then reboot the device where "adb
remount" will then succeed.

In addition, if verity needs to be disabled to remount, it will be disabled in
the same reboot cycle to minimize reboots.

Bug: 64109868
Test: adb remount -R on a deduplicated filesystem
Change-Id: I812407499b2df6f4d2509e8d51878117108a6849
2018-05-31 15:38:25 -07:00
Josh Gao
e82401e592 Merge "adb: really fix the mac build." 2018-05-25 05:59:58 +00:00
Josh Gao
6e1246c234 adb: really fix the mac build.
Test: changed `#if !defined(__APPLE__)` to `#if 0` and ran mma
Change-Id: I173cccbfb7bad348ac4796a2d6cebb8490f63479
2018-05-24 22:58:08 -07:00
Treehugger Robot
6c9bb058c5 Merge "Build adbd for recovery" 2018-05-25 05:58:01 +00:00
Josh Gao
99c27d3e99 adb: fix mac build.
Test: none
Change-Id: I93ff87338aa503588e36404f7566651e18f50292
2018-05-24 00:47:05 -07:00
Jiyong Park
a0e75045e6 Build adbd for recovery
adbd (and its dependencies) are marked as recovery_available:true so
that recovery version of the binary is built separately from the one for
system partition. This allows us to stop copying the system version to
the recovery partition and also opens up the way to enable shared
libraries in the recovery partition. Then we can also build adbd as a
dynamic executable.

Bug: 79146551
Test: m -j adbd.recovery
Change-Id: Ib95614c7435f9d0afc02a0c7d5ae1a94e439e32a
2018-05-24 14:11:11 +09:00
Josh Gao
fd3fd937b1 adb: add benchmark script.
Test: ./benchmark_device.py
Change-Id: I9f36cc267b1cbef2d90a30009c87ccc2a8e21795
2018-05-23 11:26:04 -07:00
Josh Gao
7c738cdb53 adb: add IOVector.
An IOVector is a collection of immutable reference counted blocks which
can have its head detached at an arbitrary index. This is extremely
useful for implementing packet-framed protocols like adb on top of a
stream protocol like TCP: a stream reader can read blocks, append them
to the end of the IOVector, and then pull packets off of the front.
This also lends itself naturally towards scatter/gather I/O, which will
enable us to read data from disk and send it across the wire with a
theoretical minimum number of copies in USB, and one extra copy over
TCP.

Since this is basically a generalization of std::deque<Range>, delete
Range and replace its uses with IOVector.

Test: adb_test
Test: wine adb_test.exe
Change-Id: I06561ad0bb25a3a51b378b61d257b5b04b41d9c4
2018-05-23 11:26:04 -07:00
Josh Gao
9da1a9118b Revert "Revert "adb: add support for O_CLOEXEC to unique_fd pipe wrapper.""
Implement pipe2 ourselves on darwin.

This reverts commit f139ba47a1.

Test: none!
Change-Id: I42c2a8d07712fe4ac75b5824f754e79a5b9f5cb4
2018-05-23 11:14:57 -07:00
Josh Gao
a2157a7d92 Merge "Revert "adb: add support for O_CLOEXEC to unique_fd pipe wrapper."" 2018-05-23 16:45:31 +00:00
Josh Gao
f139ba47a1 Revert "adb: add support for O_CLOEXEC to unique_fd pipe wrapper."
This reverts commit 948b3e1068.

Reason for revert: mac doesn't have pipe2

Change-Id: Id6a517bb500cbea602839f06452bc5e6d92289f1
2018-05-23 16:44:53 +00:00
Treehugger Robot
812a6b77c6 Merge "adb: add support for O_CLOEXEC to unique_fd pipe wrapper." 2018-05-23 00:17:32 +00: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
948b3e1068 adb: add support for O_CLOEXEC to unique_fd pipe wrapper.
Change-Id: I8fd22fe55db4d3dbcbb7318cf4a364eb07323ed0
2018-05-22 14:55:36 -07:00
Josh Gao
3b37fa256f adb: convert fdevent over to unique_fd.
This adds fdsan deallocation sanitization to all fds monitored by
fdevent, which is most of the ones in adb.

Bug: http://b/79786774
Test: python test_device.py
Change-Id: I465804fdb0fd0ac019445900a30ba3403f5bf711
2018-05-22 14:55:36 -07:00
Josh Gao
ae9c1dc44a adb: move towards using unique_fd.
Bug: http://b/79786774
Test: treehugger
Change-Id: Ib5a684bba88e87e1aad9da452dcdd5edd11f18f4
2018-05-22 14:55:36 -07:00