Commit graph

1452 commits

Author SHA1 Message Date
David Pursell
0f427fead7 am 5d1a943d: am 002f9d5c: Merge "adb: fix adbd feature parsing for no features."
* commit '5d1a943dc49dcb1513d64e281efb522d704dea02':
  adb: fix adbd feature parsing for no features.
2015-09-28 16:14:30 +00:00
David Pursell
edf0728e2d am a36f4d68: Merge "adb: bump server version to prevent feature mismatch."
* commit 'a36f4d680a02dbf2bf2166f148f4c5200ec1d8f4':
  adb: bump server version to prevent feature mismatch.
2015-09-28 16:06:24 +00:00
David Pursell
5d1a943dc4 am 002f9d5c: Merge "adb: fix adbd feature parsing for no features."
* commit '002f9d5c70058e8db78a61d65384fd9510cf4ffd':
  adb: fix adbd feature parsing for no features.
2015-09-28 16:06:22 +00:00
David Pursell
a36f4d680a Merge "adb: bump server version to prevent feature mismatch." 2015-09-28 16:03:21 +00:00
David Pursell
d2b588e239 adb: fix adbd feature parsing for no features.
Previously the transport features list was only overwritten if a
new feature list was found. However, adbd can reuse the same atransport
object even if the adb server is killed and restarted, so the feature
list was not cleared properly if the newly started adb server didn't
provide one.

This CL fixes the bug by clearing the transport features list whenever
a connection banner is parsed.

Bug: http://b/24405971
Change-Id: Ia6ee6c9a46a621534681f6d4d7df77156b885eb9
2015-09-25 13:10:17 -07:00
David Pursell
bbe3d210ba adb: bump server version to prevent feature mismatch.
Devices get a list of supported features from the adb server, not the
client, so a mismatch between client and server features can cause the
device to use an incorrect feature set.

Bumping the server version is the easiest way to make sure the client
and server features match and seems like the best solution at the
moment.

A more automated fix could be to compare client/server features on each
connection and restart if they don't match. This requires an extra
client <-> server round-trip per command, but removes the need to
manually bump the server version number on feature change. Unless the
feature set changes often it didn't seem worth the extra overhead.

Bug: http://b/24370690
Change-Id: I4e43825d1c15c61e5d924fc8d4110b467debde37
2015-09-25 09:59:31 -07:00
Yabin Cui
b8db64313a am 56ece709: am e4975da3: Merge "Adb: use VLOG() to replace D() for verbose logging."
* commit '56ece709b093aa7570aa2915fa98682113acc5cb':
  Adb: use VLOG() to replace D() for verbose logging.
2015-09-23 23:16:09 +00:00
Yabin Cui
56ece709b0 am e4975da3: Merge "Adb: use VLOG() to replace D() for verbose logging."
* commit 'e4975da33326295885f4c606288516d73459c68e':
  Adb: use VLOG() to replace D() for verbose logging.
2015-09-23 23:00:18 +00:00
Yabin Cui
aed3c61c44 Adb: use VLOG() to replace D() for verbose logging.
As there are too many D(), we can keep both VLOG() and D() now, and get
rid of D() gradually.

Change-Id: I2f1cb70bcab3e82c99fed939341d03f6b2216076
2015-09-23 12:53:38 -07:00
David Pursell
90f297ada1 am b0d84d16: am 36856b73: Merge "adb: add -Tt options to adb shell."
* commit 'b0d84d16ffeabd3aa1b9d9ecf48110ff4f8508e7':
  adb: add -Tt options to `adb shell`.
2015-09-22 20:38:57 +00:00
David Pursell
b0d84d16ff am 36856b73: Merge "adb: add -Tt options to adb shell."
* commit '36856b7306b50e22f98c3299a6c951cb74fd1854':
  adb: add -Tt options to `adb shell`.
2015-09-22 20:31:25 +00:00
David Pursell
4e2fd36bc8 adb: add -Tt options to adb shell.
Adds -T (no PTY) and -t (force PTY) options to `adb shell` to mimic
ssh options. Small cleanup to send an entire FeatureSet to the adb
client at once to avoid multiple round-trips when querying multiple
features.

Known issue: humans using `adb shell -T` to start a non-PTY interactive
session may experience problems since neither side will have PTY
features like echoing or newline translation. This is probably OK for
now as the -Tt options are primarily useful for scripting.

Bug: http://b/23825231
Change-Id: I4d0df300db0abd1f7410bab59dd4d5b991babda7
2015-09-22 12:50:11 -07:00
Yabin Cui
03581ce1ea am 46a005c3: am 2b5f5fb9: Merge "base logging: fix errno restoring, severity conditionality, dangling ifs"
* commit '46a005c3d9a6557985316a1ee802880e99cc2407':
  base logging: fix errno restoring, severity conditionality, dangling ifs
2015-09-21 20:13:06 +00:00
Yabin Cui
46a005c3d9 am 2b5f5fb9: Merge "base logging: fix errno restoring, severity conditionality, dangling ifs"
* commit '2b5f5fb9d94d13809af6967fb3adb40669ddfb49':
  base logging: fix errno restoring, severity conditionality, dangling ifs
2015-09-21 20:04:54 +00:00
Yabin Cui
2b5f5fb9d9 Merge "base logging: fix errno restoring, severity conditionality, dangling ifs" 2015-09-21 19:56:52 +00:00
Spencer Low
765ae6bcfc base logging: fix errno restoring, severity conditionality, dangling ifs
Fix LOG() to properly save and restore errno. Test this properly.

Only do logging if severity is >= the minimum.

Fix dangling if statements in CHECK(), CHECK_STR{EQ,NE}(). Test this
properly.

Fix base logging tests on Windows. All libbase_tests now pass on
Windows.

Change place to lock, so the lock can protect logging of all data in
LogMessage.

Change-Id: I7ff531c67ae10a99ef0a2bbfe279aa77282d5ae9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-21 12:46:12 -07:00
Dan Albert
82b9e94173 am 1bcb4677: am 71f878f8: Merge "Move python-adb to development/python-packages."
* commit '1bcb4677b0a9aaf4c62db073bc878a7249c8028c':
  Move python-adb to development/python-packages.
2015-09-21 17:42:11 +00:00
Dan Albert
1bcb4677b0 am 71f878f8: Merge "Move python-adb to development/python-packages."
* commit '71f878f89b6bc6df960e857836467a059802c61e':
  Move python-adb to development/python-packages.
2015-09-21 17:34:29 +00:00
Dan Albert
8858883388 Move python-adb to development/python-packages.
We want to be able to use this in the NDK without having to pull in
all of system core.

Also, this clarifies the separation of adb and its python interface.

Bug: http://b/22881740
Change-Id: I0b437d9bf621e371d4698d7f8e8828072c7ff347
2015-09-18 13:39:13 -07:00
Elliott Hughes
15b9dbad7f am 8fd98104: am a951a82d: Merge "adb unittest for win32 handle inheritance"
* commit '8fd981040d6396d74ccbaafbb28688aedc34e6bb':
  adb unittest for win32 handle inheritance
2015-09-17 22:20:23 +00:00
Elliott Hughes
8fd981040d am a951a82d: Merge "adb unittest for win32 handle inheritance"
* commit 'a951a82dcc9cbefb4162a048d5d668dcb855cbf5':
  adb unittest for win32 handle inheritance
2015-09-17 22:08:42 +00:00
Spencer Low
1ce06087db adb unittest for win32 handle inheritance
adb.cpp: launch_server() has a long comment about how
stdin/stdout/stderr handles have to be made non-inheritable to prevent
hangs in callers to adb.exe.

It would be disastrous to do this wrong, and I've modified this code, so
here's a unittest to verify that I'm doing it right.

The test also runs fine on unix.

Change-Id: I3672c3066bc7498635c19212f9e5c50757942439
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-16 20:50:53 -07:00
Elliott Hughes
8057b81e22 am 09a0d98b: am 1d758c90: Merge "adb unittest: make test_sync properly cleanup after itself"
* commit '09a0d98bebce23f014ea11af002c1fafaf6b8065':
  adb unittest: make test_sync properly cleanup after itself
2015-09-17 03:17:27 +00:00
Elliott Hughes
09a0d98beb am 1d758c90: Merge "adb unittest: make test_sync properly cleanup after itself"
* commit '1d758c90959225c76ed4d318290ad1bf11532409':
  adb unittest: make test_sync properly cleanup after itself
2015-09-17 03:10:54 +00:00
Elliott Hughes
1d758c9095 Merge "adb unittest: make test_sync properly cleanup after itself" 2015-09-17 03:03:31 +00:00
Yabin Cui
c375568401 am eee68196: am 0b743df4: Merge "Add unit tests for local socket."
* commit 'eee68196e9198b781e23fa01d3f82bd60d515cca':
  Add unit tests for local socket.
2015-09-17 02:45:48 +00:00
Yabin Cui
eee68196e9 am 0b743df4: Merge "Add unit tests for local socket."
* commit '0b743df4c4813d59c0405fbb32d59441399d8478':
  Add unit tests for local socket.
2015-09-17 02:38:45 +00:00
Yabin Cui
0b743df4c4 Merge "Add unit tests for local socket." 2015-09-17 02:32:12 +00:00
Elliott Hughes
853e6b79c2 am b9b05199: am d17cf08e: Merge "adb: win32: fix regression on older versions of Windows"
* commit 'b9b0519995d4beeee9c443f046315b18305d369f':
  adb: win32: fix regression on older versions of Windows
2015-09-17 00:16:23 +00:00
Elliott Hughes
b9b0519995 am d17cf08e: Merge "adb: win32: fix regression on older versions of Windows"
* commit 'd17cf08eca500a96f4808744b8a0a34664291de8':
  adb: win32: fix regression on older versions of Windows
2015-09-17 00:08:43 +00:00
Spencer Low
bc36bdbdc8 adb: win32: fix regression on older versions of Windows
On Windows 7, GetStdHandle() may return console pseudo-handles. If you
call SetHandleInformation(h, HANDLE_FLAG_INHERIT, 0) on such a handle,
it will fail. These failures should be ignored like the old code.

Newer versions of Windows return real handles that don't have this
issue. Console pseudo-handles can apparently be identified by the values
3, 7, 11.

This is a regression from 2122c7a148.

https://code.google.com/p/android/issues/detail?id=186599

Change-Id: I287a74a81d37e0ebe62d673a3f5651ee5439c0d2
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-16 16:40:06 -07:00
Yabin Cui
c1b1f6ff5d Add unit tests for local socket.
Add has_write_error flag in asocket, so it will not wait on local_socket_closing_list
to write pending packets in local_socket_close(). Although it doesn't fix any problem,
it helps to make the code more stable.
Add a missing put_apacket() in error handling.
Add a check when adding local socket in local_socket_closing_list.

Bug: 23314034

Change-Id: I75b07ba8ee59b7f277fba2fb919db63065b291be
2015-09-16 15:00:59 -07:00
Yabin Cui
971d17f251 am c8a5b0b6: am fa965d96: Merge "adb: move adb to poll."
* commit 'c8a5b0b6535aed78e4f213ab4bf4262a6d475263':
  adb: move adb to poll.
2015-09-15 21:19:15 +00:00
David Pursell
21bfc391ea am 2017030b: am d9076f21: Merge "adb: Kill subprocess when the client exits."
* commit '2017030b49b22b9abc4b47cc1d15882d7e7f3e21':
  adb: Kill subprocess when the client exits.
2015-09-15 21:19:14 +00:00
Yabin Cui
c8a5b0b653 am fa965d96: Merge "adb: move adb to poll."
* commit 'fa965d9639dc264bb0d18e71dff998a4f648b50d':
  adb: move adb to poll.
2015-09-15 20:05:02 +00:00
David Pursell
2017030b49 am d9076f21: Merge "adb: Kill subprocess when the client exits."
* commit 'd9076f2132006505227e5fec91926acb512c3d68':
  adb: Kill subprocess when the client exits.
2015-09-15 20:04:58 +00:00
Yabin Cui
fa965d9639 Merge "adb: move adb to poll." 2015-09-15 18:40:51 +00:00
David Pursell
544e795fbb adb: Kill subprocess when the client exits.
When the client exits (e.g. with Ctrl+C) the subprocess should be
notified as well so it can cleanup if needed.

Bug: http://b/23825725
Change-Id: Idb771710b293e0a9f7bebc9e2814b3a816e2c50e
2015-09-15 10:16:24 -07:00
Yabin Cui
a10801674c adb: move adb to poll.
It is reported that the registered fd can be bigger than FD_SETSIZE, and can't be
handled by select(). By moving to poll(), we can remove the limitation.
Although we can't ignore the possibility that there is a fd leak, but we can
still make the potential bug more explicit by moving to poll().
We didn't move to epoll() because it is not supported on mac.

Bug: 23820751

Change-Id: Icb39329c4984f1fef749472c9e088682ee8c3444
2015-09-15 10:12:31 -07:00
David Pursell
de6aed81c8 am a3ef4fad: am 0af19a0e: Merge "adb: Fix missing shell protocol usage."
* commit 'a3ef4fad70692c88819b95a41437c03e9a3398a6':
  adb: Fix missing shell protocol usage.
2015-09-15 15:18:55 +00:00
David Pursell
a3ef4fad70 am 0af19a0e: Merge "adb: Fix missing shell protocol usage."
* commit '0af19a0e82d7808678f3b92a8c5b4b8cb80ee216':
  adb: Fix missing shell protocol usage.
2015-09-15 15:12:33 +00:00
Spencer Low
80fdc0bf86 adb unittest: make test_sync properly cleanup after itself
It wasn't deleting the tempfile.mkdtemp() dir that it made.

Change-Id: I59c5f98aa8297c7b28d38799dd21ffe9566f2145
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-14 18:53:25 -07:00
David Pursell
71c83126a8 adb: Fix missing shell protocol usage.
Some adb commands use the shell service but weren't using the
shell protocol, causing a protocol mismatch between the client and
the device. This CL uses the shell protocol whenever possible.

Change-Id: I4c9c75b7fd1d5bf3dc1f73900711840270527682
2015-09-14 15:33:50 -07:00
David Pursell
e4c0454083 am 07448e07: am 76f4a653: Merge changes from topic \'adb_shell\'
* commit '07448e072e50703b01aca9f99cf03ead030746de':
  adb: add client side shell protocol and enable.
  adb: implement shell protocol.
2015-09-14 18:52:42 +00:00
David Pursell
07448e072e am 76f4a653: Merge changes from topic \'adb_shell\'
* commit '76f4a6533c6b803e267225b42c5dda63f23bf3ea':
  adb: add client side shell protocol and enable.
  adb: implement shell protocol.
2015-09-14 18:45:34 +00:00
David Pursell
76f4a6533c Merge changes from topic 'adb_shell'
* changes:
  adb: add client side shell protocol and enable.
  adb: implement shell protocol.
2015-09-14 18:39:37 +00:00
David Pursell
9a5c3775d4 am 3b43b161: am 7b749acd: Merge "adb: fix shell_service_protocol_test for Windows."
* commit '3b43b161824946cca173d66694c8941f94a7aca2':
  adb: fix shell_service_protocol_test for Windows.
2015-09-12 01:44:40 +00:00
David Pursell
3b43b16182 am 7b749acd: Merge "adb: fix shell_service_protocol_test for Windows."
* commit '7b749acd5f7de9448f851e84ac2d3d90d28e5f03':
  adb: fix shell_service_protocol_test for Windows.
2015-09-12 01:37:50 +00:00
David Pursell
b404dec85a adb: fix shell_service_protocol_test for Windows.
Adds missing #ifdef guards to shell_service_protocol_test.cpp so the
test compiles on Windows.

Also fixes a bug in Windows socketpair write implementation. Previously
it was only checking for a closed pipe if the write happened to block.
This adds an additional pre-check to exit immediately on a closed pipe.

These two changes allow the test to compile and pass on Windows.

Change-Id: Ib8853ed72f015fc0d623da47c32982cb3ffa4a3d
2015-09-11 18:28:27 -07:00
Elliott Hughes
e3082990cd am e917d8ed: am 9336ee38: Merge "Fix (Windows) build."
* commit 'e917d8ed629eda66fa1218ee6564a31409c2afe8':
  Fix (Windows) build.
2015-09-11 23:30:36 +00:00
Elliott Hughes
83226d0439 am 61eee363: am 0ad13cf2: Merge "fix adb_test Windows build"
* commit '61eee3636f96a0b32be3304796e6af4421d03a4e':
  fix adb_test Windows build
2015-09-11 23:30:35 +00:00
Elliott Hughes
e917d8ed62 am 9336ee38: Merge "Fix (Windows) build."
* commit '9336ee389f79296d04790d1a1dab6f55b6a4c221':
  Fix (Windows) build.
2015-09-11 23:23:52 +00:00
Elliott Hughes
61eee3636f am 0ad13cf2: Merge "fix adb_test Windows build"
* commit '0ad13cf2982d428a4db742877720e5f4be738fa4':
  fix adb_test Windows build
2015-09-11 23:23:50 +00:00
Elliott Hughes
2f577205fc Fix (Windows) build.
Change-Id: Ib9afd101d255d748ba6c15ed8075f3d10338c95c
2015-09-11 16:18:24 -07:00
Elliott Hughes
a480aa1d67 am 0b60dae6: am ee46239c: Merge "adb: win32: make adb_getenv() case-insensitive"
* commit '0b60dae6d342d336a7e1c4ae86058d3099c643c5':
  adb: win32: make adb_getenv() case-insensitive
2015-09-11 23:14:04 +00:00
Elliott Hughes
0ad13cf298 Merge "fix adb_test Windows build" 2015-09-11 23:13:40 +00:00
David Pursell
8b39e2ff58 am 90ba84b2: am 31139af0: Merge "adb: create shell protocol class (take 2)."
* commit '90ba84b2868580ab357f8b5f049bc59df0a58d1f':
  adb: create shell protocol class (take 2).
2015-09-11 23:05:42 +00:00
Elliott Hughes
0b60dae6d3 am ee46239c: Merge "adb: win32: make adb_getenv() case-insensitive"
* commit 'ee46239c358fac90813128fccbcb49292f8b04f3':
  adb: win32: make adb_getenv() case-insensitive
2015-09-11 23:05:02 +00:00
Spencer Low
e6ae573571 adb: win32: make adb_getenv() case-insensitive
adb_getenv() should be case-insensitive just like the real getenv() on
Windows.

Added a unittest for adb_getenv(). In the process, made adb_test link
with -municode so that the environment block is Unicode.

Move wmain() from main.cpp to sysdeps_win32.cpp so that adb_test could
also use it.

Because wmain() moved, it wasn't as easy to do the runtime check to
verify that -municode was used, so do that check in _ensure_env_setup()
since adb_getenv() is called early in adb anyway.

Added a utility ToLower() which is good enough for env vars whose keys
are probably always ASCII to begin with.

Change-Id: I082f7fdee9dfe2c7f76b878528d2f7863df6d8d1
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-11 15:53:08 -07:00
Spencer Low
ebf770fd73 fix adb_test Windows build
adb/Android.mk: adb_test should build on Windows (and Darwin), so add to
the whitelist.

Change-Id: I778f6a7dff4caec92c48e0957591abf32f86ab1b
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-11 15:47:20 -07:00
David Pursell
90ba84b286 am 31139af0: Merge "adb: create shell protocol class (take 2)."
* commit '31139af04f97c843db2a98c7fafc1d58d7f7c8ac':
  adb: create shell protocol class (take 2).
2015-09-11 22:14:17 +00:00
David Pursell
606835ae5c adb: add client side shell protocol and enable.
Adds the shell protocol functionality to the client side and enables it
if the transport supports the feature.

Bug:http://b/23031026
Change-Id: I9abe1c8b1d39f8dd09666321b1c761ad708a8854
2015-09-11 13:02:17 -07:00
David Pursell
0955c66b22 adb: implement shell protocol.
Adds functionality for handling stdin/stdout/stderr streams and exit
codes using the shell protocol.

This CL just contains implementation for adbd which will not yet be
enabled. Once we have the ability to query transport features from the
adb client, another CL will add the implementation for the client side
and update the feature list to turn this on.

Note: this CL must be submitted together with a minadbd CL to update
the service_to_fd() function signature.

Bug: http://b/23030641

Change-Id: Ibed55e9c1946d8a35190696163ff63e8fb880238
2015-09-11 11:27:50 -07:00
David Pursell
31139af04f Merge "adb: create shell protocol class (take 2)." 2015-09-11 18:17:55 +00:00
Dan Willemsen
2f6d1e5486 am a376c046: am aaf4fcf4: Merge "Remove HOST_OS==windows check"
* commit 'a376c046bf7f5f86b53190d1f8dab309dd80a58b':
  Remove HOST_OS==windows check
2015-09-09 18:31:10 +00:00
Dan Willemsen
a376c046bf am aaf4fcf4: Merge "Remove HOST_OS==windows check"
* commit 'aaf4fcf482d427459c70e10a22fef5ea9c7bca1a':
  Remove HOST_OS==windows check
2015-09-09 18:19:15 +00:00
Dan Willemsen
aaf4fcf482 Merge "Remove HOST_OS==windows check" 2015-09-09 18:13:22 +00:00
Yabin Cui
4a53f6ec43 am b73eb268: am 4ddb6a32: Merge "adb: remove unnecessary dependencies of liblog."
* commit 'b73eb268ffdf61257342bdb256f6dd372666ffaf':
  adb: remove unnecessary dependencies of liblog.
2015-09-09 18:03:27 +00:00
Yabin Cui
824a51eae4 am bd9305ee: am 0df24ea2: Merge "adb: refactor _is_valid_ack_reply_fd"
* commit 'bd9305eeb7152058ba8255f0c2601d512c906f98':
  adb: refactor _is_valid_ack_reply_fd
2015-09-09 18:03:25 +00:00
Yabin Cui
b73eb268ff am 4ddb6a32: Merge "adb: remove unnecessary dependencies of liblog."
* commit '4ddb6a3289d7cc1d1f60e3ae0af231da55f937ac':
  adb: remove unnecessary dependencies of liblog.
2015-09-09 17:57:36 +00:00
Yabin Cui
bd9305eeb7 am 0df24ea2: Merge "adb: refactor _is_valid_ack_reply_fd"
* commit '0df24ea234fcfb9ac57ed94701868426a41d8642':
  adb: refactor _is_valid_ack_reply_fd
2015-09-09 17:57:34 +00:00
Yabin Cui
4ddb6a3289 Merge "adb: remove unnecessary dependencies of liblog." 2015-09-09 17:38:31 +00:00
Yabin Cui
cb992d9a21 adb: remove unnecessary dependencies of liblog.
Change-Id: I1aaa9e6c1b47a70f8daf91745f6aec13c92b789f
2015-09-08 18:27:10 -07:00
David Pursell
b9e2e84e7e adb: create shell protocol class (take 2).
Adds a new class ShellProtocol to help read and write data with
`adb shell`. This will allow splitting streams and sending out-of-band
data such as exit codes.

Nothing uses the new class yet except the unit tests.

This is the second attempt at this CL, the first is at
http://r.android.com/169600. The problems was using sighandler_t
which is not available on mac. sig_t is used instead which is available
due to _GNU_SOURCE being defined in Android.mk, which causes
_BSD_SOURCE -> __USE_BSD -> sig_t to be defined. Nothing else has been
changed from the original CL.

Bug: http://b/23030641
Change-Id: I7bd7f5a82ad811fbca7a3eee1236d2c55ae57c48
2015-09-08 10:04:10 -07:00
Spencer Low
a13df3070f adb: refactor _is_valid_ack_reply_fd
Visual Studio's 'jump to reference' feature couldn't parse
adb_commandline() because I used an #ifdef in the middle of an if
statement, so this refactors the code into a separate helper function. I
just copied the code and inverted the comparisons.

No need for sysdeps since this is pretty minor.

Change-Id: Ifd5c62b0b505080ada6db5cc19739c6f07b94de9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-07 16:20:13 -07:00
David Pursell
beb81f48d8 am 9432e753: am da0b0116: Merge "Revert "adb: create shell protocol class.""
* commit '9432e7538ac5ce57a0701bfe274b3eab8589544e':
  Revert "adb: create shell protocol class."
2015-09-06 02:41:35 +00:00
David Pursell
9432e7538a am da0b0116: Merge "Revert "adb: create shell protocol class.""
* commit 'da0b0116ba676203328906608a78dd240e0fea48':
  Revert "adb: create shell protocol class."
2015-09-06 02:38:35 +00:00
David Pursell
da0b0116ba Merge "Revert "adb: create shell protocol class."" 2015-09-06 02:34:02 +00:00
David Pursell
d9b74192b8 Revert "adb: create shell protocol class."
This CL broke the mac build. I'll revert for now and take a look at how to get it working next week.

This reverts commit 73096f2e1d.

Change-Id: Icb3e015250bcbbc69a45675a1358699ebe01e77b
2015-09-06 01:18:47 +00:00
David Pursell
04aa49346a am 74b6e8ec: am e4c1bb53: Merge "adb: features passes transport features."
* commit '74b6e8ecfdb4e7f46d53f174e8ba21ce74f90482':
  adb: `features` passes transport features.
2015-09-05 00:16:00 +00:00
David Pursell
897baffb75 am 3f742914: am 21541531: Merge changes from topic \'adb_shell_prework\'
* commit '3f742914b1dd66bdf172059fc7c4bf421e3a87a6':
  adb: create shell protocol class.
  adb: refactor subprocess code.
  adb: move shell service to a separate file.
2015-09-05 00:08:33 +00:00
David Pursell
74b6e8ecfd am e4c1bb53: Merge "adb: features passes transport features."
* commit 'e4c1bb53068db184ee4cb19513ffe7764a09722f':
  adb: `features` passes transport features.
2015-09-05 00:07:54 +00:00
David Pursell
e4c1bb5306 Merge "adb: features passes transport features." 2015-09-05 00:01:27 +00:00
David Pursell
3f742914b1 am 21541531: Merge changes from topic \'adb_shell_prework\'
* commit '215415318d8483d648955b72bb3b083e131cb62e':
  adb: create shell protocol class.
  adb: refactor subprocess code.
  adb: move shell service to a separate file.
2015-09-05 00:01:02 +00:00
David Pursell
215415318d Merge changes from topic 'adb_shell_prework'
* changes:
  adb: create shell protocol class.
  adb: refactor subprocess code.
  adb: move shell service to a separate file.
2015-09-04 23:54:19 +00:00
David Pursell
880be434a9 adb: features passes transport features.
`adb features` previously returned a list of host features which was
not terribly useful. This CL changes functionality to return the
transport features instead using the standard targeting args:
  $ adb features  # default target.
  $ adb -e features
  $ adb -s 123456 features

Also adds a "check-feature" service which is currently unused but will
allow the adb client to easily check for a specific feature.

Bug: http://b/23824036
Change-Id: Ibc0c420c75f73d363f3bba7705af616ba2059348
2015-09-04 16:47:21 -07:00
Dan Willemsen
66680c506a Remove HOST_OS==windows check
With the HOST_CROSS_OS build system change, LOCAL_MULTILIB := first now
behaves the same way.

Change-Id: I03294403e5a106a53d4a0d48b176434221284901
2015-09-04 14:05:19 -07:00
David Pursell
73096f2e1d adb: create shell protocol class.
Adds a new class ShellProtocol to help read and write data with
`adb shell`. This will allow splitting streams and sending out-of-band
data such as exit codes.

Nothing uses the new class yet except the unit tests.

Bug: http://b/23030641

Change-Id: Ieb02e127095c6dda25b7cb188a2e599173fd97e6
2015-09-04 11:30:11 -07:00
David Pursell
a932058504 adb: refactor subprocess code.
Refactor shell_service.cpp to remove dependencies on service.cpp and
combine some common logic between PTY and raw subprocesses.

This will make it easier to add additional common code paths for
the upcoming shell protocol.

Change-Id: I497d30dd388de61b6e68d9086dce38f33dd92876
2015-09-04 11:18:51 -07:00
Tom Cherry
c74403b4c9 am b00a8a06: am e8b0fcec: Merge "combine adbd.rc with init.usb.rc"
* commit 'b00a8a066f5b6ae5b8d0c03ee7f680389b38a260':
  combine adbd.rc with init.usb.rc
2015-09-04 18:02:32 +00:00
Tom Cherry
b00a8a066f am e8b0fcec: Merge "combine adbd.rc with init.usb.rc"
* commit 'e8b0fcecf4a17cf37b5fefbcceef0920788f776e':
  combine adbd.rc with init.usb.rc
2015-09-04 17:56:25 +00:00
David Pursell
80f67029e0 adb: move shell service to a separate file.
Upcoming changes to the shell will require significant additions to
the subprocess code, and it will be cleaner if it's in a separate file.

The only functional change here is a new debug tag specifically for
the shell service. Everything else has been copied exactly as-is in
order to make it easier to determine what's changing in upcoming CLs.

Change-Id: I13bd4294059051ee10e0d0c6a06affd8eca62967
2015-09-04 08:52:35 -07:00
Tom Cherry
2270dbbc84 combine adbd.rc with init.usb.rc
init.usb.rc and adbd.rc contain similar contents and belong in the same
file.

This file also belongs on the ramdisk as adbd is on the ramdisk, not the
system partition, therefore resolving to keep init.usb.rc in its current
location and combining the contents of adbd.rc is the best approach

Change-Id: I430f8fea58694679e7b8b7be69ce87daadd616f4
2015-09-03 16:19:04 -07:00
Elliott Hughes
27e427aaa2 am db31ac76: am 478da637: Merge "Improve adb sync_send error reporting."
* commit 'db31ac76baf732244b9492a96db43fd90070411a':
  Improve adb sync_send error reporting.
2015-09-03 21:41:56 +00:00
Elliott Hughes
db31ac76ba am 478da637: Merge "Improve adb sync_send error reporting."
* commit '478da6374b5f4a5742566edfe3057c674a51615e':
  Improve adb sync_send error reporting.
2015-09-03 21:33:59 +00:00
Elliott Hughes
081696d27c Improve adb sync_send error reporting.
Bug: http://b/23786900
Change-Id: I71f10de8d767eaf8bf0f5d9b8c304527e2b953ff
2015-09-03 13:55:55 -07:00
Yabin Cui
9bbc68dd07 am 7d0b4ada: am 6562c151: Merge "adb: clean up debug tracing a little."
* commit '7d0b4ada0bf539a0f48b00e211799400aa733f4d':
  adb: clean up debug tracing a little.
2015-09-03 18:14:05 +00:00
Yabin Cui
7d0b4ada0b am 6562c151: Merge "adb: clean up debug tracing a little."
* commit '6562c1513b2b7bd88da8b1d0c88b89e66b2dcd69':
  adb: clean up debug tracing a little.
2015-09-03 17:38:57 +00:00
Yabin Cui
6562c1513b Merge "adb: clean up debug tracing a little." 2015-09-03 17:32:44 +00:00
Yabin Cui
7a3f8d6691 adb: clean up debug tracing a little.
Always use LOG() for debug tracing.
Remove useless D_lock. I believe it is useless to lock just before and after fprintf.

I verified the log output both on host and on device. The output looks fine to me.

Change-Id: I96ccfe408ff56864361551afe9ad464d197ae104
2015-09-02 20:21:00 -07:00
Dan Willemsen
54afdbaef7 am a4b8f9f1: am bfe32228: Merge "Remove USE_MINGW/CYGWIN; Whitelist windows modules"
* commit 'a4b8f9f1c2d9fb6795c81ae39441e720662602d0':
  Remove USE_MINGW/CYGWIN; Whitelist windows modules
2015-09-03 02:15:32 +00:00
Dan Willemsen
a4b8f9f1c2 am bfe32228: Merge "Remove USE_MINGW/CYGWIN; Whitelist windows modules"
* commit 'bfe322285fdbe86fdc01fdc4c711e22e894bdaee':
  Remove USE_MINGW/CYGWIN; Whitelist windows modules
2015-09-03 00:39:19 +00:00
Dan Willemsen
87a419c8b1 Remove USE_MINGW/CYGWIN; Whitelist windows modules
CYGWIN is not supported, USE_MINGW and HOST_OS==windows are being
replaced with LOCAL_..._windows variables.

Bug: 23566667
Change-Id: I3e4a1e4097dc994cf5abdce6939e83a91758fd75
2015-09-02 17:10:35 -07:00
Elliott Hughes
0b23a08b27 am 1428640f: am 5d804006: Merge "adb/base win32 tests: fix comment and open() flags"
* commit '1428640f5cf69ede7dcafa7ae5ecca5a0a4fff50':
  adb/base win32 tests: fix comment and open() flags
2015-09-01 22:39:00 +00:00
Elliott Hughes
1428640f5c am 5d804006: Merge "adb/base win32 tests: fix comment and open() flags"
* commit '5d8040060515128f2bee9b4759d0618b90c4d70c':
  adb/base win32 tests: fix comment and open() flags
2015-09-01 22:10:57 +00:00
Spencer Low
2fbeb0cc71 adb/base win32 tests: fix comment and open() flags
Match base's use of O_BINARY.

Change-Id: I930b5c8fddde20966580069f2e681b99cb26f1a3
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-01 14:57:58 -07:00
Elliott Hughes
59224c9537 resolved conflicts for merge of 46603db5 to mnc-dr-dev-plus-aosp
Change-Id: I3fb7ff8e9d9313c294620ae0ce63a17766940ec4
2015-09-01 11:25:24 -07:00
Yabin Cui
14bf82e21f am 2ae47a0b: Merge "adb: add unit test for fdevent."
* commit '2ae47a0b54c51d05cfb5bab3e1d7a34d5d15ba1b':
  adb: add unit test for fdevent.
2015-09-01 16:37:39 +00:00
Yabin Cui
7a3dc5eacf am 1e19317e: Merge "adb: improve names for transport threads."
* commit '1e19317e575e1020cc0c241c4591a3f95f6a45c4':
  adb: improve names for transport threads.
2015-09-01 16:37:35 +00:00
Yabin Cui
85c04dfeb6 am 1531cee6: Merge "adb: remove workaround for b/6558362."
* commit '1531cee658ecc46a8eda3c1bc13a09fd4fa73eb9':
  adb: remove workaround for b/6558362.
2015-09-01 16:37:22 +00:00
Elliott Hughes
7dbc0936e8 am b6bfd36c: Merge "Distinguish transport threads."
* commit 'b6bfd36c19626ef1aca3b5d28092721c6b498a34':
  Distinguish transport threads.
2015-09-01 16:36:41 +00:00
Siva Velusamy
1f9d3b07a6 am c9525ec3: Merge "adb: set thread names (linux & mac)"
* commit 'c9525ec366232aa6a0968be1cc8e8abc37df789f':
  adb: set thread names (linux & mac)
2015-09-01 16:36:29 +00:00
Yabin Cui
2ae47a0b54 Merge "adb: add unit test for fdevent." 2015-08-31 22:40:04 +00:00
Yabin Cui
1e19317e57 Merge "adb: improve names for transport threads." 2015-08-31 21:21:21 +00:00
Yabin Cui
d6ab3c2245 adb: improve names for transport threads.
The old names seems confusing. output_thread was reading remote data and writing to
local sockets. input_thread was reading local sockets data and writing to remote.
This change tries to make it clear by renaming output_thread to read_transport thread,
and renaming input_thread to write_transport thread.

Change-Id: I2e7b4cde7a94d436f3745e9e3ab10780e7caa8ac
2015-08-31 13:34:27 -07:00
Yabin Cui
c6424585a2 adb: remove workaround for b/6558362.
I believe the problem has been fixed in https://android-review.googlesource.com/#/c/168412/.
So it's time to remove the workaround.

Bug: 6558362
Change-Id: I399c18eda0693f3c51feac07ff59a0a4b5558128
2015-08-31 12:10:11 -07:00
Elliott Hughes
0c3914a44d Distinguish transport threads.
Use "<-" and "->" to work around Linux's very short thread name limit.

Bug: http://b/23423333
Change-Id: I9f3f096415b47162dacb660cd0a97ac7ff6107e6
2015-08-31 10:46:05 -07:00
Siva Velusamy
49ee7cf9a1 adb: set thread names (linux & mac)
Bug: 23423333
Change-Id: I0069f32ddbae2a10fb130064f721facf45b2cc09
2015-08-31 07:52:52 -07:00
Yabin Cui
bec02fc43d adb: add unit test for fdevent.
Change-Id: Ic26cda5d8e84425bc60ce36bc686bb6917c4ca3c
2015-08-28 21:33:22 -07:00
Elliott Hughes
b77146ce7c am 9f07f879: Merge "fatal and fatal_errno should be noreturn."
* commit '9f07f87908f072d63d8bb9ded91616af8d3edbb4':
  fatal and fatal_errno should be noreturn.
2015-08-29 02:30:50 +00:00
Yabin Cui
432ea8f94e am a3bdc6ab: Merge "adb: clean up transport disconnect operations."
* commit 'a3bdc6aba29950b38a4c8ab785e5828451e97140':
  adb: clean up transport disconnect operations.
2015-08-29 02:30:49 +00:00
Elliott Hughes
9f07f87908 Merge "fatal and fatal_errno should be noreturn." 2015-08-29 02:22:18 +00:00
Yabin Cui
a3bdc6aba2 Merge "adb: clean up transport disconnect operations." 2015-08-29 02:21:46 +00:00
Elliott Hughes
2f3342fa33 fatal and fatal_errno should be noreturn.
Change-Id: I9c5d9cb5ed743d13e65112a111cc9544ec5da339
2015-08-28 19:13:10 -07:00
Yabin Cui
b329824e6c adb: clean up transport disconnect operations.
Move operations from global functions into member functions.
Add unit test.

Change-Id: Id4543d8e78541eb08c8e629f180c605c699737ec
2015-08-28 16:36:00 -07:00
Elliott Hughes
9382e6c071 am f6224587: Merge "Improve adb tracing."
* commit 'f6224587e5fdb8d659172ba5a87a55685a94adf7':
  Improve adb tracing.
2015-08-28 23:09:40 +00:00
Elliott Hughes
f6224587e5 Merge "Improve adb tracing." 2015-08-28 21:56:46 +00:00
Elliott Hughes
bd4b1fa4a9 Improve adb tracing.
The existing format was unreadable; putting the pid and tid first helps
somewhat. Also remove the unused qemu tracing which wasn't called anywhere.

Change-Id: I37ef3c556fe17b237ba1d8ca3216e2155ce5d0de
2015-08-28 14:46:33 -07:00
Yabin Cui
bbe5de2307 am 88a51cd4: Merge "adb: call run_transport_disconnects() only once."
* commit '88a51cd4d8377516f693720f427511cb40e90b75':
  adb: call run_transport_disconnects() only once.
2015-08-28 20:59:30 +00:00
Yabin Cui
88a51cd4d8 Merge "adb: call run_transport_disconnects() only once." 2015-08-28 20:50:07 +00:00
Elliott Hughes
bffa890641 am e73a8a23: Merge "win32: adb start-server shows stdout/stderr output from actual server"
* commit 'e73a8a2388f019b0f7a6e468af27056edbb02521':
  win32: adb start-server shows stdout/stderr output from actual server
2015-08-28 20:23:49 +00:00
Elliott Hughes
e73a8a2388 Merge "win32: adb start-server shows stdout/stderr output from actual server" 2015-08-28 20:13:40 +00:00
Elliott Hughes
4417c38a1e am a54f14eb: Merge "adb unittest: get test_unicode_paths passing on win32"
* commit 'a54f14eb95d73c91aaa2a4387a79d897a4731060':
  adb unittest: get test_unicode_paths passing on win32
2015-08-28 20:07:47 +00:00
Elliott Hughes
a54f14eb95 Merge "adb unittest: get test_unicode_paths passing on win32" 2015-08-28 20:00:53 +00:00
Elliott Hughes
be881b65ca am 1d9253f2: Merge "adb: fix adb install and adb push exit code, error handling, unittest"
* commit '1d9253f255c60069c4187f0c43b2b22015fd5688':
  adb: fix adb install and adb push exit code, error handling, unittest
2015-08-28 19:52:18 +00:00
Elliott Hughes
1d9253f255 Merge "adb: fix adb install and adb push exit code, error handling, unittest" 2015-08-28 19:46:46 +00:00
Yabin Cui
adab77ad50 am 7b6fa7ed: Merge "adb: remove adisconnect in aremotesocket."
* commit '7b6fa7ed304cbd682e4c4cb539f2e4f8047aedc4':
  adb: remove adisconnect in aremotesocket.
2015-08-28 18:57:35 +00:00
Yabin Cui
12d7f0909a adb: call run_transport_disconnects() only once.
Currently run_transport_disconnects() are called twice. One is in
handle_offline(), another is before destroying transport.
The users of disconnect callback are listener, adb_auth_client, and
remote_sockets. All of them need only to be called once. And after
handle_offline, no new listeners, adb_auth_client, or remote_sockets
can be connected to the offlined transport. So I think we can remove
the second call to run_transport_disconnects().

Change-Id: I1ef8b6b7b5ab7ae1bad109be107c85973d65a2e3
2015-08-28 11:39:37 -07:00
Spencer Low
d8cce1817b adb: fix adb install and adb push exit code, error handling, unittest
adb push was not returning a bad exit code when write_data_file() or
write_data_link() failed. I encountered this when running the unittest
on Windows which can get into situations where stat() succeeds, but
open() fails due to pre-existing exclusive file access (which typically
doesn't exist on unix).

The same code is used by adb install, so this also fixes its error
handling.

Fixed some fd leaks and propagation of errors when reading a file.

Fixed a unittest to close temp files before reading them.

Change-Id: Ieba0026fa4c79eb0484676e4f2faaac9603ef584
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-28 11:38:28 -07:00
Spencer Low
de4505f819 adb unittest: get test_unicode_paths passing on win32
The Python 2 subprocess class doesn't use Unicode, so as a work-around
write the command line to a UTF-8 batch file and run that.

I modified the test to use u'blah' without .encode('utf-8') because the
Python docs recommend dealing with string variables like that. When
formatting a string with a unicode parameter, use u'foo' on the constant
string to make it unicode.

I also tested this on Linux and it seems to work fine (I did ls in the
middle of the test to make sure the filenames came out right, etc.).

I had to close the temporary files before adb tries to read/write them
because filesystem semantics are different on Windows (technically I
might be able to modify adb to try to open files with more permissive
share flags, but then I'm not sure if Python uses the right share flags.
Basically, I'd be opening another can of worms.).

Fixed the test to delete a temp file on the device once it is done.

Change-Id: Id0c34e26d7697fbbb47a44ae45298bed5e8c59d6
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-28 01:20:03 -07:00
Yabin Cui
fd28f327ee adb: remove adisconnect in aremotesocket.
The function of remote_socket_disconnect() is to make sure
the local_sockets and remote_sockets are closed when the binded
transport is disconnected. However, as we call close_all_sockets()
in handle_offline(), we don't need remote_socket_disconnect() any more.

Change-Id: I575f632d9f8703149f34e0210eb698a56e2516a9
2015-08-27 19:35:47 -07:00
Yabin Cui
a483eae5b1 am 4f8d5b01: Merge "adb: disconnect: fix write-after-free memory corruption and crash."
* commit '4f8d5b01281e751168718c7b0a74db34352aaf1e':
  adb: disconnect: fix write-after-free memory corruption and crash.
2015-08-27 23:05:43 +00:00
Yabin Cui
f4b9928563 adb: disconnect: fix write-after-free memory corruption and crash.
Transport atransport objects are semi-reference counted: the input and
output threads each hold a reference. The adb disconnect command was
calling transport_unref to release a reference that it never had in the
first place. This meant that the refcount dropped to zero and the object
was deleted before either the input or output thread released its
reference. When that last thread released its reference, it wrote to
freed memory and also sometimes crashed.

This fix is to not release any unheld reference, instead it just kicks
the transport to break remote_read in output_thread. So all transport
close flow goes the following way:
output_thread (exit) -> main thread (offline the transport) ->
input thread (exit) -> main thread (destroy the transport)

Change-Id: Iad1fe718acc8716f3a79c8c22b426a1b2450452c
2015-08-27 14:41:07 -07:00
Yabin Cui
9f91681d50 am f3068123: Merge "adb: fix a fake data race on transport:kick reported by tsan."
* commit 'f3068123039e81cee85ce9103d01b5b2aceb2ba3':
  adb: fix a fake data race on transport:kick reported by tsan.
2015-08-27 18:29:50 +00:00
Yabin Cui
f306812303 Merge "adb: fix a fake data race on transport:kick reported by tsan." 2015-08-27 18:25:02 +00:00
Yabin Cui
860169cbf8 am 804180b2: Merge "adb: fix a data race in local_socket_event_func."
* commit '804180b2ccf2ef4dedad7d136c060ecbdda7aac5':
  adb: fix a data race in local_socket_event_func.
2015-08-27 05:22:52 +00:00
Spencer Low
2122c7a148 win32: adb start-server shows stdout/stderr output from actual server
When launching the adb server (typically from adb start-server),
redirect stdout/stderr to anonymous pipes which are read by threads in
the parent process, to make error diagnosis easier.

If there is an error during adb start-server, the output looks like:

> adb start-server
* daemon not running. starting it now on port 5037 *
error: could not blah                 # from server process
could not read ok from ADB Server     # from launch_server
* failed to start daemon *            # from adb_connect
error: cannot connect to daemon       # from adb_commandline

Fix handle-leaks in launch_server by using new unique_handle class
that is based on std::unique_ptr.

In the server, close stdin and redirect to adb.log *before* sending the
ACK, so that any errors are reported early instead of after the ACK.

Change-Id: I943881210a0ea9458fc36851339f916c3d6a0830
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-26 18:46:09 -07:00
Elliott Hughes
24f165f121 Minimal fix for adb backup.
In master this code has been completely rewritten. This is the minimal fix
against the mnc-sdk-release source.

Bug: http://b/23015233
Bug: https://code.google.com/p/android/issues/detail?id=183490
Change-Id: Iac30993bd2b1b354f8518d8ea2a9ae680ebe4177
2015-08-26 22:30:56 +00:00
Yabin Cui
d8459b3d3c adb: fix a fake data race on transport:kick reported by tsan.
It is reported by tsan as a double checked locking. But I think
it is not a real data race. Because I think the old code is able
to make sure t->kick() is only called once, and the caller of
kick_transport is not relying on the side-effect of calling
t->kick().
But as it is not perf critical, I don't mind breaking the double
checked locking pattern.

Bug: 23385662
Change-Id: Ie3597dd56bb514117c3865d2afcfd7c115731a78
2015-08-26 15:22:56 -07:00
Yabin Cui
804180b2cc Merge "adb: fix a data race in local_socket_event_func." 2015-08-26 22:11:26 +00:00