Commit graph

1958 commits

Author SHA1 Message Date
Treehugger Robot
abf88685e3 Merge changes from topic 'debuggerd_client'
* changes:
  adb: use libdebuggerd_client.
  debuggerd: add libdebuggerd_client.
2016-06-20 20:22:18 +00:00
Josh Gao
344778da41 adb: fix fd double close, Subprocess lifetime issue.
This commit fixes two somewhat related issues in shell_service.

  - The fd returned by StartSubprocess is owned by a unique_fd
    contained in the Subprocess object, but also gets closed by the
    caller. Resolve this by duping the returned file descriptor.

  - A Subprocess object can be destroyed immediately after its initial
    construction in StartSubprocess if we're sufficiently unlucky.
    Split up the fork/exec and "start management thread" steps, so that
    we can safely do everything we need to do on the Subprocess before
    handing it over to the thread that'll eventually destroy it.

Bug: http://b/29254462
Change-Id: Id9cf0b7e7a7293bee7176919edc758597691c636
2016-06-20 11:40:16 -07:00
Josh Gao
809607ae28 adb: use libdebuggerd_client.
Bug: http://b/24414818
Change-Id: I177708877488e5c4f99c453498485a2daa9b79b0
2016-06-17 13:11:29 -07:00
David 'Digit' Turner
c7b098ceb5 [qemu]: Move qemu_pipe.h from include/system/ directory.
The <hardware/qemu_pipe.h> header isn't related to any loadable
hardware module, this patch thus relocates it to <system/qemu_pipe.h>
which is a much more logical location.

Note the following changes:

  - The pipe name must begin with the 'pipe:' prefix to avoid an
    un-necessary snprintf() and buffer copy.

  - Does not probe for the obsolete /dev/goldfish_pipe device, i.e.
    only use /dev/qemu_pipe instead.

  - Use QEMU_PIPE_DEBUG() instead of D() as the debugging macro.

+ Update ADB to use the newest <system/qemu_pipe.h>

+ Add qemu_pipe_frame_send() and qemu_pipe_frame_recv() utility
  functions which replace the obsolete qemud_channel_send() and
  qemud_channel_recv() from the defunct <hardware/qemud.h>
  header.

BUG=25875346

Change-Id: Ic290a5b79d466c2af64b49bd9134643277c11bfd
2016-06-17 09:21:59 +02:00
Josh Gao
ba7aea829b Merge \"adb: make adb root not wait-for-device.\"
am: 81e59ca5a7

Change-Id: I231ad44c7b6293256f33eb3fd617b4e5da728ca1
2016-06-16 22:41:08 +00:00
Treehugger Robot
81e59ca5a7 Merge "adb: make adb root not wait-for-device." 2016-06-16 22:26:41 +00:00
Josh Gao
05824734ac adb: make adb root not wait-for-device.
`adb root` would hang for devices connected over TCP/IP, because they
never come back. Unfortunately, there doesn't seem to be an easy way to
find out what we're talking to, so replace it with a long sleep for now.

Bug: http://b/27836058
Change-Id: Icd6e6bf817ca9e2124c2961665c37b2f31f7ef29
2016-06-16 14:02:01 -07:00
Elliott Hughes
c63439ae7f Merge \"Better diagnostics from \"adb sideload\".\"
am: edd401e24e

Change-Id: I36b23f7533bbd4d6d9d9e171c297155846734a63
2016-06-15 23:29:30 +00:00
Treehugger Robot
edd401e24e Merge "Better diagnostics from "adb sideload"." 2016-06-15 23:18:52 +00:00
Elliott Hughes
b94f3c597c Merge \"Minor adb style fixes.\"
am: 35151f49ca

Change-Id: I84187cdafe76026ac58d90f4510979cff4e2afe5
2016-06-15 22:48:43 +00:00
Elliott Hughes
14415142c9 Better diagnostics from "adb sideload".
Well, slightly less bad diagnostics, anyway.

Change-Id: Idf5612f7dcb9bdbd7252163889e2612ba197426d
2016-06-15 15:09:47 -07:00
Elliott Hughes
ffc73a39fd Minor adb style fixes.
Change-Id: Ic4b45828dfdf88ef6c0fc468f66df3e62d2fbe51
2016-06-15 14:46:56 -07:00
Elliott Hughes
e691def5df Merge \\"Fix the sense of a test in \\"adb sideload\\".\\" am: 62cc17de8c
am: e9dfa4f753

Change-Id: If5dbbcaa7452b17b3e383daf7bbfc037108c10a3
2016-06-13 23:41:24 +00:00
Elliott Hughes
356fd364ad Fix the sense of a test in "adb sideload".
Change-Id: I516a2ad2d74d9322ff9eb2e4cd3c3829e5cbda99
2016-06-13 15:01:13 -07:00
Felipe Leme
e1d64b4eaf Merge \"Redirect bugreport stderr to host\'s stderr.\" into nyc-dev
am: 6d349051ce

Change-Id: I7ed56de80ff6ac698fb62820f24fca940d7c0905
2016-06-08 23:41:22 +00:00
TreeHugger Robot
6d349051ce Merge "Redirect bugreport stderr to host's stderr." into nyc-dev 2016-06-08 23:35:12 +00:00
Felipe Leme
d1dd125bc2 Redirect bugreport stderr to host's stderr.
Change-Id: I46f474f0b0d5cacdc4b129eab1bb0a7f52ccece0
Fixes: 29161586
2016-06-08 11:09:34 -07:00
Elliott Hughes
e4e6864e72 Merge \\"Set file capabilities on adb sync/push.\\" am: a500cf9cdf
am: 4e4a274e96

Change-Id: Ife5e12dcbf019d740ac642adf25aec75c006b2c8
2016-06-08 17:26:17 +00:00
Treehugger Robot
a500cf9cdf Merge "Set file capabilities on adb sync/push." 2016-06-08 17:19:41 +00:00
Elliott Hughes
32c60b4ced Set file capabilities on adb sync/push.
Bug: http://b/29180022
Change-Id: Ia21ebf0972af41b0a3becc1189ed836fd74ae5c8
2016-06-08 09:16:28 -07:00
Elliott Hughes
75f42d7ea7 Allow multiple (sequential) adb users on Linux.
Before this, adb will fail to start for the second user who tries because
/tmp/adb.log already exists and isn't writable by the second user.

Also allow $TMPDIR to override the use of /tmp.

Bug: http://b/29201686
Bug: https://code.google.com/p/android/issues/detail?id=211420

(cherry picked from commit d89a6c2285)

Change-Id: Ibb1369e8043feb9774593e317dcd7bb93323fd89
2016-06-08 08:36:19 -07:00
Elliott Hughes
fff3e52617 Merge \\"Allow multiple (sequential) adb users on Linux.\\" am: 6bf8d26c82
am: b227e61c41

Change-Id: Ibed97f2d5ac4ae9c307871cc516a81c2eb761bcd
2016-06-08 14:36:36 +00:00
Elliott Hughes
d89a6c2285 Allow multiple (sequential) adb users on Linux.
Before this, adb will fail to start for the second user who tries because
/tmp/adb.log already exists and isn't writable by the second user.

Also allow $TMPDIR to override the use of /tmp.

Bug: https://code.google.com/p/android/issues/detail?id=211420
Change-Id: Ic53da981ac0fa45bfed62e7b351d75dca0540235
2016-06-07 14:53:21 -07:00
David Pursell
27a68ef007 Merge "adbd: properly close subprocess pipes on Ctrl+C." am: 605628d325
am: 5701c58296

* commit '5701c58296b7ae84e8b9e67b6103ffdf63550fc7':
  adbd: properly close subprocess pipes on Ctrl+C.

Change-Id: I361b9ed8ce1d12487d88850635bf1b60c1b675c4
2016-06-06 21:25:03 +00:00
David Pursell
a6d5661140 adbd: properly close subprocess pipes on Ctrl+C.
When non-interactive sessions exit via Ctrl+C, adbd sends SIGHUP
to the child process to let it know to exit. However, adbd was not
closing the pipes to the child process, so if the subprocess ignored
SIGHUP and continued writing it could fill up the pipe and block
forever while adbd waits for it to exit.

This CL adds the necessary calls to close the subprocess pipe after
sending SIGHUP.

Bug: 28981563
Change-Id: I318e322e563241052648361172f4859c297837fb
(cherry picked from commit f2aa186c7b)
2016-06-06 12:56:52 -07:00
David Pursell
f2aa186c7b adbd: properly close subprocess pipes on Ctrl+C.
When non-interactive sessions exit via Ctrl+C, adbd sends SIGHUP
to the child process to let it know to exit. However, adbd was not
closing the pipes to the child process, so if the subprocess ignored
SIGHUP and continued writing it could fill up the pipe and block
forever while adbd waits for it to exit.

This CL adds the necessary calls to close the subprocess pipe after
sending SIGHUP.

Bug: 28981563
Change-Id: I318e322e563241052648361172f4859c297837fb
2016-06-06 09:59:34 -07:00
Siqi Lin
8edfe2040b Revert "adb: close ep0 on disconnection."
am: 8c4076295e

* commit '8c4076295ebd867d276636d673b9f8e6a8df01a6':
  Revert "adb: close ep0 on disconnection."

Change-Id: I74112ef3f508016238a3eb1224292aa4d77334d5
2016-06-03 04:46:25 +00:00
Siqi Lin
8c4076295e Revert "adb: close ep0 on disconnection."
This reverts commit 69e97e4bee.

Bug: 28932120
Change-Id: I5e2569abed316c089886556c432bfe59bca08549
(cherry picked from commit 57de0514f0)
2016-06-02 17:30:43 -07:00
Josh Gao
52338a3f93 adb: refactor jdwp_service.cpp.
Refactor jdwp_service.cpp to be more idiomatic C++.

Bug: http://b/28347842
Change-Id: I8c463069fe489819cb7c248f4aff2689877bfe45
2016-06-02 15:38:16 -07:00
Elliott Hughes
8d96370fb2 Merge "Kill adb\'s ScopedFd for unique_fd." am: 0f3fde210d
am: b8901de2ad

* commit 'b8901de2adca421ad10d91cdfd35851f0473464a':
  Kill adb's ScopedFd for unique_fd.

Change-Id: Idb0559a08423b9985058866ba906580353e5a7e5
2016-05-28 02:17:19 +00:00
Elliott Hughes
2ce86e527b Kill adb's ScopedFd for unique_fd.
It's the adb unique_fd, but at least it's the same API...

Change-Id: If5d6642457e145c450374fde6f1358e5ac386a96
2016-05-27 17:51:24 -07:00
Elliott Hughes
500c7e5bc7 Merge "Kill load_file." am: b42e4a6b63
am: 198a727891

* commit '198a727891aef33469d82b263fc222e4f4335b1b':
  Kill load_file.

Change-Id: I81d715153b8b882ace9deb073abfc4dde5535811
2016-05-28 00:30:31 +00:00
Elliott Hughes
e8b663fec3 Kill load_file.
Change-Id: I6c332f7d8e94d513605295b3d4d32c4e1cf878dc
2016-05-27 16:14:02 -07:00
Yurii Zubrytskyi
dace015269 [adb] Followup CL to clean up adb_auth_host.cpp
Get rid of unused includes + replace a fixed-size buffer with an
std::string

(cherry-pick of 049ebb810f466d916ec9e73cdf28624b57a8c25d.)

Change-Id: I4f9927b900a79a012b5d52908b9d22ac3d2a401c
2016-05-27 14:43:26 -07:00
Yurii Zubrytskyi
376b27532c [adb] Issue the "auth" emulator command before any other one
Emulator console now requires authentication; this means
'adb emu ...' commands silently fail because of it.
This CL adds an 'auth <token>' command to each user command,
making sure it won't be silently ignored.

(cherry-pick of a9e2b99a7fdd31bcd6d852c6db26fe592236a24f.)

Bug: https://code.google.com/p/android/issues/detail?id=211233
Change-Id: Id9ca4999fd2e6393cc88278eaf444243e13c0ec0
2016-05-27 13:34:40 -07:00
Yurii Zubrytskyi
1098c529d1 [adb] Followup CL to clean up adb_auth_host.cpp
am: 049ebb810f

* commit '049ebb810f466d916ec9e73cdf28624b57a8c25d':
  [adb] Followup CL to clean up adb_auth_host.cpp

Change-Id: I6e7d1a1e0fe58648f3a3bf12aef6507f990de123
2016-05-27 19:36:31 +00:00
Yurii Zubrytskyi
f48adf6351 resolve merge conflicts of a9e2b99 to nyc-dev-plus-aosp
Change-Id: Ic77afb008f68ebc455d3a788119b669a52a254dc
2016-05-27 11:07:40 -07:00
Yurii Zubrytskyi
049ebb810f [adb] Followup CL to clean up adb_auth_host.cpp
Get rid of unused includes + replace a fixed-size buffer with an
std::string

Change-Id: I4f9927b900a79a012b5d52908b9d22ac3d2a401c
2016-05-26 18:12:15 -07:00
Yurii Zubrytskyi
a9e2b99a7f [adb] Issue the "auth" emulator command before any other one
Emulator console now requires authentication; this means
'adb emu ...' commands silently fail because of it.
This CL adds an 'auth <token>' command to each user command,
making sure it won't be silently ignored.

Bug: https://code.google.com/p/android/issues/detail?id=211233
Change-Id: Id9ca4999fd2e6393cc88278eaf444243e13c0ec0
2016-05-26 18:11:59 -07:00
Yabin Cui
16dad488b3 Merge "adb: retry connecting disconnected emulators instead of always looping." am: 50e91fec0e
am: cfb0c5cd91

* commit 'cfb0c5cd913b689c8f9d0d930c92c6a0804e2995':
  adb: retry connecting disconnected emulators instead of always looping.

Change-Id: I4b7f30bd3738ce53eb343e5d0e20f3d20faf7e2a
2016-05-26 02:10:10 +00:00
Yabin Cui
50e91fec0e Merge "adb: retry connecting disconnected emulators instead of always looping." 2016-05-26 01:32:53 +00:00
Yabin Cui
b74c6498aa adb: retry connecting disconnected emulators instead of always looping.
Previously we loop through local ports every second, this patch improves
the strategy by retrying only just disconnected emulators.

Bug: 26468076
Bug: 19974213
Bug: 22920867

Change-Id: I43ccb746922d104202b0f81a3d163d850bbc890e
2016-05-24 16:38:47 -07:00
Yabin Cui
8fc9d25841 Merge "adb: close ep0 on disconnection." into nyc-dev
am: fcab9a8507

* commit 'fcab9a85076c83e5b6808935db0f89e4f10dda87':
  adb: close ep0 on disconnection.

Change-Id: I2597ec4471378b341ef92b6aa0362511e09ac3ac
2016-05-24 00:23:39 +00:00
Yabin Cui
638420ef31 adb: close ep0 on disconnection.
adbd on device kicks the usb connection when usb IO fails. But to notify
adb on host to reconnect it, adbd needs to close ep0 to reset the usb
connection. Otherwise, adb on host cann't connect the device unless the
usb cable is reconnected or adb host server is restarted.

This can be tested by using `adb reconnect device` command.

Bug: 25935458

Change-Id: I80979d6029e60b9cfd218f7b9b5201810238ec07
(cherry picked from commit 69e97e4bee)
2016-05-23 17:17:46 -07:00
Yabin Cui
fcab9a8507 Merge "adb: close ep0 on disconnection." into nyc-dev 2016-05-24 00:15:27 +00:00
Yabin Cui
bb89e7e6b5 Merge "adb: check return value of register_socket_transport." am: 3d981c87c9
am: 1a78ec8f65

* commit '1a78ec8f6525e7101cb8f7d75f42955bbdbbd98e':
  adb: check return value of register_socket_transport.

Change-Id: I94be64825d5908d52d930125808f431fd6b96503
2016-05-21 01:27:05 +00:00
Yabin Cui
3d981c87c9 Merge "adb: check return value of register_socket_transport." 2016-05-21 01:12:35 +00:00
Josh Gao
014b01706c adb: use asocket's close function when closing.
close_all_sockets was assuming that all registered local sockets used
local_socket_close as their close function. However, this is not true
for JDWP sockets.

Bug: http://b/28347842
Change-Id: I40a1174845cd33f15f30ce70828a7081cd5a087e
(cherry picked from commit 53eb31d87c)
2016-05-18 17:20:30 -07:00
Josh Gao
268068f256 adb: switch the socket list mutex to a recursive_mutex.
sockets.cpp was branching on whether a socket close function was
local_socket_close in order to avoid a potential deadlock if the socket
list lock was held while closing a peer socket.

Bug: http://b/28347842
Change-Id: I5e56f17fa54275284787f0f1dc150d1960256ab3
(cherry picked from commit 9b587dec6d)
2016-05-18 17:20:30 -07:00
Josh Gao
63760409ad adb: clang-format sockets.cpp.
Bug: http://b/28347842
Change-Id: Ie3748b6c803d4e8056e9d7abd065a8b99d945a5b
(cherry picked from commit 52bd8526aa)
2016-05-18 17:20:30 -07:00
Josh Gao
6e106990cf adb: add implementations of mutex, recursive_mutex.
Our version of mingw doesn't support std::mutex or
std::recursive_mutex, so implement our own using the Windows primitives.

Bug: http://b/28347842
Change-Id: I4e1d56a89bc5fcb5f859bf5014343697a4a85b77
(cherry picked from commit 903b749f78)
2016-05-18 17:20:30 -07:00
Josh Gao
a41a0c2acc Merge "adb: use asocket\'s close function when closing." am: 684d543922
am: 43c058e51a

* commit '43c058e51a652874cfdf0c687ba1dee18f13f993':
  adb: use asocket's close function when closing.

Change-Id: I0681ff8c31c2f221e246a86857fbff779d2b7dcf
2016-05-19 00:16:11 +00:00
Treehugger Robot
684d543922 Merge "adb: use asocket's close function when closing." 2016-05-19 00:11:03 +00:00
Chih-Hung Hsieh
dccd3a3698 Merge "Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace." am: dab7d9de03
am: fa7569c921

* commit 'fa7569c921b9ca0db894287ea826cbd3b041d880':
  Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace.

Change-Id: I63223e36f3627d312051c86d54919b6cef33766c
2016-05-19 00:05:39 +00:00
Treehugger Robot
dab7d9de03 Merge "Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace." 2016-05-18 23:54:40 +00:00
Josh Gao
ebb08fb9a6 Merge changes I5e56f17f,Ie3748b6c,I4e1d56a8 am: cea14958d2
am: 71c062f40a

* commit '71c062f40ac9ac5175f55bce03ce0cb8eb540710':
  adb: switch the socket list mutex to a recursive_mutex.
  adb: clang-format sockets.cpp.
  adb: add implementations of mutex, recursive_mutex.

Change-Id: Icd8a74f1052f7b4c4616ddf23b65c7208195202c
2016-05-18 23:22:47 +00:00
Chih-Hung Hsieh
67867dbd79 Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace.
Bug: 28705665
Change-Id: I469b2a882f6d1f399bfc22c75a26da245991fc33
2016-05-18 15:53:15 -07:00
Josh Gao
53eb31d87c adb: use asocket's close function when closing.
close_all_sockets was assuming that all registered local sockets used
local_socket_close as their close function. However, this is not true
for JDWP sockets.

Bug: http://b/28347842
Change-Id: I40a1174845cd33f15f30ce70828a7081cd5a087e
2016-05-18 14:21:53 -07:00
Josh Gao
9b587dec6d adb: switch the socket list mutex to a recursive_mutex.
sockets.cpp was branching on whether a socket close function was
local_socket_close in order to avoid a potential deadlock if the socket
list lock was held while closing a peer socket.

Bug: http://b/28347842
Change-Id: I5e56f17fa54275284787f0f1dc150d1960256ab3
2016-05-18 14:21:53 -07:00
Josh Gao
52bd8526aa adb: clang-format sockets.cpp.
Bug: http://b/28347842
Change-Id: Ie3748b6c803d4e8056e9d7abd065a8b99d945a5b
2016-05-18 14:21:53 -07:00
Josh Gao
903b749f78 adb: add implementations of mutex, recursive_mutex.
Our version of mingw doesn't support std::mutex or
std::recursive_mutex, so implement our own using the Windows primitives.

Bug: http://b/28347842
Change-Id: I4e1d56a89bc5fcb5f859bf5014343697a4a85b77
2016-05-18 14:21:53 -07:00
Josh Gao
666d9aa507 Merge "adb: replace failing exits in adbd with abort()." am: eb62619ff9
am: 4e1149bb15

* commit '4e1149bb152829a016873bbc7795646b5ff5f384':
  adb: replace failing exits in adbd with abort().

Change-Id: I78b30130181d09a7755a48c6b769e33def622f7b
2016-05-17 23:06:17 +00:00
Josh Gao
1209092769 Merge "adb: add track-jdwp and track-devices commands." am: f8f40a1e2e
am: 32045567be

* commit '32045567be1f5af449dfa16173f16b70ae34e85b':
  adb: add track-jdwp and track-devices commands.

Change-Id: I60e9899b403fa68e3037aed3a4bce498c66c6c7d
2016-05-17 23:06:15 +00:00
Yabin Cui
01401823fb adb: check return value of register_socket_transport.
Change-Id: I45e30861cf292323e3264a815e4ffd23d6610c52
2016-05-17 15:15:43 -07:00
Josh Gao
8781256b19 Merge "adb/base: allow use of unique_fd inside adb." am: 210fdc2742
am: 881b440b7a

* commit '881b440b7a228e065d4b42ec71add07fbcb336c4':
  adb/base: allow use of unique_fd inside adb.

Change-Id: Ib1c437bcc6462235b8a753fb8cdedb9ff7261e9c
2016-05-16 22:02:55 +00:00
Josh Gao
4abdeee073 adb: replace failing exits in adbd with abort().
This makes it possible to get a core dump from adbd when it decides to
exit.

Bug: http://b/28347842
Change-Id: I4cfe5f273f62b2c32e61232d3c39881ecdd6b582
2016-05-14 18:52:46 -07:00
Josh Gao
b463baf610 adb: add track-jdwp and track-devices commands.
Expose these to the command line client to make it easier to poke
around.

Bug: http://b/28347842
Change-Id: Ia939b3a41eb8201365d50cd2996b83d884e42b64
2016-05-14 18:35:44 -07:00
Josh Gao
13ea01db45 adb/base: allow use of unique_fd inside adb.
adb implements its own file descriptor emulation layer on Windows,
which requires the use of adb_close instead of close throughout the
codebase. Add a template argument to unique_fd that allows for this.

Bug: http://b/28347842
Change-Id: I6397261f4973d49f2f8e04257bf67b348585bb63
2016-05-14 18:25:51 -07:00
David Pursell
1e57ab6f7b Merge "adb: support forwarding TCP port 0." am: cb90562bcf
am: 5aaffac37e

* commit '5aaffac37e2b2b32e645c0c03c96a88a3133b3ae':
  adb: support forwarding TCP port 0.

Change-Id: I2e7bd29de76a87b80e71ce00ed2da4666f3cbb56
2016-05-13 15:21:04 +00:00
David Pursell
eaae97e127 adb: support forwarding TCP port 0.
This CL adds support to forward or reverse TCP port 0 to allow the
system to automatically select an open port. The resolved port number
will be printed to stdout:
  $ adb forward tcp:0 tcp:8000
  12345
  $ adb reverse tcp:0 tcp:9000
  23456
This allows testing to be more robust by not hardcoding TCP ports which
may already be in use.

Forwarding port 0 is a host-only change and will work with any device,
but reversing port 0 requires the device to be updated with a new adbd
binary.

This CL also does a little bit of cleanup such as moving the alistener
class out of adb.h, and adds some error checking and additional tests.

Bug: 28051746
Test: python -m unittest discover
Test: adb_test
Test: `adb forward` and `adb reverse` with tcp:0
Change-Id: Icaa87346685b403ab5da7f0e6aa186aa091da572
2016-05-09 16:55:10 -07:00
Josh Gao
2928f7df70 Merge "adb: search for a maximum of 16 emulators." into nyc-dev
am: 72e47300fb

* commit '72e47300fb2d7842509c492fcb8ee363d43ef446':
  adb: search for a maximum of 16 emulators.

Change-Id: I51d01d4d1d8985c37c6cf3c4dbaa19eba49ae306
2016-05-06 21:32:31 +00:00
Josh Gao
72e47300fb Merge "adb: search for a maximum of 16 emulators." into nyc-dev 2016-05-06 21:23:28 +00:00
Josh Gao
9fe742684c adb: search for a maximum of 16 emulators.
Android Wear has unfortunately been using port 5601 for years, which
falls into the range of ports we were previously polling for Android
emulators. Reduce the maximum number of emulators we can support so
that 5601 no longer falls within our range.

Bug: http://b/26468076
Change-Id: I931809cfa412122f4781eebe0164facab12c95f0
2016-05-06 11:27:19 -07:00
Felipe Leme
6993211d38 Merge "Display warning about bugreport delay." into nyc-dev
am: f99193b7aa

* commit 'f99193b7aa8eedb0f5be448c6df6d2688c1bfb2e':
  Display warning about bugreport delay.

Change-Id: I19de3a7c8e98127322a4f8454d87e4be39c2d071
2016-05-05 03:05:22 +00:00
Felipe Leme
42e45c7068 Display warning about bugreport delay.
BUG: 28569299
Change-Id: Ide6109fd24737cbaf6296ef7326127e85d6420cb
2016-05-04 16:20:25 -07:00
Felipe Leme
d4611a9680 Automatically add a .zip to adb bugreport file when missing.
am: 644a36c209

* commit '644a36c20942029ece43ea9fbeb6163d4b706c56':
  Automatically add a .zip to adb bugreport file when missing.

Change-Id: I081fbac07cba3c7e3cbfc263ed71ee4832224d9b
2016-05-03 21:34:13 +00:00
Felipe Leme
644a36c209 Automatically add a .zip to adb bugreport file when missing.
BUG: 27653204
Change-Id: Ib322f1f9eeedd8e78c9a51a845a20c462442a0fe
2016-05-03 10:21:22 -07:00
Chih-hung Hsieh
fb44ca5178 Merge "Fix google-explicit-constructor warnings." am: 7bdd6a8b5a
am: 427d8d840f

* commit '427d8d840f6ec5ce5767b2ee521e4ac5b7ebd619':
  Fix google-explicit-constructor warnings.

Change-Id: I26dc45aca83f991aa7993f6d4233e0439dd44a22
2016-04-30 05:16:35 +00:00
Chih-Hung Hsieh
1c563d96f0 Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I4504e98a8db31e0edcbe63c23f9af43eb13e9d86
2016-04-29 15:44:04 -07:00
Yabin Cui
69e97e4bee adb: close ep0 on disconnection.
adbd on device kicks the usb connection when usb IO fails. But to notify
adb on host to reconnect it, adbd needs to close ep0 to reset the usb
connection. Otherwise, adb on host cann't connect the device unless the
usb cable is reconnected or adb host server is restarted.

This can be tested by using `adb reconnect device` command.

Bug: 25935458

Change-Id: I80979d6029e60b9cfd218f7b9b5201810238ec07
2016-04-28 16:01:10 -07:00
Yabin Cui
9b53e4c42c adb: fix adb usb operations on device.
Problem: For devices using /dev/usb-ffs/adb, Run
`while true; do adb reconnect device; sleep 1; done`. And the
device soon becomes offline. The adbd log shows that calling
adb_read(h->bulk_out) in usb_ffs_read() gets EOVERFLOW error.

Reason: When kicking a transport using usb-ffs, /dev/usb-ffs/adb/ep0
is not closed, and the device will not notify a usb connection reset
to host. So the host will continue to send unfinished packets even
if a new transport is started on device. The unfinished packets may
not have the same size as what is expected on device, so adbd on
device gets EOVERFLOW error. At the worst case, adbd has to create new
transports for each unfinished packet.

Fixes:
The direct fix is to make the usb connection reset when kicking transports,
as in https://android-review.googlesource.com/#/c/211267/1. And I think
we can make following improvements beside that.
1. Close a file that is used in other threads isn't safe. Because the file
descriptor may be reused to open other files, and other threads may operate
on the wrong file. So use dup2(dummy_fd) to replace close() in kick function,
and really close the file descriptor after the read/write threads exit.

2. Open new usb connection after usb_close() instead of after
usb_kick(). After usb_kick(), the transport may still exist and
reader/writer for the transport may be still running. But after
usb_close(), the previous transport is guaranteed to be destroyed.

Bug: 25935458
Change-Id: I1eff99662d1bf1cba66af7e7142f4c0c4d82c01b
(cherry picked from commit 005bf1e05b)
2016-04-26 17:43:14 -07:00
Treehugger Robot
02e8b642af Merge "adb: decrease the number of fds used in fd_count test." am: c296440
am: dbb3e3b

* commit 'dbb3e3ba92b090afa32808cbb504d4c653f5311c':
  adb: decrease the number of fds used in fd_count test.

Change-Id: Id48542904272ac506eec121fa21cbed374b9408d
2016-04-27 00:11:26 +00:00
Yabin Cui
71bddf842d adb: use a custom thread to poll for usb devices on mac.
On mac, if the adb server kicks a transport on some error, mac usb driver
will not report a new usb device. So instead of relying on mac usb driver
to report new usb devices, this CL uses a loop to search for usb devices
not exist before. Note that this is also the behavior on windows and linux
host.
`adb reconnect` can be used to verity this CL.

Bug: 25935458
Change-Id: I890e0eb1fae173f2e7a0c962ededa294d821e015
(cherry picked from commit 48d4c0c42a)
2016-04-26 17:00:49 -07:00
Josh Gao
858f133d41 adb: decrease the number of fds used in fd_count test.
Default limit is 1024 fds, which means 512 socketpairs will hit the
limit.

Bug: http://b/28386497
Change-Id: Ib36404c050e4be3db51378e250f300f7ec5aab13
2016-04-26 15:45:23 -07:00
Treehugger Robot
023dc9ab5c Merge "adb: fix test_device.py shell protocol checks." am: 52eb602
am: 8a77b30

* commit '8a77b300bead94a90a62dce2e53526cd2d2071ae':
  adb: fix test_device.py shell protocol checks.

Change-Id: I92176c64aeabb9195b69efc2ced1b2c38a70de6c
2016-04-26 21:48:12 +00:00
David Pursell
cf46741b4f adb: fix test_device.py shell protocol checks.
https://android-review.googlesource.com/#/c/210646/ added a
has_shell_protocol() function but the test_device.py tests were still
trying to use the now-missing SHELL_PROTOCOL_FEATURE constant.

This CL just switches test_device.py to correctly use the
has_shell_protocol() method.

Change-Id: Ie0a2f0dc07529843d25051a01e08fb677551a4e1
Test: `python -m unittest discover -v` on devices with and without
      the shell protocol.
2016-04-26 13:29:39 -07:00
Yabin Cui
ba8498b41b Merge "adb: fix socket tests." am: e998abd
am: 61f6d1d

* commit '61f6d1df52649eb9611ca908cddd55bbad3149bc':
  adb: fix socket tests.

Change-Id: I686c5799014abdf00203a4c4df0b5c02b9ac7102
2016-04-26 03:07:44 +00:00
Yabin Cui
2407d7c3d9 adb: fix socket tests.
Bug: 28386497

Change-Id: I9f37ecadf3cfc6bb4e5da502d40f49e1f3a16d8a
2016-04-25 19:51:58 -07:00
Yabin Cui
a28918cf30 Fix kick_transport test.
Fix broken kick_transport test, and make it not access atransport
internal variables.

Bug: 25935458
Change-Id: I91b4d32a222b2f369f801bbe3903acac9c8ea4f7
(cherry picked from commit 7f27490e7f)
2016-04-25 17:37:08 -07:00
Yabin Cui
799e80334c Merge "adb: fix adb usb operations on device." am: ad2021a
am: ec4db8f

* commit 'ec4db8f14f8ecc122505f17f93ca7e34ced409b4':
  adb: fix adb usb operations on device.

Change-Id: I6daa50bfdb968ef3f1371f30ee3a378630169ce7
2016-04-25 17:41:41 +00:00
Yabin Cui
ad2021a1b1 Merge "adb: fix adb usb operations on device." 2016-04-25 17:19:03 +00:00
Zach Riggle
f9f0b5f413 Merge "Fix NULL deref on exec-in with insufficient arguments" am: 245e4dbfd4
am: a0690543da

* commit 'a0690543dac2792508caef09e9e97804b31fea24':
  Fix NULL deref on exec-in with insufficient arguments

Change-Id: Ic5e62d01fecc77aace676bf6cdf4218f93806860
2016-04-22 15:53:55 +00:00
Zach Riggle
ccafc79de7 Fix NULL deref on exec-in with insufficient arguments
(cherry-pick of 566a28169b84836fddd5ae96db9b147237ea054f.)

Bug: 28152091
Change-Id: Ib59e3bf7f26974aa09d2e6a0e1d9281d7ce25511
2016-04-22 08:08:01 -07:00
Yabin Cui
e618f6cb36 Merge "adb: use a custom thread to poll for usb devices on mac." am: 09c5fcf
am: 507f38f

* commit '507f38f6d7e8dcae4b513ea6c5f638ae43204245':
  adb: use a custom thread to poll for usb devices on mac.

Change-Id: Idc21e33a8b0942afe0f6fa18076718d71d9d34f6
2016-04-19 20:38:07 +00:00
Yabin Cui
48d4c0c42a adb: use a custom thread to poll for usb devices on mac.
On mac, if the adb server kicks a transport on some error, mac usb driver
will not report a new usb device. So instead of relying on mac usb driver
to report new usb devices, this CL uses a loop to search for usb devices
not exist before. Note that this is also the behavior on windows and linux
host.
`adb reconnect` can be used to verity this CL.

Bug: 25935458
Change-Id: I890e0eb1fae173f2e7a0c962ededa294d821e015
2016-04-19 11:26:44 -07:00
Yabin Cui
2f46a7d0ec Merge "Fix kick_transport test." am: a960864
am: 119ca23

* commit '119ca2345d97db04d4114f5031d172f3694350d4':
  Fix kick_transport test.

Change-Id: I4625174a1d62edfa8a1db52ced70356798d53c95
2016-04-19 02:57:56 +00:00
Yabin Cui
a960864355 Merge "Fix kick_transport test." 2016-04-19 02:29:29 +00:00
TreeHugger Robot
a9e818f463 Merge changes Ia4a2ff77,I970806e3,I47daa338 into nyc-dev
* changes:
  adb: increase the FD table size on Win32.
  adb: bump the server version to 36.
  adb: add reconnect command.
2016-04-19 00:51:22 +00:00
Josh Gao
826bdace3d Merge changes Iaf0efc0c,Ia4a2ff77 am: c4f3546
am: c5b388f53a

* commit 'c5b388f53a5666daa368f597c7e190f7f31f2b8a':
  adb: disable tests that are expected to fail on Win32.
  adb: increase the FD table size on Win32.

Change-Id: Ifcc55e62935c95c8b34fa0d1973277a08916fad2
2016-04-19 00:28:58 +00:00
Josh Gao
d1e2300a71 adb: increase the FD table size on Win32.
128 maximum FDs is a pretty low limit, which can easily be exhausted by
port forwarding. Bump the maximum up to 2048, and add a test that checks
whether we can actually use a few hundred sockets.

Bug: https://code.google.com/p/android/issues/detail?id=12141
Bug: http://b/28246942
Change-Id: Ia4a2ff776e8e58ec13378756f19d80392679ece9
(cherry picked from commit b31e17107c)
2016-04-18 15:46:25 -07:00