Commit graph

2795 commits

Author SHA1 Message Date
Josh Gao
2f6c2fa935 adb: add fdevent_release.
Implement a version of fdevent_destroy that returns the file descriptor
previously owned by the fdevent, instead of closing it.

Bug: http://b/74616284
Test: treehugger
Change-Id: I6a14ac96e6b8c801bc71bfcc9094851c158510ae
2018-09-26 12:44:30 -07:00
Josh Gao
ed17650438 adb: fix test_device.FileOperationsTest.test_push_empty.
It was doing a test with `[ -d foo`, without the closing square bracket.

Test: python -m unittest test_device.FileOperationsTest.test_push_empty
Change-Id: I996b98850cf916986ef969768a7235547fcc404a
2018-09-26 12:44:30 -07:00
Josh Gao
db8b2afe23 Merge "adb: make test_device.py executable." 2018-09-26 19:43:28 +00:00
Treehugger Robot
c105f4b63a Merge "adb: remount for /system as root" 2018-09-25 20:38:01 +00:00
Treehugger Robot
37d8bbdf9c Merge "fs_mgr: init: adb: add fstab argument to fs_mgr_overlayfs_mount_all" 2018-09-25 20:37:15 +00:00
Treehugger Robot
6544056d54 Merge "Support 'adb reboot fastboot' command conditionally." 2018-09-25 17:17:08 +00:00
Mark Salyzyn
04aa426c5f adb: remount for /system as root
We can not mount overlayfs on root / as it will intercept all file
transactions.  Thus must remount /system instead.

Test: manual
Bug: 109821005
Bug: 115751838
Change-Id: Idf646b8c1ca8a0d006bf64e23a76a7e909f9162a
2018-09-25 07:30:57 -07:00
Mark Salyzyn
f35db9b11b fs_mgr: init: adb: add fstab argument to fs_mgr_overlayfs_mount_all
Add an fstab argument for fs_mgr_overlayfs_mount_all so that it can
leverage the locally and timely acquired fstab entries.  Affects all
callers, adb and init.

Test: manual
Bug: 109821005
Bug: 115751838
Change-Id: I96e2045d88525a6ce39bef63327a0fcf0704e9bc
2018-09-25 07:30:55 -07:00
Hridya Valsaraju
542582689d Support 'adb reboot fastboot' command conditionally.
Devices not supporting logical partitions do not require the command.

Bug: 78793464
Test: 'adb reboot fastboot' reboots to bootloader for a device
not supporting logical partitions.

Change-Id: I0a7b6d4335040e24efbf461e2dd2d56ab1985b7f
2018-09-25 03:52:12 +00:00
Josh Gao
caab47f513 adb: make test_device.py executable.
For symmetry with test_adb.py, since they have different interpreter
requirements now.

Test: ./test_device.py
Change-Id: I02fe659a7216a619383661c8019d356f9ccfb34d
2018-09-20 17:55:37 -07:00
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