Commit graph

1985 commits

Author SHA1 Message Date
Josh Gao
fb0c5cb28c adb: improve display of transfer rate.
Show transfer rate for individual files, and for the overall transfer.

Bug: http://b/30411535
Change-Id: If2f3008f1287b1d1add4a23c3430b39885b6c904
Test: inspected output manually
2016-08-04 18:03:09 -07:00
Josh Gao
1a9979ec1e adb: add missing newline when printing transfer rate.
Previously, we weren't printing a newline when reporting transfer
rates, so only the last transfer rate printed would be visible.

Bug: http://b/30667841
Change-Id: Id341147912d057673de4ad26a8f618f04a8c02f3
Test: inspected output manually
2016-08-04 14:56:53 -07:00
Josh Gao
baa215ea59 adb: fix output of sync -l
sync with list-only was using SyncConnection::Error to print its output
persistently, which would prepend "adb: error: " to messages.

Change-Id: I90df5fc1123b8c613c811cf66c37aef05663b1e4
2016-08-04 14:56:53 -07:00
Josh Gao
0889353fa5 Merge changes I1d398d19,I8f20b3cd
am: c97b73aa83

Change-Id: I9a22ba63f4306c17933624f4c99380702f6e701e
2016-08-01 22:00:22 +00:00
Treehugger Robot
c97b73aa83 Merge changes I1d398d19,I8f20b3cd
* changes:
  adb: fix stat on Windows.
  adb: extract Windows bits out of directory_exists test.
2016-08-01 21:54:00 +00:00
Chih-Hung Hsieh
4c4fa90462 Merge \"Fix clang-tidy performance warnings in syste/core.\"
am: 4efbce14b5

Change-Id: I84f6b0134fae6e9f40710f243f4825e3f31fa15f
2016-08-01 20:23:10 +00:00
Josh Gao
f551ea0f63 adb: fix stat on Windows.
stat on Windows fails with ENOENT when passed a path with a trailing
slash or backslash, regardless of whether the target is actually a
directory. Emulate the correct POSIX behavior by stripping trailing
path separators and then checking if the target is a directory if
successful.

Bug: http://b/30481559
Bug: https://code.google.com/p/android/issues/detail?id=214633
Change-Id: I1d398d19a9bce1ecb3fdc4aabc31aa98c82c3f93
Test: Relevant adb_tests pass on Linux and Windows 10.
2016-08-01 12:36:04 -07:00
Chih-Hung Hsieh
8f7b9e3d39 Fix clang-tidy performance warnings in syste/core.
* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
2016-08-01 11:55:42 -07:00
Josh Gao
3bdc76025b adb: extract Windows bits out of directory_exists test.
Bug: http://b/30481559
Bug: https://code.google.com/p/android/issues/detail?id=214633
Change-Id: I8f20b3cd5aef6a77c2b4f194b914b4295397d73f
2016-07-28 18:36:01 -07:00
Jorge Lucangeli Obes
3ab30ecf4c Merge \"Use arraysize() for supplementary groups.\"
am: ddbcecec3a

Change-Id: Ia8405d8bc181b1cdbf1f0812c0dbe8f7701747ef
2016-07-18 20:06:19 +00:00
Jorge Lucangeli Obes
bae15b4f46 Use arraysize() for supplementary groups.
Also make adbd use ScopedMinijail.

Bug: 30191189
Change-Id: I5e259aa466817b51037912aba043ba75bd35f9e1
2016-07-18 13:46:42 -04:00
Elliott Hughes
7191a56e96 Merge \"Remove unnecessary ARRAY_SIZE macros.\"
am: c37d8ea22a

Change-Id: Id3443d7247e893ee549ae5b799a8f0bf42088d35
2016-06-29 00:16:44 +00:00
Elliott Hughes
749ae2d32f Remove unnecessary ARRAY_SIZE macros.
Use the canonical one instead.

Change-Id: Id80f19455f37fd2a29d9ec4191c1a0af80c5c0e7
2016-06-28 14:48:45 -07:00
Josh Gao
a4e35be4a4 Merge \"adb: refactor jdwp_service.cpp.\"
am: 71d11ade9d

Change-Id: If7940e3a0b3a457d9be29dfb6c0707dbe8961397
2016-06-23 23:31:38 +00:00
Treehugger Robot
71d11ade9d Merge "adb: refactor jdwp_service.cpp." 2016-06-23 23:28:25 +00:00
Josh Gao
05f889dd4e Merge \"adb: add test for SIGHUP behavior.\"
am: a355dd6110

Change-Id: Ib786fefd55a2a4533bf66dc1e47f88e398beb8e1
2016-06-23 23:12:05 +00:00
Josh Gao
fe50bb713b adb: add test for SIGHUP behavior.
This keeps regressing, so add a test to keep this from happening.

Bug: http://b/23603716
Bug: http://b/25965770
Bug: http://b/29565233
Test: Ran test with/without commit cd5d737, fails before, passes after
Change-Id: I8c431e10fc76da5a9fd404dd70f17bb8a8df24e6
2016-06-23 15:01:50 -07:00
Josh Gao
79a69f0bd7 Merge changes Ia59c6dbe,I13b17bcd
am: 0b47d08303

Change-Id: Ica4c5de30e12f6950f0a9f3a2dc94213ef2fe70a
2016-06-23 21:25:10 +00:00
Josh Gao
e31a7a4ce4 adb: fix fd leak when shell fails to create a thread.
Bug: http://b/29565233
Change-Id: Ia59c6dbe5ac033425c11739579e85cbcad1170d1
2016-06-23 13:14:49 -07:00
Josh Gao
cd5d7376dc adb: don't dup local socket fd.
SIGHUP handling depends on the local socket fd being fully closed in
order to trigger an event on its counterpart. Release the local socket
fd inside of Subprocess when returning it to ensure this.

Functionally, a cherry-pick of internal commit 42afe20.

Bug: http://b/29565233
Change-Id: I13b17bcddf0b396a5f4880f9e410fbbf24d9370d
2016-06-22 19:09:42 -07:00
Elliott Hughes
a81117b8f9 Merge \"Address old review comments in adb_auth_host.cpp.\"
am: 57bbedc036

Change-Id: I0ab20c9258d42e6b0b847e8eb69382005f086706
2016-06-22 17:17:51 +00:00
Treehugger Robot
57bbedc036 Merge "Address old review comments in adb_auth_host.cpp." 2016-06-22 17:09:26 +00:00
Elliott Hughes
625faf0196 Address old review comments in adb_auth_host.cpp.
Comments from:
https://android-review.googlesource.com/#/c/212781/4/adb/adb_auth_host.cpp@107

Bug: http://b/28152031
Change-Id: I27d062f3eeb8db90f94b1b4f5d7204000a7ac73d
Test: manually removed ~/.android/adb* and checked they were recreated correctly.
2016-06-22 08:38:47 -07:00
David 'Digit' Turner
1c01bae82a Merge \"[qemu]: Move qemu_pipe.h from include/system/ directory.\"
am: 44b7339aa2

Change-Id: I59b9a896058dea76f69b9ba757890d4a42952a66
2016-06-21 08:05:18 +00:00
David Turner
44b7339aa2 Merge "[qemu]: Move qemu_pipe.h from include/system/ directory." 2016-06-21 07:38:02 +00:00
Josh Gao
88347e1430 Merge changes from topic \'debuggerd_client\'
am: abf88685e3

Change-Id: I2a61e4e8b5ec5a4ab6566ab4f8eb31653255fbc5
2016-06-20 20:47:18 +00:00
Josh Gao
34c6ca01ff Merge \"adb: fix fd double close, Subprocess lifetime issue.\"
am: b23e5729a8

Change-Id: I96db140e4316b767fb632307a435bc3e22cbfb36
2016-06-20 20:47:17 +00:00
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