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
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>
Use libfec to locate verity metadata and disable verity.
Needs changes from
I02f83b0d1d4e7ef5cd5d13a37ff0b84f17e23376
Bug: 21893453
Change-Id: Ib43c352400a368664c949c7b8c9961829adf48f4
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>
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
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
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
"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
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
* 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>
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
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
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>
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
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
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
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>
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
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>
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>
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
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
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
It wasn't deleting the tempfile.mkdtemp() dir that it made.
Change-Id: I59c5f98aa8297c7b28d38799dd21ffe9566f2145
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
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
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