Commit graph

1447 commits

Author SHA1 Message Date
Josh Gao
04c64dba9f Merge "adb: Mask SIGTTIN so that I/O works when backgrounded."
am: 69ccb9532c

* commit '69ccb9532cb822685d27142a5117d881be21ab01':
  adb: Mask SIGTTIN so that I/O works when backgrounded.
2015-10-24 01:43:23 +00:00
Josh Gao
8dcdb57daf adb: Mask SIGTTIN so that I/O works when backgrounded.
SIGTTIN gets sent to the process when we attempt to read from
stdin when we're in the background, which stops the process by
default. Mask the signal so that the read returns -1 with errno
set to EIO, instead.

Change-Id: I4ae626b0670c05a1a05165539b9eed709e83d536
2015-10-23 15:04:33 -07:00
Daniel Cashman
27ff12443d Merge "init/adb: correct static lib dependencies for libselinux"
am: 38aee48fc6

* commit '38aee48fc695c25e15435e4ef235c8bc2e0afde9':
  init/adb: correct static lib dependencies for libselinux
2015-10-22 23:12:22 +00:00
William Roberts
bd2d961cc2 init/adb: correct static lib dependencies for libselinux
Now that libselinux uses libpackagelistparser, in order
for libpackagelistparser to be properly statically linked
liblog must come after libselinux for all the liblog
references to be defined in libpackagelistparser which
is included in libselinux. This patch corrects that order.

Change-Id: I7aee10c9395310919779ed2463aab6b2f8b380cc
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-10-22 15:21:26 -07:00
Elliott Hughes
5d5e8c2f4d Merge "Fix lseek argument order."
am: 56543606b5

* commit '56543606b55e1e1455ef5c0bf9aa9f4febab967f':
  Fix lseek argument order.
2015-10-20 20:37:05 +00:00
Elliott Hughes
56543606b5 Merge "Fix lseek argument order." 2015-10-20 20:28:05 +00:00
Elliott Hughes
c96de0d36e Fix lseek argument order.
Change-Id: I12feed2de8a4e0782f90609254a3e2ec66d7d98e
2015-10-20 13:18:22 -07:00
Sami Tolvanen
17e80ff5fc Merge "adb: use libfec in disable-verity"
am: ed38714426

* commit 'ed38714426b0f6bf67057dd28d6417a13807590c':
  adb: use libfec in disable-verity
2015-10-20 14:41:03 +00:00
Sami Tolvanen
8ad80763e4 adb: use libfec in disable-verity
Use libfec to locate verity metadata and disable verity.

Needs changes from
  I02f83b0d1d4e7ef5cd5d13a37ff0b84f17e23376

Bug: 21893453
Change-Id: Ib43c352400a368664c949c7b8c9961829adf48f4
2015-10-20 13:55:24 +01:00
Elliott Hughes
3f9ad41e0a am c2492937: Merge "adb: win32: Improve Winsock error code mappings and strings"
* commit 'c24929373ec0686e0695320d8f10f3bf4fc4547e':
  adb: win32: Improve Winsock error code mappings and strings
2015-10-19 14:09:12 -07:00
Spencer Low
0a79600e72 adb: win32: Improve Winsock error code mappings and strings
Improved mapping of Winsock error codes to POSIX error codes, especially
WSAECONNABORTED to EPIPE (which WriteFdExactly() looks for) when sending
to a closed socket and WSAECONNRESET to ECONNRESET when the peer resets
the connection.

Use a macro to map strerror() to adb_strerror() which handles these
POSIX error codes that the Windows C Runtime doesn't recognize.

Also:

* Unittest for adb_strerror().

* Don't trace when send() returns WSAEWOULDBLOCK because that is
  expected.

Change-Id: If46aeb7b36de3eebfbbccf5478ff5b1bb087714b
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-10-18 16:45:09 -07:00
David Pursell
2535ea1e18 am ca0d66d5: Merge "adb: non-interactive shell stdin."
* commit 'ca0d66d597dde0a76adc3f5da15aedff4b6cb70b':
  adb: non-interactive shell stdin.
2015-10-15 21:41:47 +00:00
David Pursell
1ed57f0dc3 adb: non-interactive shell stdin.
Non-interactive `adb shell` previously only read from the remote shell,
but we want it to write as well so interactive and non-interactive
shells can both send data. With this CL, we can now do:
  $ echo foo | adb shell cat
  foo

This is primarily usable with newer devices that support the shell_v2
features. Older devices will receive stdin but the shell will still
hang after all input has been sent, requiring user Ctrl+C. This seems
better than closing communication altogether which could potentially
miss an unpredictable amount of return data by closing too early.

Known issue: non-interactive stdin to a PTY shell isn't reliable.
However I don't think this is a common case as ssh doesn't seem to
handle it properly either. Examples:
  * echo 'echo foo' | adb shell
  * echo 'foo' | adb shell -t cat

Bug: http://b/24565284
Change-Id: I5b017fd12d8478765bb6e8400ea76d535c24ce42
2015-10-15 09:44:54 -07:00
Badhri Jagan Sridharan
4b542afe05 am ba000511: Merge "adbd: Add os descriptor support for adb."
* commit 'ba0005118b78dc8ff456492bb1e16947ab26be9e':
  adbd: Add os descriptor support for adb.
2015-10-14 17:32:55 +00:00
Badhri Jagan Sridharan
ba0005118b Merge "adbd: Add os descriptor support for adb." 2015-10-14 17:28:53 +00:00
Elliott Hughes
ebe9ffc48e am 21f99c08: Merge "Use const auto&/auto&& in adb."
* commit '21f99c089e2691f308cb5f24ca3db5eef4aa59ae':
  Use const auto&/auto&& in adb.
2015-10-08 00:04:02 +00:00
Elliott Hughes
65fe2516b4 Use const auto&/auto&& in adb.
Change-Id: I74a7e511302e15e207906f572d181634e0ed5604
2015-10-07 16:11:17 -07:00
Elliott Hughes
28a3e4958e am 1407b286: Merge "Fix adb -d/-e error reporting."
* commit '1407b28628afec6c06eb6cb818f800083df668e1':
  Fix adb -d/-e error reporting.
2015-10-07 22:49:15 +00:00
Elliott Hughes
1407b28628 Merge "Fix adb -d/-e error reporting." 2015-10-07 22:38:50 +00:00
Elliott Hughes
8d28e191c5 Fix adb -d/-e error reporting.
If -d/-e fail, get-serialno and friends will now report an error
and return a failure status code on exit.

Also fix the behavior of -d/-e with $ANDROID_SERIAL --- -d/-e
should override $ANDROID_SERIAL, not the other way round.

I'm deleting my own comment here about always returning "unknown"
for scripts. I can't find any evidence that there are scripts
relying on that, so I think my comment meant "I fear that there
are scripts doing so".

Bug: http://b/24403699
Change-Id: Ie13a751f1137abcfe0cc6c46a0630ba5e02db676
2015-10-07 15:35:18 -07:00
Badhri Jagan Sridharan
ca2a0bdcb5 adbd: Add os descriptor support for adb.
Eventhough windows does not rely on extended os
descriptor for adbd, when android usb device is
configures as a composite device such as mtp+adb,
windows discards the extended os descriptor even
if one of the USB function fails to send
the extended compat descriptor. This results in automatic
install of MTP driverto fail when Android device is in
"File Transfer" mode with adb enabled.

https://msdn.microsoft.com/en-us/library/windows/hardware/gg463179.aspx

BUG=24583401
BUG=chromium:43409

Change-Id: I87341683a9337848cac66daf9055b0d05cedd3d3
2015-10-07 06:04:00 +00:00
Yabin Cui
ff32110e1e am 7f9d4c97: Merge "adb: keep file flags in fdevent_install."
* commit '7f9d4c97c35bbc5357126731bbb9faad1825c090':
  adb: keep file flags in fdevent_install.
2015-10-06 23:42:37 +00:00
Yabin Cui
6dfef255b8 adb: keep file flags in fdevent_install.
Bug: 24615098
Change-Id: Ia791ecbe612f09aca3bbd5787513f121fae54da5
2015-10-06 16:15:30 -07:00
Elliott Hughes
7d46e88936 am 8c47bb52: am 8a69e031: Merge "Speed up adb sync."
* commit '8c47bb52c41f461ee15bf0bc94378f0cc4fcb7d4':
  Speed up adb sync.
2015-10-05 19:53:45 +00:00
Elliott Hughes
8c47bb52c4 am 8a69e031: Merge "Speed up adb sync."
* commit '8a69e0315a3288ca14213602f5bec1173bc3216e':
  Speed up adb sync.
2015-10-05 19:48:00 +00:00
Elliott Hughes
8a69e0315a Merge "Speed up adb sync." 2015-10-05 19:42:03 +00:00
Elliott Hughes
49a59bf317 am 450b592d: am 42b8df38: Merge "adb: win32: specify socket protocol"
* commit '450b592da5e630fad028e3a112651b7071971fd7':
  adb: win32: specify socket protocol
2015-10-03 03:14:55 +00:00
Elliott Hughes
fb068b39e0 am f6d28fca: am e412cc89: Merge "Explain adb client/server version mismatch better."
* commit 'f6d28fcaf048dba2e422824f52ac687b48768c0b':
  Explain adb client/server version mismatch better.
2015-10-03 03:14:53 +00:00
Elliott Hughes
450b592da5 am 42b8df38: Merge "adb: win32: specify socket protocol"
* commit '42b8df38439b390f9c67eee567717f30143cf64f':
  adb: win32: specify socket protocol
2015-10-03 03:09:08 +00:00
Elliott Hughes
f6d28fcaf0 am e412cc89: Merge "Explain adb client/server version mismatch better."
* commit 'e412cc891ebdbcc64137ef3c91950124ff633d6f':
  Explain adb client/server version mismatch better.
2015-10-03 03:09:07 +00:00
Elliott Hughes
42b8df3843 Merge "adb: win32: specify socket protocol" 2015-10-03 03:06:24 +00:00
Elliott Hughes
5b73a10f64 Explain adb client/server version mismatch better.
"Out of date" is only probably true. You might equally well have an older
client talking to a newer server. So tell the truth and include the actual
version numbers.

Change-Id: I821de88f5baf65bf2623363129c60c496b407bff
2015-10-02 19:49:10 -07:00
Elliott Hughes
ae5a6c06cd Speed up adb sync.
Sending the SEND/DATA/DONE packets all in one write makes small file and
symbolic link transfer orders of magnitude faster. Transferring all the
symbolic links in /system/bin or all the cacerts in /system/etc goes down
from about 6s in each case to less than 0.5s.

Change-Id: Ia1706cef25535d0b685d3744241a0557a52b22ff
2015-10-02 14:48:58 -07:00
Yabin Cui
40bc602445 am fb070f3c: am 7377398b: Merge "adb: fdevent fixes"
* commit 'fb070f3c2b1b2e5398a4cb0e67801192a5d90a94':
  adb: fdevent fixes
2015-10-01 19:04:23 +00:00
Yabin Cui
fb070f3c2b am 7377398b: Merge "adb: fdevent fixes"
* commit '7377398be81a9a8a4256b4c11e7ed25b059c32bb':
  adb: fdevent fixes
2015-10-01 18:57:59 +00:00
Spencer Low
888a748bf2 adb: fdevent fixes
* fdevent_{set,add,del}()

  * CHECK() that the fdevent is FDE_ACTIVE, otherwise the caller would
    be waiting for events that will never arrive.

  * Remove ~ from "fde->events &= ~events" to keep desired bits instead
    of turning off desired bits.

* fdevent_call_fdfunc()

  * CHECK(FDE_PENDING) since it should always be true if the fdevent was
    on the pending list, or if fdevent_subproc_event_func() is faking
    things. The goal is to try to avoid losing events.

Change-Id: I979c2fffa0b3d6b635488cde11dc544691193018
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-30 23:29:25 -07:00
Yabin Cui
5027ffd873 am 4b3ee266: am ffa866f5: Merge "adb: detect sockets in CLOSE_WAIT state to prevent socket leak on linux."
* commit '4b3ee2666cdddbace5b7115853780e1d969c2776':
  adb: detect sockets in CLOSE_WAIT state to prevent socket leak on linux.
2015-10-01 00:14:43 +00:00
Yabin Cui
4b3ee2666c am ffa866f5: Merge "adb: detect sockets in CLOSE_WAIT state to prevent socket leak on linux."
* commit 'ffa866f5caefb13412f1814d0de06cda385feaa4':
  adb: detect sockets in CLOSE_WAIT state to prevent socket leak on linux.
2015-10-01 00:10:00 +00:00
Yabin Cui
ffa866f5ca Merge "adb: detect sockets in CLOSE_WAIT state to prevent socket leak on linux." 2015-10-01 00:03:50 +00:00
David Pursell
428f3434ae am de3faec6: am fd18d9e2: Merge "adb: put legacy shell: service back in."
* commit 'de3faec64d407e76013913cb39cf569f692e8f8f':
  adb: put legacy shell: service back in.
2015-09-30 23:59:55 +00:00
David Pursell
de3faec64d am fd18d9e2: Merge "adb: put legacy shell: service back in."
* commit 'fd18d9e254874557aa44d42bd6d6bdf4352b0e36':
  adb: put legacy shell: service back in.
2015-09-30 23:44:31 +00:00
David Pursell
70ef7b40f9 adb: put legacy shell: service back in.
ddmlib does not use the ADB client, but instead connects directly to
the adb server. This breaks some of the assumptions I previously made
when enabling the shell protocol.

To fix this, the adb server now defaults to no protocol for the
standalone command, and the shell protocol must be explicitly requested
by the client. For example:
  shell:echo foo     -- no shell protocol
  shell,v2:echo foo  -- shell protocol

As long as I was touching the shell service arguments I also changed
them to no longer duplicate the command-line arguments. This allows
more flexibility to change the adb client CLI if necessary and makes
the code more readable.

Bug: http://b/24148636
Change-Id: I28d5ae578cf18cbe79347dc89cea1750ff4571a8
2015-09-30 15:40:09 -07:00
Yabin Cui
aa77e22d73 adb: detect sockets in CLOSE_WAIT state to prevent socket leak on linux.
It is possible that the adb server on host has many sockets in
CLOSE_WAIT state. To prevent socket leak, always enable POLLRDHUP
in fdevent.cpp to detect sockets in CLOSE_WAIT state.

Update LocalSocketTest unit tests:
Change half_close_with_packet to read_from_closing_socket, as reading
from a SHUT_WR socket is not needed in adb.
Change close_with_no_events_installed to close_socket_in_CLOSE_WAIT_state,
as the latter is more close to the real situation in use.

Bug: 23314034

Change-Id: Ice4f4036624e5584eab6ba5848e7f169c92f037f
2015-09-30 15:03:26 -07:00
Spencer Low
677fb43b0f adb: win32: specify socket protocol
Instead of using socket(..., 0), pass IPPROTO_TCP or IPPROTO_UDP. Using
zero wasn't buying us anything and was different than popular apps like
Chrome. We should stick to what everyone else does so that we don't go
down different code-paths and potentially hit Winsock service provider
issues that everyone else is (accidentally) avoiding.

Also CHECK() if send() returns an erroneous value as described in the
Chromium source.

Also add comment about socket buffer sizing and Windows Vista.

Change-Id: I63db8f6de352fe1e9525cbc9cfc040eb02a4b9cd
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-29 15:05:29 -07:00
David Pursell
88b71d41af am edf0728e: am a36f4d68: Merge "adb: bump server version to prevent feature mismatch."
* commit 'edf0728e2de358bc1a0eb73626c2c7788a3cc808':
  adb: bump server version to prevent feature mismatch.
2015-09-28 16:14:32 +00:00
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