Instead of using the pm command, 'adb install' and 'adb uninstall' will now
use the cmd command. Additionally, the APK will be streamed directly to
package installer instead of creating a temporary file.
(cherry-pick of d039800a4e008b52c532f901e3bb34b40877cf30.)
Change-Id: Ie7529afa5b039d29cc8183f36085ff4e66b3457a
Pushing empty directories is more troublesome, and probably either
requires changes to the server, or hacky `adb shell mkdir` stuff.
Bug: http://b/25395071
Change-Id: I4db6a993429a56e5c5ca994752418503b6f5d7c4
local_build_list previously was returning an int, 0 on success and -1 on
failure, while remote_build_list was returning a bool, true on success
and false on failure.
Change-Id: Iced6c4142e2f843048d81c4e133d6b6dc75a35dd
Previously, mkdirs/secure_mkdirs wouldn't create a directory at the
specified path, only the ones above it.
Bug: http://b/25459942
Change-Id: I70c94c4b44d90723cb4a063657fc40e5bcb3b10e
Previously, adb_basename was behaving according to the GNU, POSIX-incompatible
basename, despite POSIX adb_dirname existing alongside it. This patch changes
adb_basename to pass through to the POSIX basename.
Bug: http://b/25456821
Change-Id: I62a4865cccf3b9cdbc112e3e53ff475aa4a23bd9
The Mac doesn't have <termio.h>, and it looks like the canonical place for
struct winsize is <sys/ioctl.h> anyway.
system/core/adb/commandline.cpp:44:10: fatal error: 'termio.h' file not found
#include <termio.h>
Bug: http://b/19734542
Change-Id: I3bfbf58cdb9b582f3b7e2c9ef0977613001cd3ac
Allow adb to build using gcc by explicitly using global scope for the
type for pollfd. An alternative would be to rename the pollfd field to
different, but I did not have a better name in mind.
Change-Id: I7925df1dca7e1acc5a289256f228e5fc3755e86e
Our Windows code has several different ways it checks whether an FD is
a console or not, some of which aren't exactly correct as they may
treat character devices (e.g. NUL) as consoles.
This CL disallows using the builtin isatty() function and provides
unix_isatty() instead which correctly checks these corner cases.
Change-Id: I6d551c745dae691c7eb3446b585265d62c1e62fa
Previously we've set these from /system/etc/mkshrc, which caused a behavioral
difference between interactive and non-interactive shells.
Bug: http://b/19635681
Change-Id: I4608c42dd3de821046220fdb1770ab3216b5d5eb
reverse_service() calls handle_forward_request(), which calls
functions in fdevent.cpp. fdevent functions is only supposed
to be called in the main thread.
Add check in fdevent.cpp to make sure all operations come from
main thread.
Bug: 25355808
Change-Id: Iceb9273f3056acc0713eaafe086ac950ca80ff4f
Background
==========
On Windows, if you run "adb shell exit" in a loop in two windows,
eventually the adb client will be unable to connect to the adb server. I
think connect() is returning WSAEADDRINUSE: "Only one usage of each
socket address (protocol/network address/port) is normally permitted.
(10048)". The Windows System Event Log may also show Event 4227, Tcpip.
Netstat output is filled with:
# for the adb server
TCP 127.0.0.1:5037 127.0.0.1:65523 TIME_WAIT
# for the adb client
TCP 127.0.0.1:65523 127.0.0.1:5037 TIME_WAIT
The error probably means that the client is running out of free
address:port pairs.
The first netstat line is unavoidable, but the second line exists
because the adb client is not waiting for orderly/graceful shutdown of
the socket, and that is apparently required on Windows to get rid of the
second line. For more info, see
https://github.com/CompareAndSwap/SocketCloseTest .
This is exacerbated by the fact that "adb shell exit" makes 4 socket
connections to the adb server: 1) host:version, 2) host:features, 3)
host:version (again), 4) shell:exit. Also exacerbating is the fact that
the adb protocol is length-prefixed so the client typically does not
have to 'read() until zero' which effectively waits for orderly/graceful
shutdown.
The Fix
=======
Introduce a function, ReadOrderlyShutdown(), that should be called in
the adb client to wait for the server to close its socket, before
closing the client socket.
I reviewed all code where the adb client makes a connection to the adb
server and added ReadOrderlyShutdown() when it made sense. I wasn't able
to add it to the following:
* interactive_shell: this doesn't matter because this is interactive and
thus can't be run fast enough to use up ports.
* adb sideload: I couldn't get enough test coverage and I don't think
this is being called frequently enough to be a problem.
* send_shell_command, backup, adb_connect_command, adb shell, adb
exec-out, install_multiple_app, adb_send_emulator_command: These
already wait for server socket shutdown since they already call
recv() until zero.
* restore, adb exec-in: protocol design can't have the server close
first.
* adb start-server: no fd is actually returned
* create_local_service_socket, local_connect_arbitrary_ports,
connect_device: probably called rarely enough not to be a problem.
Also in this change
===================
* Clarify comments in when adb_shutdown() is called before exit().
* add some missing adb_close() in adb sideload.
* Fixup error handling and comments in adb_send_emulator_command().
* Make SyncConnection::SendQuit return a success boolean.
* Add unittest for adb emu kill command. This gets code coverage over
this very careful piece of code.
Change-Id: Iad0b1336f5b74186af2cd35f7ea827d0fa77a17c
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
This makes no measurable difference to the sync time; "adb sync" of
everything on /system for a Nexus 9 still takes 20s.
Change-Id: Ifa2626f7453937e43856b9c4ee06e1f5db0aa273
ssh has slightly more sophisticated -Tt options that we want to match.
This CL changes -Tt behavior to match ssh so that we allocate a remote
PTY in these cases:
-T: never.
: if stdin is a terminal and user wants an interactive shell.
-t: if stdin is a terminal (otherwise print a warning message).
-t -t: always.
Now this will work as expected:
$ adb shell < my_script.sh
Also corrects a small unrelated bug with escape sequences so that only
a single tilde is accepted for the disconnect sequence.
Bug: http://b/24565284
Change-Id: Idab57ac98d81233b45c2613fe64ceb4398add961
I fixed the server side to send detailed error reports, but the client-side
code for pull was broken because it had already read the "FAIL" header before
calling the general error reporting code that expects to be able to read
the header. This meant we'd always report that we failed to read the failure
message.
Also add a couple of missing "\n"s, make sure every error message is prefixed
by "adb: ", and remove a useless path length check that would silently ignore
over-long paths rather than relying on SendRequest to detect and report the
problem.
Bug: http://b/6205106
Change-Id: I23862ececf03b761115ffa3f7725b7e1cecb48c7