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
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
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
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
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
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 the shell protocol functionality to the client side and enables it
if the transport supports the feature.
Bug:http://b/23031026
Change-Id: I9abe1c8b1d39f8dd09666321b1c761ad708a8854
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>
`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
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
We can double the speed of "adb sync" (on N9) if we increase SYNC_DATA_MAX
from 64KiB to 256KiB. This change doesn't do that, because I still haven't
managed to plumb through the information about whether we're a new adb/adbd
to file_sync_client.cpp and file_sync_service.cpp. But this is already a big
change with a lot of cleanup, so let's do the cleanup and worry about the
intended change another day...
This change does improve performance somewhat by halving the number of
lstat(2) calls made on the client side, and ensuring that most packets are
sent with a single write. This has the pleasing result of making the null
sync on an AOSP N9 go from just over 300ms to around 100ms, which means it
now seems instantaneous (https://en.wikipedia.org/wiki/Mental_chronometry).
Change-Id: If9f6d4c1f93ec752b95f71211bbbb1c513045166
- handle_host_request
- When the host:kill command comes in, shutdown the socket before
calling exit(). If we don't do this, the client will output error info
even though everything is working ok.
- adb_connect()
- If we can't parse the version string, explain this in error output
and don't goto error which would try to close an fd we already closed.
- If host:kill doesn't work, output error info. Don't try to close
already closed fd.
- adb_main()
- If writing the ACK somehow has an error, output error info (I doubt
this will ever get hit).
- adb_commandline()
- Fix typo about max port number.
- Make 'adb kill-server' and 'adb start-server' output any detailed
error info.
Change-Id: Id1a309cc1bf516f7f49bd332b34d30f148b406da
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
The win32 version of 9f2d1a9cfc. The big
technique is to fit a Win32 HANDLE value in an int because it only uses
32-bits. This allows most of the other adb code to stay the same.
Also, fix a regression in the 'adb server nodaemon' command that was
erroneously returning an error when --reply-fd was not used, which
should not be necessary for this particular command.
Change-Id: I37e9c609014b813af93bf0d6c12f665b59c93c41
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
When "adb start-server" is issued, and a server needs to be launched,
adb client forks itself and the child process runs the server routine.
Once the server initializes its various components, it sends an "OK\n"
back to the client via its stderror (or stdout on Windows).
This sequence breaks down if before sending the "OK\n", the server
happens to log something on its stderr. In order to avoid this, the
client now expects the ack to come on a different fd rather than one
of the standard streams.
Bug: https://code.google.com/p/android/issues/detail?id=182150
Change-Id: I9d58a08068d71eb3b77e8a7377e934631c016466
This removes adb_dirstart and adb_dirstop. It also fixes a couple of memory
leaks by switching to std::string. This also fixes the bug in the previous
change --- mkdirs is given input like "/system/bin/sh" and only expected to
create "/system/bin". In a later change, we should remove mkdirs and only
expose the intended "unlink && mkdirs && create" functionality.
Change-Id: I30289dc1b3dff575cc1b158d993652178f587552
~ Rewrote mkdirs to be in C++ style.
~ Replaced adb_dir{start,stop} with std::string params and (r)find.
+ Added test for mkdirs.
Also make base/test_utils.h public and support temporary directories
as well as files.
Change-Id: I6fcbdc5e0099f3359d3aac6b00c436f250ca1329
This causes build failures in google3 where they use GCC. glibc only
provides const-correct overloads for string functions for GCC >= 4.4,
but clang -- which is what we use -- pretends to be GCC 4.2.
Change-Id: I2a054823ea6201ebcea46d5e77b80a975eefc622