Commit graph

2947 commits

Author SHA1 Message Date
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
Josh Gao
e5353021ba adb: delete FDEVENT_DONTCLOSE.
The only existing usage of this doesn't actually need it.

Bug: http://b/79786774
Test: mma
Change-Id: If5e665705393e938cfdbf1526beb5496a8b99a9b
2018-05-22 14:55:36 -07: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
Treehugger Robot
2fa9770c3a Merge changes I4d6da40d,I91c7ced5,I7b9f6d18
* changes:
  adb: Add a test for emulator connection
  adb: Improve test_adb a bit more
  adb: Add a way to reconnect TCP transports
2018-05-21 22:37:21 +00:00
Treehugger Robot
93e4501611 Merge "adb: Retry io in case of interrupt" 2018-05-17 01:17:11 +00:00
Treehugger Robot
adf07c5428 Merge "adb: Move io_setup to usb_handle init" 2018-05-16 23:25:15 +00:00
Luis Hector Chavez
3255974169 adb: Add a test for emulator connection
This should prevent regressions in the future.

Bug: 78991667
Test: python system/core/adb/test_adb.py
Change-Id: I4d6da40da82c6d79797cec82ffaf071d4b56ddc7
2018-05-16 15:20:48 -07:00
Luis Hector Chavez
fbee0a9133 adb: Improve test_adb a bit more
This change:

* uses unittest.main(), which allows for a subset of the tests to be
  selected.
* drops the requirement to have a device already connected since all the
  tests that need a device now spin their own mock device.
* Splits the monolithic test class into more granular classes.
* Makes this file be pylint-compliant.

Bug: None
Test: python system/core/adb/test_adb.py
Test: pylint system/core/adb/test_adb.py
Change-Id: I91c7ced520c3c69f855d639e0dbf7e57bb690e97
2018-05-16 15:20:48 -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
Jerry Zhang
d8c1ae910f adb: Move io_setup to usb_handle init
Remove some redundancy by moving io_setup
into aio_block_init. The io_contexts will
now live till the end of the program, similar
to the rest of usb_handle

Test: adb works
Bug: 78793464
Change-Id: I910a39d4395645f1ff231f265c285a72893a0ac6
2018-05-16 21:47:11 +00:00
Jerry Zhang
5ba6802e9a adb: Retry io in case of interrupt
io_submit sleeps waiting for the gadget
to be enabled. Currently if that sleep
is interrupted it will shut down adb,
causing it to have to start back up again.

Rather than return EINTR if interrupted,
io_submit actually completes and the EINTR
is found later when looking through events.
Since an io that is interrupted will be
small anyway, add a loop to retry small ios.

Also upgrade aio logs in accordance with
their importance.

Fixes: 75981904
Test: adb works, logs show successful interrupt handling
Change-Id: I35973fce130ee849ce59fef80d15b65afb816ba4
(cherry picked from commit 6e9a327504)
2018-05-16 21:44:46 +00:00
David Anderson
570426aadd adb: warn on remount if undoing deduplication is impossible
A deduplicated filesystem might not have enough free space to undo its
block sharing. In this case "adb remount" should give a more precise
error message.

Bug: 64109868
Test: adb remount on deduplicated filesystem with no free space
Change-Id: I2beb67aa3dfc807cb8493b9c622e7b14174dc9c6
2018-05-16 14:18:59 -07:00
Josh Gao
2744084981 adb: fix uninitialized variable in AsyncServiceRef.
Bug: none
Test: treehugger
Change-Id: I8ba0a70a772f88bfd701730a48d4eb32c6677b9e
2018-05-15 23:43:50 -07:00
Treehugger Robot
da6ab73420 Merge "adb: fix double close in jdwp_service." 2018-05-15 01:52:29 +00:00
Josh Gao
b7a9956cbc adb: fix double close in jdwp_service.
Bug: http://b/78793027
Test: treehugger
Change-Id: Ie66d12e70bdaf09148e3d672e3c7c3da9e8ab2fe
2018-05-14 17:13:47 -07:00
Treehugger Robot
313aa7172f Merge "adb: better error messages on deduplicated filesystems." 2018-05-14 21:10:34 +00:00
David Anderson
a962ec0c73 adb: better error messages on deduplicated filesystems.
If BOARD_EXT4_SHARE_DUP_BLOCKS is true, "adb remount" will error saying
the filesystem is read-only. Instead, it will now list affected
partitions and explain why they can't be remounted.

Bug: 64109868
Test: adb remount with deduplicated system image
Change-Id: Ida737a6be8e9fe9ea26300897d82b1a149e72f6d
2018-05-11 13:20:31 -07:00
Josh Gao
c97cea0d20 Merge "adb: add authorizing, connecting states to transport." 2018-05-09 20:43:31 +00:00
android-build-prod (mdb)
53248e47f4 Merge "Documented adb install --instant" 2018-05-09 18:23:11 +00:00
Felipe Leme
807be77c25 Documented adb install --instant
Test: m -j32 adb && ./out/host/linux-x86/bin/adb help 2>&1 | grep instant
Bug: 79422318

Change-Id: I2830a9e3cf81becac1a6334670d8dc487fe72322
2018-05-09 09:33:38 -07:00
Dan Willemsen
3e41f92cf5 Remove unused tags property from Android.bp files
The tags property is (and has always been) unused by Soong. The property has
been defined as a list of strings, and the `androidmk` converted any
LOCAL_MODULE_TAGS entries over to it, but we've never done anything with it.

In preparation for removing the definition from Soong, I'm removing it from all
Android.bp files in the tree.

Since this has never done anything, this is a no-op, but if you really did want
the Android.mk behavior, the proper way to define a module to be installed in
userdebug / eng builds is to use PRODUCT_PACKAGES_DEBUG or PRODUCT_PACKAGES_ENG
in the appropriate product makefile.

Change-Id: Id519b2c0ec352e45c470a1734dfc633bbe39937e
Exempt-From-Owner-Approval: global no-op build change
Test: remove `tags` from Soong, see errors go away.
2018-05-08 17:15:23 -07:00
Josh Gao
704494b070 adb: add authorizing, connecting states to transport.
Add two states: connecting and authorizing, to disambiguate the offline
and unauthorized states, respectively.

Previously, devices would transition as follows:

  offline -> unauthorized -> offline -> online
  offline -> unauthorized (when actually unauthorized)

With this patch:

  connecting -> authorizing -> online
  connecting -> authorizing -> unauthorized (when actually unauthorized)

This allows test automation and the like to distinguish between offline
devices, unauthorized devices, and working devices without having to
do retry loops with arbitrary sleeps on their end.

Bug: http://b/79257434
Test: adb_test
Test: adbd_test
Test: manually plugging in a device with `while true; do adb shell echo foo; done`
Change-Id: I036d9b593b51a27a59ac3fc57da966fd52658567
2018-05-04 18:05:18 -07:00
Luis Hector Chavez
c587f02cc6 adb: Avoid waiting for emulator connections
This change exempts the emulator connections from
WaitableConnection.WaitForConnection(). This is because emulator
connections are a) more reliable and b) handled a bit differently than
normal TCP connections.

Bug: 78991667
Test: emulator -showkernel ; adb shell
Change-Id: I552946198889a82d6c265f45e8c3b38f6ac9d045
2018-05-01 17:12:16 -07:00
Elliott Hughes
4e6f3d9603 Merge "Add test_suites lines." 2018-04-28 16:02:40 +00:00
Elliott Hughes
40fdf3f4ab Add test_suites lines.
Bug: N/A
Test: builds
Change-Id: Ic5e2b9206bcfcb53c774989013b5db6aab462e42
2018-04-27 16:12:06 -07:00
Luis Hector Chavez
9a388d5387 adb: Make the Connection object a std::shared_ptr
This change is in preparation to allow the TCP-based transports to be
able to reconnect. This is needed because multiple threads can access
the Connection object. It used to be safe to do because one instance of
atransport would have the same Connection instance throughout its
lifetime, but now it is possible to replace the Connection instance,
which could cause threads that were attempting to Write to an
atransport* to use-after-free the Connection instance.

Bug: 74411879
Test: system/core/adb/test_adb.py
Change-Id: I4f092be11b2095088a9a9de2c0386086814d37ce
2018-04-26 13:53:35 -07:00
Luis Hector Chavez
56fe753070 adb: Add a way to distinguish between connection failures and successes
This change adds a callback that is invoked exactly once, either when
the connection is fully established (i.e. CNXN packets have been sent
and received) or the atransport object is deleted before that (because
the connection failed).

This helps in distinguishing between successful and failing connections
for TCP. Especially when there is some kind of port
forwarding/multiplexing in between (like an SSH tunnel or SSLH proxy).

Bug: 74411879
Test: adb connect chromebook:22 (which runs an sslh tunnel to adbd).
      either succeeds or fails, but not fake-succeeds.

Change-Id: I7e826c6f5d4c30338a03b2d376a857ac5d05672a
2018-04-26 13:53:35 -07:00
Treehugger Robot
c4ad6b6adc Merge changes I722d2c41,Ic216ddef
* changes:
  Improve test_adb.py
  adb: Distinguish betwen already-connected and connection failure
2018-04-20 02:13:09 +00:00
Treehugger Robot
224d965be0 Merge "adb: don't error in handle_host_request if we can't acquire a transport." 2018-04-19 21:40:57 +00:00
Josh Gao
78f133d7d4 adb: don't error in handle_host_request if we can't acquire a transport.
Host services are attempted after handle_host_request, which means that
failing to find a transport to give to handle_forward_request shouldn't
send an error over to the other end.

Bug: http://b/78294734
Test: `adb track-devices` with multiple devices connected
Change-Id: I46c89cc1894b51d48fea7d4e629b1d57f73e3fd6
2018-04-19 13:09:18 -07:00
Luis Hector Chavez
8b67c52099 Improve test_adb.py
This change uses a context manager to create the fake ADB servers (and
cleanly tear them down.

Bug: 74411879
Test: python system/core/adb/test_adb.py

Change-Id: I722d2c4135259b1b0ef00a1510aa8402e87ecf72
2018-04-17 21:49:43 -07:00
Luis Hector Chavez
5d39585255 adb: Distinguish betwen already-connected and connection failure
This change returns a different value (-EALREADY) when a connection has
already been established, as opposed to a real connection failure (which
still returns -1).

Bug: 74411879
Test: Opened a socket, tried to adb connect to it,
      got "failed to connect to localhost:1337"

Change-Id: Ic216ddef7f28eb43ca750f9e51d068c077d54b07
2018-04-17 14:36:33 -07:00
Elliott Hughes
77561c1f28 Remove out of date comment.
Bug: https://code.google.com/p/android/issues/detail?id=189821
Test: N/A
Change-Id: I25e64611d0c2db75a9caf0f19e7dd17c725d98a1
2018-04-16 15:22:33 -07:00
Josh Gao
44899eeb53 adb: fix adb reverse when adbd has multiple transports.
Plumb the transport that we received the adb reverse request on through
to reverse_service, instead of trying to get a unique transport on
devices that have multiple active transports (e.g. a device with USB
(even unplugged) connected via TCP).

Bug: http://b/37066218
Bug: http://b/71898863
Test: `echo foo | nc -l 12345 & adb reverse tcp:12345 tcp:12345; adb shell nc localhost 12345` on a device connected via TCP
Change-Id: Iae199ae787f2e344126bbcacca8544cfc9844a4c
2018-04-13 14:25:28 -07:00
Josh Gao
2e93df2e14 adb: win32: cleanup winsock initialization.
Instead of doing it in 3 arbitrary functions, do it at startup always.

Test: wine adb_test.exe
Change-Id: Ida272d218aee6c331471250edce64d512d3b628a
2018-04-11 12:54:38 -07:00
Josh Gao
011ba4b9bf adb: win32: properly set EBADF in some functions.
Test: treehugger
Change-Id: If3f29f9ee586e29652e9709b3f594a1376ed4bb3
2018-04-11 12:54:38 -07:00
Josh Gao
64a63acba9 adb: partially clang-format sysdeps_win32.cpp.
clang-format some functions that I'm about to touch, but do it in a
separate commit to avoid making the actual changes unreadable.

Test: treehugger
Change-Id: I7dc5258d9ecc1c091d42311149d9e18ae483715b
2018-04-11 12:54:38 -07:00
Josh Gao
116aa0a4ad adb: implement adb_writev.
Change-Id: I55258c155d7b07368ebb45577b2e01ca804cf258
Test: adb_test
Test: python test_device.py
2018-04-11 12:54:36 -07:00
Josh Gao
1ce99576f0 adb: switch apacket payload to a type that doesn't initialize its contents.
Switch from using std::string as the type we use to hold our payload in
apacket to a custom reimplementation that doesn't zero initialize. This
improves bulk transfer throughput in the adb_benchmark microbenchmark
on walleye by ~20%.

Test: adb shell taskset f0 /data/benchmarktest64/adb_benchmark/adb_benchmark
Change-Id: Ibad797701eb1460c9321b0400c5b167b89b2b4d0
2018-04-11 12:54:07 -07:00
Treehugger Robot
ee63d74b6c Merge "adb: properly calculate packet size on Mac." 2018-04-11 00:27:36 +00:00
Josh Gao
2ea46521f3 adb: properly calculate packet size on Mac.
OS X reports maxPacketSize as wMaxPacketSize * (bMaxBurst + 1) in the
deprecated GetPipeProperties function. Use the also-deprecated
GetPipePropetiesV2 API to get bMaxBurst and figure out what
wMaxPacketSize is. (This file is going to go away eventually, so don't
bother with switching to the recommended GetPipePropertiesV3, since
it would be a substantially larger charge.)

libusb is unaffected.

Bug: http://b/77733422
Test: python test_device.py
Change-Id: I66517d699a4f39b93ba5eb7882bd8ee6c70f3672
2018-04-10 14:46:34 -07:00
Elliott Hughes
6eb9248cb3 Merge "Support /odm and /product in "adb remount" and "adb sync"." 2018-04-06 01:16:04 +00:00
Luis Hector Chavez
daacf4f6f3 adb: Correctly drop caps when ambient capabilities are used
This change splits the capability-dropping step of adbd into two. This
is more robust when ambient capabilities are being used, since minijail
cannot currently handle that case.

Bug: 77146512
Test: grep Cap /proc/`pidof adbd`/status
      CapInh: 0000000000000000
      CapPrm: 0000000000000000
      CapEff: 0000000000000000
      CapBnd: 00000000000000c0
      CapAmb: 0000000000000000

Change-Id: I0476a8d80f7a2497600196932542045f3bc87537
2018-04-05 15:34:05 -07:00
Treehugger Robot
fa1f191ad9 Merge "adbd: configure jemalloc to not immediately purge." 2018-04-05 22:14:05 +00:00
Josh Gao
218f766e21 adbd: configure jemalloc to not immediately purge.
Profiling of adb_benchmark revealed that something like half of the CPU
time was being spent in malloc and free, which was odd because the
benchmark repeatedly mallocs and frees allocations of the same size. It
turns out that our default configuration of jemalloc will purge after
every free. Configure jemalloc to not do this, for gains of over 100%
on adb_benchmark, and up to 25% (on walleye USB3) in real-life.

Test: adb_benchmark
Change-Id: I602dd1645c3d21709c7f6a78903511ce4d576558
2018-04-05 15:13:30 -07:00
Treehugger Robot
8daf742900 Merge "Revert "Revert "adb: add transport benchmark.""" 2018-04-05 01:49:38 +00:00
Josh Gao
9c59649e0b Revert "Revert "adb: add transport benchmark.""
This reverts commit 2ef56a1174.

host_supported is broken in cc_benchmark on Mac, but we probably don't
actually too much about the host benchmarks, so just delete the line.

Bug: http://b/77585931
Test: treehugger
Change-Id: I8898b4037a3faf8e8dee2a99498a6f84e642b92b
2018-04-04 14:26:39 -07:00
Elliott Hughes
57e97cb7aa Support /odm and /product in "adb remount" and "adb sync".
Bug: http://b/77587036
Test: `adb remount` and `adb sync` still work on hikey
Change-Id: I960ae75099edf147f857a67d906b6bc133f817a7
2018-04-04 13:14:59 -07:00
Elliott Hughes
9c8c03896e Merge "Move adb/fastboot bash completion into adb/fastboot." 2018-04-04 19:44:37 +00:00
Elliott Hughes
fbfa0e8781 Move adb/fastboot bash completion into adb/fastboot.
Bug: http://b/74443706
Test: bash completion still works.
Change-Id: I9da3a0ae748a202407652f513c990e9d05f8b01a
2018-04-04 08:33:33 -07:00
David Brazdil
3876e37319 Merge "Revert "adb: add transport benchmark."" 2018-04-04 11:42:39 +00:00
David Brazdil
2ef56a1174 Revert "adb: add transport benchmark."
This reverts commit d78f59ca53.

Reason for revert: Breaks aosp-master renderscript and sdk_mac:
  error: system/core/adb/Android.bp:199:19: unrecognized property "host_supported"

Change-Id: Ifd75921dcdf5dce57f98833a913540914984b293
2018-04-04 10:32:08 +00:00
Josh Gao
3f6ef0d2d2 Merge "adb: add transport benchmark." 2018-04-04 07:02:07 +00:00
Josh Gao
d78f59ca53 adb: add transport benchmark.
Add some basic benchmarks for the underlying transport.

Test: adb_benchmark
Change-Id: I6475a66eb5a43a241c907046c23fea68263db945
2018-04-03 16:54:51 -07:00
Josh Gao
c251ec55d3 adb: don't abort when connecting to the same address twice.
When connecting to an address, we construct a transport first, and then
check whether we've already connected to that address. The consequent
destruction of the BlockingConnectionAdapter attempts to join threads
that haven't been started, which aborts.

Make it safe to destruct a BlockingConnectionAdapter without calling
Start on it first, to solve this.

Bug: http://b/69137547
Test: nc -l 12345 & (adb connect localhost:12345; adb connect localhost:12345)
Test: python test_adb.py
Change-Id: I6cb968a62dbac6332907e06575893d764905ee62
2018-04-03 13:58:21 -07:00
Josh Gao
7651eb9ef7 adb: try harder to fill our test sockets.
On platforms that implement sockets via underlying sockets (e.g. Wine),
a socket can appear to be full, and then become available for writes
again without read being called on the other end. Add a sleep after
each write to give the underlying implementation time to flush.

This doesn't help us if the buffer size is smaller than MAX_PAYLOAD,
but at least in the case of Wine, that doesn't seem to be the case.

Test: adb_test
Test: wine adb_test.exe
Change-Id: Iff1ec14bbf318b9742ec7e2fb72e34e3d6bbe6ad
2018-04-02 14:18:50 -07:00
Josh Gao
954e1280d7 adb: don't set has_write_error on success.
Whoops.

Test: adb_test
Change-Id: I32123c51446a22d4423eef0753b0a0b00b500a90
2018-04-02 14:18:27 -07:00
Josh Gao
7ab55713cc adb: move ownership of the fdevent thread into FdeventTest.
Previously, each of the tests was spawning the fdevent thread manually,
in order to be able to set up listeners and such before running
fdevent_loop. Now that we have a way to run arbitrary code on the
fdevent thread, switch to having a generic fdevent thread and running
setup code via fdevent_run_on_main_thread.

Test: adb_test
Test: wine adb_test.exe
Change-Id: I517dbcbad31067b45087d9fbed67a75b75a75aec
2018-03-30 14:57:09 -07:00
Josh Gao
fa30bf3932 adb: guarantee that fdevent_run_on_main_thread happens last.
Make it so that we handle run_on_main_thread calls after regular socket
events, so that we can use it as a way to ensure we've processed all
pending socket events.

Test: adb_test
Test: wine adb_test.exe
Change-Id: Ic215c7fed19a8e1699e759970658b3775aa08c45
2018-03-30 14:38:25 -07:00
Josh Gao
05fb45be17 adb: fix FdeventTest.invalid_fd on Windows.
Bail out immediately in our poll emulation if we have any invalid file
descriptors, instead of actually calling WSAPoll (which might block
forever).

Test: wine adb_test.exe
Change-Id: I06ccca305783ee7a1721b1585ddf73e022bd02d7
2018-03-29 14:24:03 -07:00
Josh Gao
fd7486fb42 adb: extract the sleep in socket_test to its own function.
Make it easier to replace the sleep with something that actually waits
for the event loop to quiesce.

Test: adb_test
Change-Id: Iee86b058abbb607256dbfce43d8c70252b6bb0f6
2018-03-29 13:21:58 -07:00
Josh Gao
31ed2a5c04 Merge "adbd: spawn login shell when run without a command." 2018-03-29 20:19:27 +00:00
Josh Gao
db9671090d Merge "adbd: increase oom_score_adj for adb shell" 2018-03-29 20:19:03 +00:00
Josh Gao
8043633922 Merge "adb: restore adb/adb.exe in the list of artifacts." 2018-03-29 20:18:58 +00:00
Josh Gao
2de2ade387 adbd: increase oom_score_adj for adb shell
Previously, processes started via `adb shell` have an oom_score_adj of
-1000, making them invisible to the oom killer. This makes running a
process that consumes all memory (e.g. by leaking in a loop) lead to
the entire rest of the system (including adbd, because of bad
heuristics in the kernel) being oom killed before getting to it.

Bug: http://b/63143027
Test: `adb shell cat /proc/self/oom_score_adj` with adb root
Change-Id: I59111134e36dc271adf4c1dd4bd4400d4fe6aee0
2018-03-28 15:01:23 -07:00
Treehugger Robot
45562bfb63 Merge changes Iea2a3055,I6582cfc6
* changes:
  adb: start building windows test again.
  adb: fix windows test build.
2018-03-28 21:59:33 +00:00
Josh Gao
541a8656c4 adb: restore adb/adb.exe in the list of artifacts.
Test: m dist
Change-Id: Iba44a03e79af9242bfe36efb736496f8db720ebf
2018-03-28 12:57:48 -07:00
Treehugger Robot
f78ff013d0 Merge "adb: Open FunctionFS files with more restrictive access modes" 2018-03-26 18:48:25 +00:00
Josh Gao
f8a97c1f14 adb: start building windows test again.
Test: mma
Change-Id: Iea2a3055cc3642905a1bbdd18550a9fc12702da8
2018-03-23 15:37:20 -07:00
Josh Gao
2e1e789e2a adb: fix windows test build.
The switch over to soong unintentionally turned off building the
Windows tests (and there's a bug preventing them from being turned on).
Preemptively fix the build breakages that'll happen when we turn them
back on.

Test: mma with Android.bp 's/cc_test_host/cc_binary_host' hacks
Change-Id: I6582cfc61b96052537d50d8ba90533dbb66e3e1d
2018-03-23 13:03:28 -07:00
Josh Gao
8f7ff94762 adbd: spawn login shell when run without a command.
Match openssh's behavior with regards to login shells.

Bug: http://b/76116378
Test: `adb shell -T set -o` vs `ssh localhost -T set -o`
Test: `adb shell -tt set -o` vs `ssh localhost -tt set -o`
Test: `echo set -o | adb shell -T` vs `echo set -o | ssh localhost -T`
Test: `echo set -o | adb shell -tt` vs `echo set -o | ssh localhost -tt`
Change-Id: I6ed69b43e2ac79c947c242948b5617ece08a713e
2018-03-21 18:23:09 -07:00
Josh Gao
bf243a6128 adb: bump the local socket backlog to the maximum.
The listen backlog seems to be more meaningful on Darwin than on Linux,
resulting in connections failing with ECONNRESET. Bump it up to the
maximum supported value to make this less likely. 128 pending
connections ought to be enough for anybody.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: I5fe0205924188cf18ca1fc1204f923ab5523eeb2
2018-03-21 15:13:07 -07:00
Josh Gao
2c621ae741 adb: fix unicode file path test.
This test is failing due to:

     UnicodeWarning: Unicode equal comparison failed to convert both
     arguments to Unicode - interpreting them as being unequal'

Both arguments are already unicode, so stop encoding one side.

Test: python -m unittest test_device.FileOperationsTest.test_unicode_paths
Change-Id: Iea8bf29845ab3008ccf4c7dbd6969196e57ea25d
2018-03-21 15:13:07 -07:00
Josh Gao
dcc055af64 adb: delete vestigial SHELL_EXIT_NOTIFY_FD.
There exists no path through which a value other than -1 can be written
to the SHELL_EXIT_NOTIFY_FD.

Test: adb_test
Test: adbd_test
Test: python test_device.py
Change-Id: I0630c302ba06bc76917f0445aea75d2dbe1dc865
2018-03-21 15:13:07 -07:00
Josh Gao
184f480547 adb: don't immediately close a socket when write fails.
When we fail to write to a local socket peer, we might still have data
queued up to send to the other side. Defer closing the socket until
we've failed to both read and write.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: Ifc4b8fe95369b4872e475c2ae4ee611dd2d8b9d7
2018-03-21 15:13:07 -07:00
Josh Gao
1222abc75b adb: make fdevent_run_on_main_thread's fd nonblocking.
If we get a ton of fdevent_run_on_main_thread calls while running one
of the handlers, the socket might become full, which will result in a
deadlock in fdevent_run_on_main_thread when a write to the fd blocks
with the mutex taken. Resolve this by making the fd nonblocking, which
is safe because we always write after appending to the list, and read
before emptying the list, which guarantees that if the byte we write is
consumed, the std::function we appended will be run.

Bug: http://b/74616284
Test: adb_test
Test: python test_device.py
Change-Id: I29319bda2ad7b5a5cdcd91d1d0ddf39f7ab7d115
2018-03-20 13:23:06 -07:00
Josh Gao
7920502065 Merge changes I6a842960,If618c26b
* changes:
  adb: add `adb shell exit 42` stress test.
  adb: improve socket tests.
2018-03-20 07:19:01 +00:00
Josh Gao
4abb5074be adb: skip IPv6 test if IPv6 isn't available.
Bug: http://b/69813298
Test: none
Change-Id: I0793e793bd52c5f1c639faedf09a513df263db78
2018-03-19 18:19:47 -07:00
Josh Gao
c970aefada adb: add adb shell exit 42 stress test.
Add a test to hammer on `adb shell exit $n` for flakiness.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: I6a842960f5b55ff739044698f5c9683992fc42f1
2018-03-19 16:14:53 -07:00
Josh Gao
ecb96ac04d adb: improve socket tests.
Make it so that the socket tests don't leak until your machine blows up
by switching an infinite loop into an assertion failure.

Bug: http://b/74616284
Test: adb_test
Change-Id: If618c26b224b660548454f542cab79bebe46f80e
2018-03-19 16:14:53 -07:00
Treehugger Robot
6156420fb7 Merge changes I99b85f07,If28f6c8d
* changes:
  adb: implement std::make_unique, start using it.
  base: export GetThreadId.
2018-03-19 20:14:33 +00:00
Josh Gao
31b5be69f4 adb: implement std::make_unique, start using it.
Add an implementation of std::make_unique for Windows, where we're
currently stuck with C++11, and switch some uses of new over to it.

Test: treehugger
Change-Id: I99b85f07754adda7c525243480c3e0bce9a25ce7
2018-03-16 15:35:52 -07:00
Josh Gao
5791e21697 base: export GetThreadId.
and stop using the incorrect (on Mac) version in adb..

Test: mma
Change-Id: If28f6c8d73b03db863be13ed88df81422c3aef87
2018-03-16 15:35:52 -07:00
Jerry Zhang
99499f1740 adb: Remove usages of ENDPOINT_ALLOC
All devices that previously used ENDPOINT_ALLOC
are on the new async io routines. None of the devices
using aio_compat have ENDPOINT_ALLOC so remove the
code to stop logging failures.

Fixes: 74213465
Test: adb works
Change-Id: I0c903eb76b006b6bcce48cec24f5353fa47cc128
(cherry picked from commit 9a1be3ad0e)
2018-03-16 15:33:26 -07:00
Josh Gao
32caa9870f Merge "adb: add test for flushing socket data after a write failure." 2018-03-16 22:18:43 +00:00
Josh Gao
df3bae9f06 adb: add test for flushing socket data after a write failure.
Add a currently failing test that's a reduced case of the 'concurrent
adb shell' flakiness reported in b/74616284.

Bug: http://b/74616284
Test: changed #if 0 to #if 1, test fails
Change-Id: Id170a185f7c5d2ff44f772f7849a73227f9df441
2018-03-15 15:33:01 -07:00
Bowgo Tsai
8cc9c3835a adb: checks device state when using adb disable-verity for AVB
adb disable-verity will toggle a flag in /vbmeta and introduce AVB
verification error on next boot. If the device is LOCKED, it will make
the device unbootable because verification error isn't allowed when the
device is locked.

Also indicating 'adb root' when failed to get verity state.

Bug: 70969453
Test: adb disable-verity should pop-up warning if the device is locked.

Change-Id: I1ed705e34334ea2231c96b16ddb8d225067af2f0
2018-03-15 18:34:42 +08:00
Luis Hector Chavez
3a3df404b4 adb: Open FunctionFS files with more restrictive access modes
This change opens the control, bulk-in, and bulk-out FunctionFS
endpoints with O_RDONLY or O_WRONLY.

Bug: 70349025
Test: Android on Chrome OS can still use ADB
Test: aosp_sailfish-userdebug can still use ADB

Change-Id: I3895b626cf7cec8437c36bdc6c6e6055aaf3777c
2018-03-09 11:11:24 -08:00
Josh Gao
6eda1840cb adbd: don't require authentication for userdebug/eng builds.
By default, the build system only sets ro.adb.secure (to 1) when
building user builds.

Bug: http://b/73993211
Bug: http://b/74059119
Test: treehugger
Change-Id: I2a683257c1027394ded90c8d2634def6003e0525
2018-03-06 13:37:45 -08:00
Josh Gao
8db99f810d adbd: make static.
adbd is copied into the recovery image without the accompanying
linker/libraries, so it must be a static executable.

Bug: http://b/74237641
Test: `file $ANDROID_PRODUCT_OUT/system/bin/adbd`
Change-Id: Ie8d0710f6002458519d3eea3d696e9016faafee8
2018-03-06 13:01:34 -08:00
Jerry Zhang
5180d5b4dc Merge "Make libasyncio headers usable from C" 2018-03-06 19:35:21 +00:00
Josh Gao
9ee373ac2c Merge changes from topic "adb_bp"
* changes:
  adb: remove meaningless const.
  adb: convert Connection to a nonblocking interface.
  adb: use soong version stamping.
  adb: switch over to Android.bp.
2018-03-05 23:45:27 +00:00
Josh Gao
ffbd3364a4 adb: remove meaningless const.
Returning a const value is pointless.

Test: mma
Change-Id: Ia578d75345361d53e4a29bb9724bfcc161b8d8be
2018-03-05 13:00:28 -08:00
Josh Gao
0bbf69cbbf adb: convert Connection to a nonblocking interface.
Rename the existing Connection to BlockingConnection, add a nonblocking
Connection, and add an adapter between the two, to enable future work
to reduce the impedance mismatch from implementing a blocking interface
on top of nonblocking primitives.

While we're here, delete A_SYNC, and remove one layer of pipes when
sending a packet (replacing it with a condition variable when using
BlockingConnectionAdapter).

Test: python test_device.py, manually plugging/unplugging devices
Change-Id: Ieac2bf937471d9d494075575f07e53b589aba20a
2018-03-05 13:00:28 -08:00
Josh Gao
c7567fa52e adb: use soong version stamping.
Bug: http://b/71719137
Test: adb version
Change-Id: Ic735814574c83a7c2b8bef213592d494f5ec3860
2018-03-05 13:00:08 -08:00
Jerry Zhang
c3d4e7226a Make libasyncio headers usable from C
This allows us to enable LTP tests
for io_* syscalls.

Bug: 31152298
Test: LTP tests pass
Change-Id: Ic25189d8bf25cdacfa0f144ac57c7b2827adcd9f
2018-03-02 16:28:15 -08:00
George Burgess IV
657db00e3d Add a NOLINT for the memory leak we added
Added by I7255d45335fa009dc9e5de99dff67af52bd70e06

Bug: None
Test: Ran the analyzer. Complaint is gone.
Change-Id: Id9b8debd8b9690210f5a8e19154ee3a5095b8fbd
2018-03-01 18:59:50 +00:00
Josh Gao
2776845aa5 adb: switch over to Android.bp.
Rearrange some files while we're doing this.

Bug: http://b/71721338
Test: manually ran adb on windows
Change-Id: Ie47bda82279e4b9521505ad0353bf9ef649fc7d7
2018-02-28 15:29:50 -08:00
Josh Gao
e2176118f4 adb: add a way to make the server intentionally leak.
Add a way to test LeakSanitizer with the server by adding an
environment variable that intentionally leaks.

Test: ASAN_OPTIONS=detect_leaks=1:leak_check_at_exit=1 ADB_LEAK=1 adb server nodaemon
Change-Id: I7255d45335fa009dc9e5de99dff67af52bd70e06
2018-02-28 14:16:14 -08:00
Treehugger Robot
d24c8484c8 Merge "Change the remount command to be more container-friendly" 2018-02-28 16:48:37 +00:00
Josh Gao
e39ccd3cbd adb: allow reentrant calls to fdevent_run_on_main_thread.
Previously, reentrant calls to fdevent_run_on_main_thread would
deadlock.

Test: adb_test on host
Change-Id: I0783be0558dcaf61ddbe76d13ac6917fc2de0be0
2018-02-27 14:50:07 -08:00
Josh Gao
d51c6df1ef adb: stop using quick_exit.
We don't actually need to use quick_exit to avoid calling static
destructors, since we have -Wexit-time-destructors to guarantee we
don't actually have any, and this precludes the use of asan's exit time
leak checking, so switch back to atexit/exit.

Test: ASAN_OPTIONS=detect_leaks=1:leak_check_at_exit=1 adb server nodaemon with a manually inserted leak
Change-Id: Id8178913f64cb02c820c5073351369a9e4d8c74d
2018-02-27 14:50:07 -08:00
Luis Hector Chavez
0db4b7a95b Change the remount command to be more container-friendly
Passing in MS_REMOUNT | MS_BIND tells the kernel to only remove the
MS_RDONLY flag and keep all the other flags the same. This is also the
only kind of remount that is allowed in Linux containers (to be more
precise, within user namespaces).

This change also attempts to always run the remount command when dealing
with /, since containers will almost always run a loop device, and since
the number of the device changes, it is not convenient to put it in the
fstab. Plus, the container won't have permission to modify it, but might
be able to perform the remount.

Bug: 72178046
Test: `adb remount` works in both sailfish and Chrome OS
Change-Id: I9e8ec8afcd57f67875a312824667768b3aa89faa
2018-02-27 14:37:26 -08:00
Josh Gao
f571fcbe87 adb: switch apacket over to a std::string payload.
Test: python test_device.py with walleye/x86_64 emulator
Change-Id: I0a18941af1cb2279e5019a24ace25741def1202f
2018-02-21 14:30:17 -08:00
Treehugger Robot
0609e8d231 Merge "bpfmt." 2018-02-20 02:02:59 +00:00
George Burgess IV
cb2449f851 Fix a memory leak
If create_service_thread fails, we'll leak `arg`.

This fixes a static analyzer complaint:
system/core/adb/services.cpp:298:13: warning: Potential leak of memory
pointed to by 'arg'

Bug: None
Test: Reran the static analyzer. No more complaints about this leak.
Change-Id: I5aec7fd78f2cc775b650501b02bdf0039d1647ca
2018-02-19 01:05:56 -08:00
Elliott Hughes
dc699a269f bpfmt.
Bug: N/A
Test: builds
Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
2018-02-16 17:58:14 -08:00
Treehugger Robot
d31df3a1be Merge "adbd: receive jdwp pids from art as raw integers." 2018-02-13 23:34:49 +00:00
Josh Gao
1b58bbf2ef adb: fix build breakage.
Test: mma
Change-Id: Id8e7ffd2212449bbac5b64b50e7b3aef7e97d649
2018-02-12 18:03:49 -08:00
Josh Gao
e0361d1e90 adb: use delete on objects with destructors.
asocket has a destructor now, so we have to delete it, or leak the
data pointed to by its std::string.

Bug: http://b/73257049
Test: manual testing with asan
Change-Id: Ia88199292cc74e10032a9a16226d3afc61c3e0be
2018-02-12 17:31:39 -08:00
Josh Gao
86f39b4078 adbd: receive jdwp pids from art as raw integers.
Don't go through a pointless conversion to hex that reduces our maximum
pid to 64k.

Bug: http://b/17661822
Test: `adb jdwp`
Change-Id: Idd572eac827f3ed3825ac2cf55fc4db109e70854
2018-02-12 15:07:28 -08:00
Josh Gao
9bf624cd3a Merge "adb: switch asocket::enqueue to std::string." 2018-02-08 01:06:22 +00:00
Josh Gao
f99711fe87 Merge changes I86bcfaaa,I24d7f5d0
* changes:
  adb: restore packet data length checks.
  adb: switch asocket's intrusive linked list to vectors.
2018-02-08 00:34:40 +00:00
Josh Gao
95c4497bd4 adb: don't spew to logcat when tracing is enabled.
When persist.adb.trace_mask is used to enable verbose logging, avoid
exponential logging when a user runs `adb logcat`. As a side-effect,
set the minimum logging level to include everything when ADB_TRACE is
used on the client (which is something we want anyway).

Bug: http://b/72971016
Test: `adb shell 'setprop persist.adb.trace_mask; killall adbd'; adb logcat`
Change-Id: Id4bca1f3933a920345499dbeaeb103c8a2e220cd
2018-02-06 15:55:06 -08:00
Josh Gao
27cb7dca77 adb: switch asocket::enqueue to std::string.
Switch asocket over to taking a std::string instead of apacket* for
data. This allows us to remove asocket specific fields from apacket*.

Test: python test_device.py with x86_64 emulator, walleye
Test: adb_test on host
Change-Id: I9d157ff331a75ba49a54fdd4194e3f6cdff722f4
2018-02-06 12:59:06 -08:00
Josh Gao
5caaebdc3d adb: restore packet data length checks.
These checks were moved to after the read of the payload, which is too
late. Add a check before each read to avoid a heap buffer overflow.

Test: python test_device.py with x86_64 emulator, walleye
Change-Id: I86bcfaaa9004951cc52ad89af74680cf748e717d
2018-02-06 12:59:06 -08:00
Josh Gao
5e5076404a adb: switch asocket's intrusive linked list to vectors.
Test: python test_device.py
Change-Id: I24d7f5d0401de77d80c7a2dd5a7dcb551943342d
2018-02-06 12:59:06 -08:00
Josh Gao
b800d88b34 adb: extract atransport's connection interface.
As step one of refactoring atransport to separate out protocol handling
from its underlying connection, extract atransport's existing
hand-rolled connection vtable out to its own abstract interface.

This should not change behavior except in one case: emulators are
now treated as TCP devices for the purposes of `adb disconnect`.

Test: python test_device.py, with walleye over USB + TCP
Test: manually connecting and disconnecting devices/emulators
Change-Id: I877b8027e567cc6a7461749432b49f6cb2c2f0d7
2018-01-30 15:22:41 -08:00
Josh Gao
fb413a2304 adb: fix a leak.
Test: none
Change-Id: I469bd93180cd2a8b6408f73e8c8f164f72b3345c
2018-01-30 13:32:38 -08:00
Treehugger Robot
ef213b6d5b Merge "adb/fastboot: switch over to shared AdbWinApi." 2018-01-09 19:49:23 +00:00
Josh Gao
b0449da977 adb/fastboot: switch over to shared AdbWinApi.
Bug: http://b/71721338
Test: manually ran adb/fastboot on windows
Change-Id: I9fee6ea4c0e07cbeb69a48e456161832a5994e7b
2018-01-08 16:45:30 -08:00
Elliott Hughes
18cdd3502a Merge "Sort devices list before output." 2018-01-08 22:11:23 +00:00
Mike Frysinger
50ecaca744 adb: add missing condition_variable include
Test: build still works
Change-Id: I0e77336bab2a4a54cb2e77143162627d47aac0b1
2018-01-02 02:25:02 -05:00
Elliott Hughes
579e682628 Add std::string StartsWith*/EndsWith* overloads.
We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.

Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
2017-12-20 09:42:22 -08:00
Artem Iglikov
04398a9b23 Sort devices list before output.
Makes copy of the transport list and sorts it by type and serial before
printing.

Bug: 70748433
Test: adb devices displays all connected devices
Change-Id: I917728a102972f2f38f2e370a0c6011c1eb883c7
2017-12-19 09:22:53 +00:00
Tim Murray
de47194940 adb: disable checksum on new versions
The checksum is unnecessary. Improves adb performance by 40% on USB2.

Test: new adb works with new + old adbd, old adb works with new adbd
bug 67327728

Change-Id: I761d8a5a62deaea9bbb092ea9926b2d6d312f00d
2017-12-14 14:18:26 -08:00
Elliott Hughes
bf2062f800 Merge "Set $TMPDIR for adb shell." 2017-12-12 00:29:50 +00:00
Treehugger Robot
6f29887c71 Merge "adb: get libusb compiling on Windows." 2017-12-11 19:24:41 +00:00
Elliott Hughes
d42df42f30 Set $TMPDIR for adb shell.
Bug: http://b/19635681
Test: printenv
Change-Id: I21e89b9d7cccad23f32a3062a9e04e59b8278104
2017-12-11 10:40:57 -08:00
Josh Gao
9425996b45 adb: get libusb compiling on Windows.
This still doesn't work yet because libusb doesn't support hotplug on
Windows yet, but it's in the milestones for the next libusb release,
and this is enough to start poking around with the WinUSB device-side
stuff, so leave it broken for now.

Bug: http://b/68993980
Test: set ADB_LIBUSB=1; adb.exe server nodaemon aborts in the expected place
Change-Id: Icef7d46e31c847d6a8e724c6f58ae5db43673c16
2017-12-08 13:11:15 -08:00
Treehugger Robot
a4a9a81d38 Merge "adb: disable USB packet overflow checking on OS X." 2017-12-08 20:31:51 +00:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
Josh Gao
801048c6ea adb: disable USB packet overflow checking on OS X.
OS X appears to be misreporting the maximum packet size on some
hardware. Disable this on OS X until we figure out what's going on.

Bug: http://b/65063965
Bug: https://issuetracker.google.com/70244520
Test: python test_device.py on linux with CHECK_PACKET_OVERFLOW disabled
Test: python test_device.py on darwin (but on hardware that wasn't reproducing this)
Change-Id: I57e1adfa162e40ed79f71f97af552b3f0519324e
2017-12-06 15:34:41 -08:00
Jim Kaye
42f9a44000 Merge "Fix typos in ADB documentation"
am: 017203b140

Change-Id: I263536093d33e7e1783049834862346e47643723
2017-11-30 21:53:43 +00:00
Jim Kaye
ab74e068ee Fix typos in ADB documentation
Bug: None

Test: None

Change-Id: Ib036eefc602bf0ebac869146b04eea225cae39ef
2017-11-30 10:57:51 -08:00
Elliott Hughes
0b8a47c55a Merge "Remove a duplicate TEMP_FAILURE_RETRY."
am: 166c6a4390

Change-Id: I7bf8f8b7c68ecced7c62122f59623eefe9bab285
2017-11-29 16:12:00 +00:00
Elliott Hughes
166c6a4390 Merge "Remove a duplicate TEMP_FAILURE_RETRY." 2017-11-29 16:06:12 +00:00
Elliott Hughes
3df2fa6d8e Remove a duplicate TEMP_FAILURE_RETRY.
Bug: N/A
Test: builds
Change-Id: I19c2f50422e8a7e0c451a464586553f3e5eaadab
2017-11-28 18:05:27 -08:00
Nick Kralevich
cac2163a6b Merge "Standarize on VFS_CAP_REVISION_2"
am: af03f483d7

Change-Id: If1d0c4aa90cb712168db2252c23e621c3513acfe
2017-11-28 01:11:17 +00:00
Nick Kralevich
65b8d749f7 Standarize on VFS_CAP_REVISION_2
In https://github.com/torvalds/linux/commit/8db6c34f1dbc8 , namespaced
file capabilities were introduced. That change updated VFS_CAP_REVISION
from VFS_CAP_REVISION_2 to VFS_CAP_REVISION_3.

Android code is written assuming v2 capabilities, and the code will
break if we naively try to treat a v2 structure as a v3 structure.
So don't even try.

Android kernels prior to v4.14 will not support this extended capability
structure, so attempting to set such capabilities will ultimately fail.

With 8db6c34f1dbc8, it appears that attempting to read a v3 capabilities
xattr will always downgrade the capability to a v2 capability, so it
really doesn't make sense to look for a v3 capability.

Android capabilities are only created at /system and /vendor filesystem
creation time by host tools. Android processes, within or outside a
namespace, are not permitted CAP_SETFCAP
(https://android-review.googlesource.com/c/platform/system/sepolicy/+/547801/1/public/domain.te
line 1101). So we should never have to deal with a v3 capability other
than those that might appear on the /system / /vendor partition at a
future date by a future author.

Bug: 69617725
Test: build/test/boot/CTS passes
Change-Id: I0378b3f1195dc62dbeb771944ab378c881441118
2017-11-27 14:17:42 -08:00
Sandeep Patil
25f1631aa7 DO NOT MERGE ANYWHERE Add comments and code about ro.boot.slot back
Taimen bootloader passes androidboot.slot for now.
This reverts commit 211a4a5d5a.

Bug: 68710251
Test: taimen successfully mounts partition in first stage
Change-Id: I046afc99120e7ec9ef4b8ea7a852eb70e7231ea9
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-11-10 16:20:27 -08:00
Treehugger Robot
93e5cd85d1 Merge "Move GetDeviceTest from adb's test_device.py to adb package." 2017-11-09 00:57:32 +00:00
Josh Gao
85d4789719 Move GetDeviceTest from adb's test_device.py to adb package.
This test actually belongs with the adb python wrapper, since it's not
affected by changes to adb itself.

Bug: http://b/64260633
Test: python test_device.py
Change-Id: I58e5dff760f35923f8dbbdc7de6ffd75254880dc
2017-11-08 14:39:06 -08:00
Elliott Hughes
6b970212fd Don't include the build number in the adbd binary.
We want repeatable builds for minimal OTAs.

(cherrypick of 2e93eda69cf20d9c04d56ea6bf1e2ea62ad62eb4.)

Bug: http://b/64634017
Bug: 64709603 (presubmit balking at the line above)
Test: repeated builds after `touch daemon/main.cpp` keep same md5sum
Change-Id: Iedeb44377ea45bbf20e2212760802198a57dc14a
2017-11-07 10:57:36 -08:00
Josh Gao
1f3763ef4a Merge "adb: fix erase-remove_if idiom."
am: c2a2ecb7a5

Change-Id: I98bc2547b3785d8ca14565a6a9b7fac84a7c673e
2017-10-23 21:36:22 +00:00
Treehugger Robot
c2a2ecb7a5 Merge "adb: fix erase-remove_if idiom." 2017-10-23 21:28:32 +00:00
Mark Salyzyn
5966ae2c6b Merge changes I3e6e5a22,I6eb3f066
am: 75836d5e7f

Change-Id: I871260b9cdf7a1ab5f6d39cd8a491cd31cd94a4d
2017-10-23 20:45:02 +00:00
Josh Gao
4dfaa88610 adb: fix erase-remove_if idiom.
This probably doesn't have any actual effect, because there should only
be one smartsocket listener so this will happen to work, but this looks
sketchy.

Test: mma
Test: adb server nodaemon & (sleep 1; adb kill-server)
Change-Id: Id00ab1fc1fc029949c675ae6e3b1a77f3e9e4c69
2017-10-20 18:03:48 -07:00
Mark Salyzyn
8f3b8873b0 adb: cleanup some portions of client usb interfaces
Cleanup to remove open coded functions.

Test: build
Bug: 63736262
Bug: 38446744
Bug: 66912053
Change-Id: I3e6e5a22542934837b6a03523987141dc2776d48
2017-10-13 07:31:49 -07:00
Mark Salyzyn
0a78cc1b76 adb: clang-format for adb.h and client/usb_windows.cpp
Future adjustments triggered cleanup and transition of adb/adb.h and
adb/client/usb_windows.cpp to be moved to Android coding standard.

Test: build
Bug: 63736262
Bug: 38446744
Bug: 66912053
Change-Id: I6eb3f0665b9670b9b3d5f5397f271605b48f4ff0
2017-10-13 07:31:49 -07:00
Elliott Hughes
510552149c Merge "Set $HOSTNAME in adbd."
am: 2364d7ccc5

Change-Id: I40ef480380f250540d6c2856721540400c599111
2017-10-03 22:32:13 +00:00
Elliott Hughes
ba4d9fd933 Set $HOSTNAME in adbd.
bash sets this itself, but mksh doesn't.

This also makes interactive and non-interactive adb shells more similar,
because when we set this in mkshrc that wouldn't affect non-interactive
shells. (I'm not sure whether this is an improvement or not.)

This is certainly _cheaper_ than doing this in mkshrc by calling out to
getprop though.

Bug: N/A
Test: `adb shell printenv` and `adb shell`, `printenv`
Change-Id: I3ff724f19a5098313df83836253f1f7e7872d6a4
2017-10-03 08:44:27 -07:00
Josh Gao
86a919041f Merge "adb: remove SendConnectOnHost."
am: 5eaa5bc081

Change-Id: I899558eb51cda69d9c53288db86cada87a4a0e85
2017-10-02 23:32:49 +00:00
Treehugger Robot
5eaa5bc081 Merge "adb: remove SendConnectOnHost." 2017-10-02 23:27:23 +00:00
Josh Gao
4b5d4da6f6 adb: remove SendConnectOnHost.
This logic appears to be racy, and it shouldn't actually be needed, if
our devices follow the USB spec. Use libusb_set_interface_alt_setting
on device initialization as well, to add one more thing that should
reset the data toggles.

Bug: http://b/32952319
Test: python test_device.py
Change-Id: I392198af3d72c524b893e5056afa2b4617cea49c
2017-10-02 14:38:03 -07:00
Josh Gao
bc3d3625d5 Merge "adbd: improve thread names."
am: 39071a5177

Change-Id: Id41804332dfb81a2bcfd07d3a7180f16e7412bc0
2017-09-29 18:34:17 +00:00
Josh Gao
bcadc77550 adbd: improve thread names.
Name each service thread specifically to improve debuggability.

Bug: http://b/65648324
Test: adb shell debuggerd -b `adb shell pidof adbd` during a sync
Change-Id: I644e25fc2f14a26eafd19f596e4e8f3c2bb79967
2017-09-28 16:45:24 -07:00
Josh Gao
d3f7956f2f Merge "adb: partially revert b5e11415."
am: ef9426d883

Change-Id: I3f7fa1577bc79b5bdcacbeacc7b5141cc9c73cb9
2017-09-27 18:45:18 +00:00
Treehugger Robot
ef9426d883 Merge "adb: partially revert b5e11415." 2017-09-27 18:38:28 +00:00
Tom Cherry
9bc2a967cf Merge "Reland "Remove comments and code about ro.boot.slot""
am: dea5e081ac

Change-Id: Idf32e9600b6a3b93a6a2b4c414cc0193d5d65fb9
2017-09-26 00:08:55 +00:00
Tom Cherry
211a4a5d5a Reland "Remove comments and code about ro.boot.slot"
This reverts commit c5f5fd430a.

Dependencies are now merged.

Bug: 37663204
Bug: 66437505
Change-Id: I84284b6bc37f6aae4096dec73f45ebd85d28ca9d
2017-09-25 16:04:30 +00:00
Tom Cherry
0ff5f16f7b Merge "Revert "Remove comments and code about ro.boot.slot""
am: eb00b1f3aa

Change-Id: If6b511a19009e28a63b52e6701dbc8f7b1f514f7
2017-09-21 18:46:44 +00:00
Tom Cherry
c5f5fd430a Revert "Remove comments and code about ro.boot.slot"
This reverts commit f4ec2c50a3.

Dependencies hadn't been merged yet.

Bug: 66437505
Change-Id: I7551b7f2f184a6fefc39e184a42dc8d323c58b89
2017-09-21 18:37:22 +00:00
Tom Cherry
bf6168fd53 Merge "Remove comments and code about ro.boot.slot"
am: 7dcf076700

Change-Id: Ic28c5bd369d45489150741b1c1cf2b4c00c4eb52
2017-09-20 19:27:43 +00:00
Tom Cherry
f4ec2c50a3 Remove comments and code about ro.boot.slot
ro.boot.slot_suffix is the correct parameter.

Bug: 37663204
Test: boot sailfish
Change-Id: I72f94b3c611a2280d0732321dd8de88b0530a3cd
2017-09-20 10:14:44 -07:00
Josh Gao
1425641300 Merge changes I0ed00441,I12d46493,Ib484f701
am: 0a01830612

Change-Id: I8b4566f0daea2181227facea12d82ffd566889b5
2017-09-14 20:35:31 +00:00
Josh Gao
0a01830612 Merge changes I0ed00441,I12d46493,Ib484f701
* changes:
  Revert "adb: fix deadlock between transport_unref and usb_close."
  adb: add lock to remove_socket.
  adb: reformat comments.
2017-09-14 20:04:42 +00:00
Mark Salyzyn
6818f80dbb Merge changes from topic "b/63736262"
am: 1f666a6be9

Change-Id: I2586aac3d6fe8252ee6728de64fb37102accf0da
2017-09-13 22:45:52 +00:00
Josh Gao
33d14b8748 adb: partially revert b5e11415.
Revert the write_msg_lock part of commit b5e11415. A write which hangs
will hold onto the mutex, preventing the device kick from ever
happening, which also causes lots of other stuff to hang, due to Kick
being called with the transport lock taken.

Test: python test_devices.py
Change-Id: Ie7c958799c93cad287c32d6bbef30c07f40c2d51
2017-09-13 15:09:40 -07:00
Josh Gao
e48ecce671 Revert "adb: fix deadlock between transport_unref and usb_close."
This reverts commit 7e197ef833.

The mutex lock in transport_unref hides a race that seems otherwise
hard to fix. Specifically, there's no synchronization between acquiring
a transport and attaching it to an asocket*, leading to badness if the
transport is closed in between the two operations.

Fix the original problem the reverted patch addressed by manually
unlocking before calling unregister_usb_transport.

Bug: http://b/65419665
Test: python test_device.py
Change-Id: I0ed0044129b1671b2c5dd1b9fa2e70a9b4475dc5
2017-09-13 14:31:14 -07:00
Josh Gao
62c92f0c05 adb: add lock to remove_socket.
The comment that was previously here says that local_socket_list_lock
must be taken, but this function is exposed to external callers that
can't possibly take the lock.

Bug: http://b/65419665
Test: python test_device.py
Change-Id: I12d464933936b2a210a827ccf19ea201020d8d78
2017-09-13 14:05:39 -07:00
Josh Gao
55c8b34f14 adb: reformat comments.
Test: none
Change-Id: Ib484f701f66cdb57f303dbd6d5eb2e5a15abdc0e
2017-09-13 14:05:21 -07:00
Mark Salyzyn
277eca138b adb: reboot: last boot command default
For reboot [reboot_arg] requests via either reboot or adb reboot,
if reboot_arg is empty then report "shell" or "adb" respectively.

Test: boot_reason_test.sh shell_reboot adb_reboot
Bug: 63736262
Change-Id: Ie613d9e62db6a705885e4e7520aede27af3aa1b9
2017-09-12 12:24:02 -07:00
Bowgo Tsai
08a8c4209f Merge "Revert "adbd: lessen security constraints when the device is unlocked""
am: 9638729a9d

Change-Id: I25eab992b0a4c2f144454cd5865fad1a762cfc61
2017-08-31 08:27:33 +00:00
Treehugger Robot
9638729a9d Merge "Revert "adbd: lessen security constraints when the device is unlocked"" 2017-08-31 08:21:08 +00:00
Bowgo Tsai
0603ec4294 Revert "adbd: lessen security constraints when the device is unlocked"
This reverts commit f1d3dbc32f.

With the following changes to move /sbin/adbd to /system/bin/adbd,
we don't need this workaround anymore.

  https://android-review.googlesource.com/#/q/topic:move-adbd-to-system+(status:open+OR+status:merged)

Bug: 63313955
Bug: 63381692
Bug: 64822208
Test: 'adb root' works in VTS for a non-A/B device (userdebug GSI + user boot.img)

Change-Id: Ic1249d6abd7d6e6e7380a661df16d25447853a48
2017-08-31 14:30:51 +08:00
Bowgo Tsai
f390f04381 Merge "Move adbd from root to system"
am: 3d6f85167e

Change-Id: I3b89a7a8e98252319f850a225ef7ba2080e54879
2017-08-31 06:30:48 +00:00
Treehugger Robot
3d6f85167e Merge "Move adbd from root to system" 2017-08-31 06:22:16 +00:00
Jerry Zhang
6fe5cda8aa Merge "adb: Use kernel aio for functionfs."
am: aaa90cfe06

Change-Id: Ia89f076b94c8974544923b64ea53dffd6b8c8397
2017-08-29 03:38:26 +00:00
Treehugger Robot
aaa90cfe06 Merge "adb: Use kernel aio for functionfs." 2017-08-29 03:28:26 +00:00
Josh Gao
f628362478 Merge "adb: improve CHECKs."
am: 9f38e19b88

Change-Id: Icc50ced0faeda5653288922ec787311e30c5085d
2017-08-28 23:40:23 +00:00
Treehugger Robot
9f38e19b88 Merge "adb: improve CHECKs." 2017-08-28 23:35:44 +00:00
Josh Gao
e46720938d adb: improve CHECKs.
Use CHECK_LT(foo, 1234) instead of CHECK(foo < 1234) so that failing
checks have the values emitted.

Bug: http://b/65063965
Test: adb server nodaemon
Change-Id: I094287f7c4d2d177ea216568d06e9e425a28dd96
2017-08-28 14:43:24 -07:00
Josh Gao
4dc1892491 Merge "adbd: don't spin if file sync read fails."
am: 32d2eae8b9

Change-Id: Ie104bb8ea8d67b5a7ce896d2237a44cc8ea1ab4f
2017-08-28 21:16:13 +00:00
Josh Gao
1d6c01b53d adbd: don't spin if file sync read fails.
Bug: http://b/64508974
Test: mma
Change-Id: Ifba6a9dea3138b6d2a62c91cc0532f63986c048a
2017-08-28 11:21:31 -07:00
Bowgo Tsai
7b9a4d5bcd Move adbd from root to system
Bug: 63910933
Test: normal boot sailfish, checks adb works
Test: recovery boot sailfish, checks adb works
Test: normal boot bullhead, checks adb works
Test: recovery boot bullhead, checks adb works

Change-Id: I1b27910c06a4172ca718b3344736ec8e3429f477
Merged-In: I1b27910c06a4172ca718b3344736ec8e3429f477
(cherry picked from commit 93defc17f3)
2017-08-24 14:22:07 +08:00
Elliott Hughes
37f256423b Merge "Fix adb tcpip tests."
am: d865b655d5

Change-Id: I1b9938c36b59db8ce991928349ba6ee9c8459de1
2017-08-24 00:52:03 +00:00
Elliott Hughes
e163298ef2 Fix adb tcpip tests.
The test was assuming we still output the full help for every syntax error.
While I'm here, make the diagnostics suck less.

Bug: N/A
Test: ran tests
Change-Id: Idc28616f20c66391f32046cf4216f122998a84bd
2017-08-23 15:43:34 -07:00
Felipe Leme
589523b7c3 Merge "Don't preserve file attributes when pulling bugreport file..." am: 8570d1db70 am: 009c2ddadc
am: 6d6ff64360

Change-Id: I4cec50a7ec2c76f355e1f1821564308d88ef5e2a
2017-08-22 23:10:58 +00:00
Treehugger Robot
8570d1db70 Merge "Don't preserve file attributes when pulling bugreport file..." 2017-08-22 22:41:26 +00:00
Josh Gao
d879c171a0 Merge changes I2270cc0a,I55e5dc5a am: 2066e0585e am: 46244a6497
am: 40b849f88a

Change-Id: Iee1c51f4b0d78f47afc5f2c1c057f6cf9110dba8
2017-08-21 23:53:22 +00:00
Josh Gao
b0c1802615 adb: add track-devices-l service.
Add a way to get the full `devices -l` output on a continuous basis.

Test: manual
Change-Id: I2270cc0a0d7e1384ce19631724ddf2462d963ade
2017-08-21 14:15:07 -07:00
Josh Gao
b122b17555 adb: allow selection of a specific transport.
Extend device selection to allow selecting a specific transport via
monotonically increasing identifier (visible in devices -l).

This is useful when using multiple devices (like hikey960...) that
have identical bogus serial numbers like 0123456789ABCDEF.

Bug: http://b/37043226
Test: adb -t {1, 2, 9999999} {get-serialno, shell, features}
Change-Id: I55e5dc5a406a4eeee0012e39b52e8cd232e608a6
2017-08-21 14:15:06 -07:00
Josh Gao
f91a9f98ae Merge "adb: fix deadlock in kick_all_transports." am: c2449e871e am: b43479c764
am: 4fd1f04a82

Change-Id: Iacdf180f5315b5436724433cc65ad6419aebea1e
2017-08-18 20:11:46 +00:00
Treehugger Robot
c2449e871e Merge "adb: fix deadlock in kick_all_transports." 2017-08-18 19:50:32 +00:00
Huihong Luo
2f19bbe3e9 Merge "Fix bug #37284906, adb shell crashes on windows with invalid options. For example, "adb.exe shell -list" crashes without this fix. Test: adb.exe shell -list-packages" am: e275043d38 am: 4be54a4622
am: 94574c4f00

Change-Id: I5e2780f291cf533689338e7216e82d2da364057c
2017-08-18 14:53:51 +00:00
Huihong Luo
af39885c9f Fix bug #37284906, adb shell crashes on windows with invalid options.
For example, "adb.exe shell -list" crashes without this fix.
Test: adb.exe shell -list-packages

Change-Id: I96be44128ff3ecab7804b70074cbde630b3fc3d1
2017-08-17 22:26:46 -07:00
Josh Gao
1db71afe97 adb: fix deadlock in kick_all_transports.
Previously, kick_all_transports would deadlock if there were any
inaccessible transports, because the transport kick function would call
unregister_usb_transport, which attempts to take the already-held
transport lock.

Fix this by switching the transport lock over to a recursive mutex.

Test: manual
Change-Id: If61296ff4745e1699f3e216811c1383582627604
2017-08-17 13:50:51 -07:00
Ting-Yuan Huang
78a298ce24 Merge "Fix a potential memory leak" am: f583ff660e am: 6677429bff
am: 6deffe3c3b

Change-Id: Ifcd960527a5da12e136ba96062460208368aafea
2017-08-16 17:34:11 +00:00
Felipe Leme
4bfddbd20e Don't preserve file attributes when pulling bugreport file...
...otherwise it could have weird dates when the device clock is wrong.

Test: m -j32 adb && ./out/host/linux-x86/bin/adb bugreport test.zip && ls -l test.zip
Test: m -j32 adb_test && ./out/host/linux-x86/nativetest64/adb_test/adb_test

Fixes: 63927360

Change-Id: I3f87277f1acb97212a87b89639e42b6d7d300faa
2017-08-15 18:11:38 -07:00
Ting-Yuan Huang
f26cf6d520 Fix a potential memory leak
Test: Built without seeing the warnings
Change-Id: I934509c78482af9ef7dc447c807f6450484b4b38
2017-08-15 16:48:24 -07:00
Jerry Zhang
ecee434fae adb: Use kernel aio for functionfs.
This method works around the downsides of
ENDPOINT_ALLOC, namely that it is not affected
by memory fragmentation and it uses an upstream
interface.

Also add libasyncio to provide the necessary syscalls
to both adb and mtp.

Add some small optimizations to file_sync.

Bug: 37916658
Test: run adb push/pull
Change-Id: If3b3be02b5e2d4f9cffec1b8ddc02a5768a51a1f
2017-08-10 15:12:47 -07:00
Elliott Hughes
df5ecefde4 Merge "Fix reference to out of scope local in adb_thread_setname." am: b31ca1a64f am: 15d565bbca
am: b664dd38b9

Change-Id: Id2d91a34d11400cdb4b601da745d64209aeb3e71
2017-08-03 00:25:00 +00:00
Elliott Hughes
7462f1858c Fix reference to out of scope local in adb_thread_setname.
Bug: https://android-review.googlesource.com/#/c/168725/5/adb/sysdeps.h@639
Test: boots, adbd thread names look sane
Signed-off-by: Ivan Maidanski <i.maidanski@samsung.com>
Change-Id: Ib3bdf53658f3903de8f0a5688f7d77745e677c77
2017-08-02 20:34:06 +00:00
Josh Gao
1324a24b26 Merge "adbd: add logging to troubleshoot usb issues." am: 5550901152 am: 07c337bb7d
am: 18e429af26

Change-Id: I85d859b7fd82b56634fe82dd921f875a206c653e
2017-07-27 01:26:13 +00:00
Treehugger Robot
5550901152 Merge "adbd: add logging to troubleshoot usb issues." 2017-07-27 00:17:15 +00:00
Josh Gao
184f571cfd adbd: add logging to troubleshoot usb issues.
Bug: http://b/63899881
Bug: http://b/63901259
Bug: http://b/63904904
Test: treehugger
Change-Id: Ifbc3caa6b416093bf8e127194003747c910352dc
2017-07-26 11:08:15 -07:00
Lennart Wieboldt
e1332dd01b Merge "Remove LOCAL_CLANG and clang: true" am: 80ec81cf4b am: f7b315c985
am: 8a8b97b271

Change-Id: I7e691abe2e2ccec5d9477c528d603c081c0a5661
2017-07-25 22:35:56 +00:00
Lennart Wieboldt
cd15fc7ba8 Remove LOCAL_CLANG and clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: I34adaeef2f6558a09f26027271222bad94780507
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 14:29:50 +02:00
Bowgo Tsai
9679967dac Merge "adbd: lessen security constraints when the device is unlocked" am: e03665142e am: 0fe0ced23c
am: 620f6e65b3

Change-Id: I532c68a077019cbf133db5cbdcf967509415687b
2017-07-18 02:45:06 +00:00
Bowgo Tsai
f1d3dbc32f adbd: lessen security constraints when the device is unlocked
ALLOW_ADBD_ROOT ('adb root') and ALLOW_ADBD_NO_AUTH (ro.adb.secure = 0)
are false in user build. This prevents a non-A/B device from running
Treble VTS because it requires 'adb root'. Without ALLOW_ADBD_NO_AUTH,
adb still can work if ro.adb.secure = 1. However, allowing it to be 0
is better for test automation.

The image combination in VTS is:
  - system.img (userdebug): provided by Googlg
  - boot.img (user): provided by the OEM  <-- adbd is here
  - vendor.img (user): provided by the OEM

This change allows 'adb root' and 'ro.adb.secure = 0' when the device is
unlocked in user build. No changes for userdebug/eng builds.

Note that the device must be unlocked when running VTS. Otherwise,
verified boot will prevent it from booting the system.img provided by
Google (no verity metadata).

Bug: 63313955
Bug: 63381692
Test: use the above image combination, check 'adb root' and
      'ro.adb.secure = 0' can work

Change-Id: I109d96c950e54c4fb0ac0c98b989a20593681e52
2017-07-18 08:41:19 +08:00
Dan Albert
6c95c3edcd Merge "Indicate that a packet was truncated." am: 046160959c am: e76c8020ba
am: c83ec67ec3

Change-Id: I61c12bc6fbcd205c2421831a64ffb783249a2222
2017-06-27 23:06:56 +00:00
Treehugger Robot
046160959c Merge "Indicate that a packet was truncated." 2017-06-27 22:50:48 +00:00
Dan Albert
9893f93950 Indicate that a packet was truncated.
Test: make checkbuild, check adb log
Bug: None
Change-Id: I0006ed284697f01966fdd79ca0b05dbc6d2eecf0
2017-06-27 13:26:14 -07:00
Josh Gao
cb39742d3a Merge "Revert "adb: turn on libusb by default."" am: b22067677e am: de931dab2d
am: 947a301852

Change-Id: Ideabacf8cd79adaf6fb828874ac636ed88707240
2017-06-26 22:17:29 +00:00
Treehugger Robot
b22067677e Merge "Revert "adb: turn on libusb by default."" 2017-06-26 21:33:34 +00:00
Josh Gao
969110ca4a Revert "adb: turn on libusb by default."
This reverts commit f2f0b31850.

libusb seems to be causing flakiness on some machines. Disable it for
now.

Bug: http://b/62962248
Test: python test_device.py (with DeviceOfflineTest commented out)
Change-Id: Ia9de78ab772c22574cf5ca7facb78f22af6d7a71
2017-06-26 13:17:58 -07:00
Elliott Hughes
b76034e755 Merge "Give a clear error message if we can't start the server." am: b6d3f28287 am: 1496863091
am: 07db226264

Change-Id: Ic2244ee02ca83ccdffcfbefac49797c2e4f7d459
2017-06-21 01:06:53 +00:00
Treehugger Robot
b6d3f28287 Merge "Give a clear error message if we can't start the server." 2017-06-21 00:48:30 +00:00
Elliott Hughes
6eadee8607 Give a clear error message if we can't start the server.
Bug: http://b/35218713
Test: adb kill-server ; export HOME=/ ; adb devices
Change-Id: I53cc30213be0eab84e42b09c7b501362d6e44b05
2017-06-20 14:21:41 -07:00
Josh Gao
24e8e0d0d8 Merge "adb: increase the shell command length limit." am: 9d2e688b9a am: 749d2a0ab5
am: 3df484eeab

Change-Id: I90d845f1c2b6aa767a7c5540b25619724f3b2331
2017-06-17 22:10:31 +00:00
Treehugger Robot
9d2e688b9a Merge "adb: increase the shell command length limit." 2017-06-17 21:57:12 +00:00
Josh Gao
a019f78141 adb: increase the shell command length limit.
Relax the shell command length limits when talking to an adbd with the
shell protocol.

shell is pretty much the only service that takes an arbitrarily long
string, so this is somewhat safe.

Bug: http://b/37716055
Test: `adb shell $(python -c 'print "echo " + "f" * (32*1024)') | wc` on L and master
Change-Id: I0737fd2244530ef8080f300cd3a3549a1ab93465
2017-06-16 18:01:11 -07:00
Josh Gao
7ff1e56f59 Merge "adb: fix deadlock between transport_unref and usb_close." am: 6f61a6d9c4 am: 2a8ce10cd8
am: 64523c01bd

Change-Id: I94128840430281a54c74cdfb2b35744b4730942f
2017-06-12 23:16:10 +00:00
Treehugger Robot
6f61a6d9c4 Merge "adb: fix deadlock between transport_unref and usb_close." 2017-06-12 23:03:55 +00:00
Nicolas Norvez
c616a8ad84 Merge "adbd: optionally use qemud pipe without ro.kernel.qemu" am: b3c363f32c am: 516ee2445d
am: 6ff249f483

Change-Id: I7a5886b9a9c325036007ad9251b0952fdbd7a206
2017-06-12 21:53:42 +00:00
Nicolas Norvez
717f15353f adbd: optionally use qemud pipe without ro.kernel.qemu
adbd currently decides to use the QEMUD pipe if ro.kernel.qemu=1, as set
for ranchu. The Android container in Chrome OS doesn't have that
property set and it can't be set to 1 because it's used as equivalent to
"runs inside an emulator" throughout Android and changes the way
graphics are handled, whether Bluetooth is supported, etc., behaviour
that we do not want to trigger in Chrome OS.

adbd now also checks service.adb.transport to decide whether to use the
QEMUD (goldfish) pipe.
adbd still first checks for ro.kernel.qemu to preserve existing
behaviour and will still fallback to TCP if it can't use Goldfish.

Bug: 38497992
Test: tested by jmgao@ -thanks!- on aosp_angler, adb still works.

Change-Id: I8370704145ae7301ac7aeef81c5cbd94cfcb7fd7
2017-06-12 12:22:32 -07:00
Josh Gao
7e197ef833 adb: fix deadlock between transport_unref and usb_close.
Fix a deadlock that happened when a reader/writer thread released a
transport while the hotplug thread attempted  to handle a device
disconnection. Decrementing a transport refcount to zero would hold the
global transport mutex and attempt to take the usb handles mutex, while
the hotplug thread would hold the usb handles mutex and try to call
unregister_usb_transport, which would attempt to take the global
transport mutex.

Resolve this by making transport_unref not take the global transport
mutex.

Bug: http://b/62423753
Test: python test_device.py
Change-Id: Ib48b80a2091a254527f3a7d945b6a11fae61f937
2017-06-07 18:54:09 -07:00
Josh Gao
806ca1a1b0 Merge changes Id51dcb18,I2517dcb9 am: 4db472b779 am: aa3c3fc3be
am: 4b32a1f8b8

Change-Id: I9b9a5f594dd9a20bbf6dc2fead193433deb51942
2017-06-07 20:12:53 +00:00
Josh Gao
5b8b10e078 adb: libusb: switch from polling for accessibility to a sleep.
For unclear reasons, it seems that for some people, devices are
becoming accessible, inaccessible, and then inaccessible again.
Switch to a sleep for now.

Bug: http://b/62200735
Test: manual
Change-Id: Id51dcb188c3534a57c35cbfd30a181c99115a23c
2017-06-07 11:08:00 -07:00
Josh Gao
7dd382ded9 adb: improve race between device_connected and device_disconnected.
If a device is unplugged while it's being processed, we can be inside
register_usb_transport still when we call unregister_usb_transport,
leading to bad things happening. Move the call of
register_usb_transport into the scope guarded by usb_handles_mutex.

Bug: http://b/62200735
Test: manual
Change-Id: I2517dcb9d30d9a08cebbb5f715ae3fd30c510109
2017-06-07 11:06:53 -07:00
Josh Gao
8e2661eedc Merge changes I6c6bf61b,I3fb0b3a8 am: 3160a25010 am: 9d7880fe96 am: 14f749c2c4
am: 2d30a74181

Change-Id: I57a3916c312b8cc23c616232e84ad6c5507b5a39
2017-06-06 03:05:34 +00:00
Josh Gao
60b8c26520 adb: libusb: don't try to delete a usb_handle twice.
Previously, we would attempt to delete a usb_handle in both
device_disconnected and usb_close. If the one in device_disconnected
happened to happen first, usb_close would abort when it failed to find
the handle it was supposed to own.

Bug: http://b/62020217
Test: unplugging device on darwin
Change-Id: I6c6bf61bf89a4d9a23458c00b457080d3d6cc744
2017-06-05 15:11:53 -07:00
Josh Gao
664a618c06 adb: don't hold queue lock while performing callbacks.
Fix yet another source of deadlocks.

Bug: http://b/62020217
Test: unplugged device on darwin
Change-Id: I3fb0b3a84c56aed7d0da8ddba36e2d01fdb682ee
2017-06-05 14:54:45 -07:00
Josh Gao
f2bd9a1b6f Merge "adb: reunregress waiting for device on start-server." am: 72076d1aa7 am: 08a70ac6e5 am: 986ba5bbbb
am: 86aeea69f2

Change-Id: Icfb77a5a596ebd9207793d9c7929bebb992de40d
2017-06-02 00:58:23 +00:00
TreeHugger Robot
b4ad076ede Merge "Send color space information with screenshots" 2017-06-01 19:27:08 +00:00
Romain Guy
3a4e80ab8a Send color space information with screenshots
Version 2 of the framebuffer protocol in adb can now be used to read
the color space information of the screenshot: unknown (native),
sRGB or Display P3.

Bug: 29940137
Test: Manual
Change-Id: I037da58e1c4f6e9e874d72348140c067640c6931
2017-05-31 19:13:47 -07:00
Josh Gao
0b13c89f7a adb: reunregress waiting for device on start-server.
Move the invocation of adb_notify_device_scan_complete to
the end of device_connected, where we decrement connecting_devices.
Also, create a dedicated thread for handling hotplug events, instead of
reusing the main thread for this, since the main thread blocks until
device scan is complete.

Test: `adb kill-server; adb devices`
Change-Id: Ia73b1a57538174282a48ef73ab0a3e58152d6f83
2017-05-31 12:13:59 -07:00