History log of /system/core/adb/commandline.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d1dd125bc2438baf596ddbead5708af57c620465 07-Jun-2016 Felipe Leme <felipeal@google.com> Redirect bugreport stderr to host's stderr.

Change-Id: I46f474f0b0d5cacdc4b129eab1bb0a7f52ccece0
Fixes: 29161586
/system/core/adb/commandline.cpp
42e45c70689f5d601357fe9f768ec1de4b14b274 05-May-2016 Felipe Leme <felipeal@google.com> Display warning about bugreport delay.

BUG: 28569299
Change-Id: Ide6109fd24737cbaf6296ef7326127e85d6420cb
/system/core/adb/commandline.cpp
644a36c20942029ece43ea9fbeb6163d4b706c56 29-Apr-2016 Felipe Leme <felipeal@google.com> Automatically add a .zip to adb bugreport file when missing.

BUG: 27653204
Change-Id: Ib322f1f9eeedd8e78c9a51a845a20c462442a0fe
/system/core/adb/commandline.cpp
a9e818f4632eca67a5ffd1fb680d15550591ecd9 19-Apr-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes Ia4a2ff77,I970806e3,I47daa338 into nyc-dev

* changes:
adb: increase the FD table size on Win32.
adb: bump the server version to 36.
adb: add reconnect command.
03468c8c509975f2f410b402b2bc211b42aa0ed9 05-Apr-2016 Yabin Cui <yabinc@google.com> adb: add reconnect command.

Add reconnect command for debugging. `reconnect` kicks a transport
from the host side, `reconnect device` kicks a transport from
the device side. They can be used to produce transport errors.

Bug: 25935458

Change-Id: I47daa338796b561941e7aba44a51a6dd117d1e98
(cherry picked from commit 1f4ec19e499ba981e4117f647d191603c2713e79)
/system/core/adb/commandline.cpp
9ea7795d38e92d8d01135fdfe7e9a0b74a65e5c8 13-Apr-2016 Josh Gao <jmgao@google.com> adb: after `adb root`, wait for the device in any state.

Otherwise, `adb root` while the device is in recovery will hang.

Bug: http://b/28168212
Change-Id: Ibc8038b1745139fb505e466c74c605b9df474c8c
(cherry picked from commit 48a348183f5f4478ca5b0ca2059fa829648fc090)
/system/core/adb/commandline.cpp
5863fb61e142ec8494443ba341e240f9fe86934b 13-Apr-2016 Josh Gao <jmgao@google.com> adb: add support for 'wait-for-any'.

Allow waiting for a device in any state.

Bug: http://b/28168212
Change-Id: I1876ecd70089ca88f2da5de4182e13724ec50501
(cherry picked from commit 86441c31fe256f37625743e2818377ce5e3dec05)
/system/core/adb/commandline.cpp
3d8df3cb2a80676b35a0641c03e1164eb876883f 13-Apr-2016 Josh Gao <jmgao@google.com> adb: make 'wait-for-{recovery,sideload,bootloader} work.

The help for wait-for-* documents this as working, but we only had a
special case for 'wait-for-device'. Make the others work as well.

Bug: http://b/28170823
Change-Id: I57d70f8b9a383947c4f761919bfbd8515a013520
(cherry picked from commit 08881e72f4b01302742e027225145b061202c528)
/system/core/adb/commandline.cpp
44a42677cfde5f1ae6d0be67dcd07659d9c0f265 02-Apr-2016 Felipe Leme <felipeal@google.com> Implements 'adb bugreport <ZIP_FILE>'.

Dumpstate now supports zipped bugreport, whose output is more complete
than the flat-file bugreports provided prior to N. As such, adb now has
a 'adb bugreport <ZIP_FILE>' name whose implementation:

- Calls the new bugreportz binary.
- Parses its output, which in case of success is the path of the .zip
file.
- Pulls the device file and renames it according to the command-line
argument.

BUG: 27653204

Change-Id: I7169fe157c77bbef1684d0cb4e43095d95ddf2b8
/system/core/adb/commandline.cpp
1ef5bf839e5b467e8014c751390045cd02b4128f 10-Mar-2016 Elliott Hughes <enh@google.com> Fix buffer overrun in adb wait-for-device.

Bug: http://b/27444063

(cherry picked from commit 34e560b9a1e44dcfa0c220c9499bbb833a95a2b4)

Change-Id: Ic71cb2070f509d76fb4208dbab6711c5dd5e1f62
/system/core/adb/commandline.cpp
5767d0dd5ae44978b7a80ba08de32fe51822cbb4 05-Mar-2016 Josh Gao <jmgao@google.com> adb: wait for restore to complete before returning.

If we return before waiting for the other side to finish, it'll get sent
SIGHUP.

Bug: http://b/27414382
Change-Id: I93514d2242ed0d7aa93a6ec6836270dc0783506d
(cherry picked from commit d26abed750640b4225a11763510f61ade3dd225c)
/system/core/adb/commandline.cpp
06c73ae94214cc72b82d4c686bd490c21f61257a 05-Mar-2016 Josh Gao <jmgao@google.com> adb: wait for adbd to die and respawn in root/unroot.

Bug: http://b/19749057
Change-Id: I57dbc113803b6fd3016c1801410be0f4023245d9
(cherry picked from commit d26212207d9bc9412dbc528307185694f8e6d082)
/system/core/adb/commandline.cpp
8a67c09e7d630ccecf8eb17463511dde2f16b548 25-Feb-2016 Alex Klyubin <klyubin@google.com> Merge "Only debuggable packages can be downgraded." into nyc-dev
b6117c4397a711d0e70cade978de97faffb6d4b7 25-Feb-2016 Josh Gao <jmgao@google.com> adb: bail out if wait_for_device fails in send_shell_command.

Bug: http://b/27166186
Change-Id: Ib7e9d7e6b909d67a3af94c3517a6a0b54cf17db7
(cherry picked from commit f56c39194f1c2a4f0ea5d2ac20aebf80de4b0ae7)
/system/core/adb/commandline.cpp
85ed97518c0c1ea312bb3b4941cd03de90f873fa 25-Feb-2016 Alex Klyubin <klyubin@google.com> Only debuggable packages can be downgraded.

This reflects the change in PackageManager service:
frameworks/base commit 921dd754ab49df0cd580ff96503f7616c4c85f4a.

Bug: 27327503
Change-Id: Ifcc7268cd271640417b8cfc9db81ea954b491cb1
/system/core/adb/commandline.cpp
d9db09c3158d3da6aad34fbb926888ceafab3a55 12-Feb-2016 Josh Gao <jmgao@google.com> adb: make adb_thread_func_t return void, add adb_thread_exit.

Windows restricts the return value of threads to 32-bits, even on 64-bit
platforms. Since we don't actually return meaningful values from thread,
resolve this inconsistency with POSIX by making adb's thread abstraction
only take void functions.

Change-Id: I5c23b4432314f13bf16d606fd5e6b6b7b6ef98b5
(cherry picked from commit b5fea14e13bb6e41b36f374c954dc55faeef4627)
/system/core/adb/commandline.cpp
d18aea99746d9befed6d596521ea3aa10e07d23f 01-Feb-2016 Josh Gao <jmgao@google.com> Merge changes I93287b87,I30a3eb0b

* changes:
adb: add nullability specifiers to adb_client.h.
adb: add adb_get_feature_set.
f3f6a1d0d4279930be1434fa66cc0b3fbbb850f0 01-Feb-2016 Josh Gao <jmgao@google.com> adb: add adb_get_feature_set.

Extract a feature set getter function from commandline.cpp.

Change-Id: I30a3eb0b060a88379e29be16264637816e378978
/system/core/adb/commandline.cpp
a9352202dd52a404199fbdca160d9d2d0992cf63 29-Jan-2016 David Pursell <dpursell@google.com> Merge "adb: fix subprocess termination for legacy shell."
2e02dc630f6449f2a79d9130a6346de7761e2be2 08-Nov-2015 Spencer Low <CompareAndSwap@gmail.com> adb: SIGWINCH support for Windows

- Introduces unix_read_interruptible() which is like unix_read() except
that it can return EINTR.

- The big idea is that the Windows ReadConsoleInput() API will return an
event on window resize and then we return EINTR from
unix_read_interruptible() just like Unix.

- Only handles horizontal resize since Windows doesn't seem to give an
event for vertical resize when no special screen buffer is used. This
should be sufficient for the primary use case of adb on Windows
(people are not running vi in the first place).

Change-Id: Id8d1710b559834c8098f2d7fbecedf2d0ade4b88
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/commandline.cpp
57dd5ae1e3004daec664263e24dc4dcf4475bb02 28-Jan-2016 David Pursell <dpursell@google.com> adb: fix subprocess termination for legacy shell.

http://r.android.com/166419 changed `adb shell` behavior to not
allocate a remote PTY for non-interactive commands, but adbd relied on
having a PTY to properly terminate the subprocess.

One impact of this is that when using older versions of adb or passing
the -x flag, `adb screenrecord` wasn't properly terminating and closing
out the video file.

This CL restores the old behavior for legacy shell connections: always
use a PTY, but put it in raw mode if the client is doing local PTY
input/output processing itself.

Bug: http://b/26742824
Change-Id: I9ee630c0ff0d2d6a0db367387af7123deea79676
/system/core/adb/commandline.cpp
0aacbbe9f3039df0413363e808ac0592add11a9d 22-Jan-2016 David Pursell <dpursell@google.com> adb: fix GetFeatureSet() to indicate failure.

Previously GetFeatureSet() on an invalid target would just return an
empty feature set, leading to some invalid assumptions, e.g. if there
isn't exactly one device connected this happens:

$ adb shell -t
error: target doesn't support PTY args -Tt

This CL adds a success/failure return value to GetFeatureSet(), and
also adds an option to print errors to stderr since that's the most
common behavior.

This will cause a slight difference in behavior for install/uninstall.
Previously they would block until the device was available, now they
print an error and quit immediately, which seems to be the more common
behavior for adb functions.

Bug: http://b/26387641
Change-Id: I0ea6ffaec922e04b9946e84f05c3870e5b549fde
/system/core/adb/commandline.cpp
82509e79253309af7d78ebc833ca922b7f7b3c48 17-Dec-2015 Elliott Hughes <enh@google.com> Merge "adb host: add device state in "adb wait-for-*""
fe01885c9ba3cf2781411f1d6a7e4bffd9d164a4 17-Dec-2015 Elliott Hughes <enh@google.com> Improve "adb install"'s error message slightly.

We still don't really have a clue what went wrong, but "Failed to write"
made it sound like we did.

Change-Id: Ic58b13202e2d8ea6b095f7046db9d0771d77ce65
/system/core/adb/commandline.cpp
1fbc9dbd0f78d755e42a7100a8a24d2ff31c7f6a 27-Nov-2015 Leo Sartre <leox.sartre@intel.com> adb host: add device state in "adb wait-for-*"

The current implementation of the host commands "adb wait-for-*" allows
to specify only the transport layer (local, usb or any).
This patch allows the specification of the expected device state
(bootloader, recovery, device or sideload), this is usefull for
scripting purposes.

Use case:
$ adb reboot sideload-auto-reboot
$ adb wait-for-usb-sideload && adb sideload package.zip

Change-Id: I276a6be4d82f8b7901f74e1e5395b86d16548e8f
Signed-off-by: Leo Sartre <leox.sartre@intel.com>
/system/core/adb/commandline.cpp
aae38d9704a6c5a2a7dfd9b628bd89822f1cbb60 10-Dec-2015 Josh Gao <jmgao@google.com> Merge "adb: shell: add -n flag to not read from stdin."
7d586073609723cb2f6ed37de0ad1a7996e621ae 21-Nov-2015 Josh Gao <jmgao@google.com> adb: shell: add -n flag to not read from stdin.

Shell scripts of the following form do not work properly with adb:
echo "foo\nbar\nbaz" | {
read FOO
while [ "$FOO" != "" ]; do
adb shell echo $FOO
read FOO
done
}
The first run of adb shell will consume all of the contents of stdin,
causing the loop to immediately end. ssh solves this by providing a -n
flag that causes it to not read from stdin. This commit adds the same.

Bug: http://b/25817224
Change-Id: Id74ca62ef520bcf03678b50f4bf203916fd81038
/system/core/adb/commandline.cpp
4f71319df011d796a60a43fc1bc68e16fbf7d321 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename of base/ to android-base/.

Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
/system/core/adb/commandline.cpp
65433da1cbd8d2869a60ce3bf18b6b440461741d 19-Nov-2015 Elliott Hughes <enh@google.com> Avoid SIGPIPE in adb.

We're now able to send packets faster than the device can handle them,
meaning that sometimes we're several packets through before the device
says "hey, wait, I can't write" and closes the connection. At best this
led to us reporting that we couldn't sync because "Connection reset";
at worst we'd get SIGPIPE because we were still streaming to a connection
that had already been closed.

This change renames adb_main adb_server_main, and moves the ignoring of
SIGPIPE into adb_commandline so it applies to both client and server (but
not adbd).

This change doesn't address the "wrong error message" part of the problem,
but at least it means you'll get *an* error message.

Bug: http://b/25230872
Change-Id: Ic60e4d13ed03fdcdf0d5cbc97201ebd1097c16ed
/system/core/adb/commandline.cpp
c2252df25a9821b95e93b8842042a282574e7c5e 18-Nov-2015 Elliott Hughes <enh@google.com> Don't send $TERM unless we're talking to a new adbd.

I put the conditional in the wrong place, not realizing that even the
old shell system allowed one 'argument'.

Bug: http://b/25765657
Change-Id: I2752fb838d6377bf24e5b4cf959462557a196c87
/system/core/adb/commandline.cpp
18ddf5c6a233bd56d20548fd834c0ecbf8216410 16-Nov-2015 Elliott Hughes <enh@google.com> Pass $TERM to the device.

Unfortunately, this isn't backwards-compatible with the current shell
protocol because we made unknown shell: arguments errors. We could try
to commit the change to make them just warnings first, but how would
we know when everyone was running adbd with that change? Bumping the
protocol version doesn't help because that only affects the code running
on the host. And although we could add another feature to the reported
features, since shell_v2 is still in development, that doesn't seem
worthwhile.

Bug: http://b/25601436
Change-Id: I12b81aa656cd25b91d14ef691dcbd2b7dab49535
/system/core/adb/commandline.cpp
56e6813e2701ee4a775e5e098801cbf16dc9a3d1 13-Nov-2015 Elliott Hughes <enh@google.com> Improve adb help text and adb backup error reporting.

Bug: https://code.google.com/p/android/issues/detail?id=188220
Bug: http://b/25677893
Change-Id: If174049e86d65d95db93a6e071c089dcd1d7cd4f
/system/core/adb/commandline.cpp
b7b1edf974a93cc4bb9a2de7a5e9c9bce9ad178b 12-Nov-2015 Josh Gao <jmgao@google.com> adb: remove exit-time destructors.

On exit, these destructors get invoked while other threads might
still be using them, potentially causing a crash, and definitely
causing tsan to report a race condition.

Bug: http://b/23384853
Change-Id: I94de55d22f97f4edd1d7cc1f34e8c1f8dfd56a5a
/system/core/adb/commandline.cpp
3c540aec245f6c010ef2d5e82a22b871335dd1c6 10-Nov-2015 Elliott Hughes <enh@google.com> Merge "Add -e to the adb shell documentation."
0e42c2a4ad06be7601377da0b3abc2cc2ad86cbf 10-Nov-2015 Elliott Hughes <enh@google.com> Add -e to the adb shell documentation.

Change-Id: I7be5d198ef174e969bbb670e629369894c7b0994
/system/core/adb/commandline.cpp
28416d6d33267f92768116e269966d61eac01db9 04-Nov-2015 Elliott Hughes <enh@google.com> Fix adb shell escape handling.

Start of input is, by definition, the start of a line. Give the states
names to make the error clearer. We should also swallow the escape
character until/unless it's proven not to have been part of an escape
sequence. Finally, implement an ssh(1)-like -e option so the user can
choose -- or, more importantly, disable -- escape character handling.

Change-Id: I28a91db47e15f3e7de96303c0b9a98d302b9c92e
/system/core/adb/commandline.cpp
6fa848adbab275c76d590a133290a59a6ef9a4d5 04-Nov-2015 Todd Kennedy <toddke@google.com> use new cmd command

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
/system/core/adb/commandline.cpp
11d18f1491430902939e8d3be4d895e6e950f00c 05-Nov-2015 Josh Gao <jmgao@google.com> Merge changes I70c94c4b,Ifd8769ed

* changes:
adb: make mkdirs/secure_mkdirs do what they say.
adb: remove use of mkdirs from `adb backup`.
09c5bbf0fb22eb4734bdb05365bba8a12a870939 04-Nov-2015 Josh Gao <jmgao@google.com> adb: remove use of mkdirs from `adb backup`.

`adb backup -f nonexistent/directories/foo <pkg>` shouldn't create the
directory structure if they don't already exist.

Change-Id: Ifd8769ed7ee5e733a6635751ad09b714ab58ea4b
/system/core/adb/commandline.cpp
0fbf9618bb595a93a83d034f04bb63e7881d8bf3 04-Nov-2015 Elliott Hughes <enh@google.com> Fix Mac adb build.

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
/system/core/adb/commandline.cpp
c15b17f1acfcdbda8602ab135371f7b7238b4b39 03-Nov-2015 Elliott Hughes <enh@google.com> adb shell SIGWINCH support.

Bug: http://b/19734542
Change-Id: Ic9404a132cb9c42cb6a378bcd4b3dea9188d0a44
/system/core/adb/commandline.cpp
aff48cbb3fce8c1529181166f21e8b9952b47f2d 03-Nov-2015 Elliott Hughes <enh@google.com> Merge "adb: fix adb reverse --no-rebind help text"
am: 4f23917299

* commit '4f2391729951ead5f0d15862bd19213962438776':
adb: fix adb reverse --no-rebind help text
4f2391729951ead5f0d15862bd19213962438776 03-Nov-2015 Elliott Hughes <enh@google.com> Merge "adb: fix adb reverse --no-rebind help text"
58ee99e4545c96938faa2cb14839089b2df2606c 03-Nov-2015 Josh Gao <jmgao@google.com> Merge "adb: allow multiple args to push/pull."
am: fe54c96ab2

* commit 'fe54c96ab28a59a87c0c26ac4e6664826b4644ea':
adb: allow multiple args to push/pull.
fe54c96ab28a59a87c0c26ac4e6664826b4644ea 03-Nov-2015 Josh Gao <jmgao@google.com> Merge "adb: allow multiple args to push/pull."
587ea20f83bd0d7b4077b5700ab3dd8c257cc344 03-Nov-2015 Spencer Low <CompareAndSwap@gmail.com> adb: fix adb reverse --no-rebind help text

There was a typo in the option.

Change-Id: I5c074a883a7b384663ed65cd8de0d891dc2b6606
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/commandline.cpp
34e0d64719ad43b9a85b36e05115e1dae1d5983f 03-Nov-2015 David Pursell <dpursell@google.com> Merge "adb: create unix_isatty() function."
am: d9ff9873df

* commit 'd9ff9873df4ef68c105bc84d8dbe098feaaa6c50':
adb: create unix_isatty() function.
c5b8ad88ce6e74216198f14c6e33d55cb1681370 28-Oct-2015 David Pursell <dpursell@google.com> adb: create unix_isatty() function.

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
/system/core/adb/commandline.cpp
05786779f390b23cc8611b101458cd174cf4e938 31-Oct-2015 Josh Gao <jmgao@google.com> adb: allow multiple args to push/pull.

Bug: http://b/25324823
Change-Id: I369dd97adbe1d08e18e84af776ce8b1d61251835
/system/core/adb/commandline.cpp
dcaf6932fde9df11f415f683589f962858084cb1 02-Nov-2015 Josh Gao <jmgao@google.com> Merge "adb: use correct _WIN32 macro."
am: 5c75b529f6

* commit '5c75b529f684b388c91c7e7d0b2c7fece376ac1d':
adb: use correct _WIN32 macro.
4a1397264b998442aacf0e7e79bdd65ba72867dd 31-Oct-2015 Josh Gao <jmgao@google.com> adb: use correct _WIN32 macro.

Change-Id: I5af7957162ae7f8472a5a262434eaba84e64325a
/system/core/adb/commandline.cpp
edb78620fbef1fa592407a5c6917b92c43a3ce7d 31-Oct-2015 Elliott Hughes <enh@google.com> Merge "adb: fix adb client running out of sockets on Windows"
am: 1e2382a027

* commit '1e2382a0277eb36fb57a3a54202945556dfd234b':
adb: fix adb client running out of sockets on Windows
351ecd15b29f0ce528ffac119640b9c01874562b 15-Oct-2015 Spencer Low <CompareAndSwap@gmail.com> adb: fix adb client running out of sockets on Windows

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>
/system/core/adb/commandline.cpp
39f7a1f0260166c107b794f0b194941b7413f216 30-Oct-2015 Elliott Hughes <enh@google.com> Merge "Show transfer progress in adb sync/pull/push."
am: 26352bf1fb

* commit '26352bf1fbbc8efdfdd0ef4d7c008fcbec445f29':
Show transfer progress in adb sync/pull/push.
b708d1628332ea9266d08f0297cd9e9ee341a64f 28-Oct-2015 Elliott Hughes <enh@google.com> Show transfer progress in adb sync/pull/push.

Change-Id: If5439877d060f9bab29cf84be996071cf680c2d4
/system/core/adb/commandline.cpp
f856b39141fec5b1d165216d265f237fcdcaf2f2 27-Oct-2015 David Pursell <dpursell@google.com> Merge "adb: fix -Tt options to match ssh."
am: 76e9236a42

* commit '76e9236a42d8652f46cc690e4fdb7636d5e8386f':
adb: fix -Tt options to match ssh.
08a27094d94bec29a4dfa1fd9acfedebc80e4600 20-Oct-2015 David Pursell <dpursell@google.com> adb: fix -Tt options to match ssh.

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
/system/core/adb/commandline.cpp
04c64dba9fe42110a1ed45bda5f8faa24715d75f 24-Oct-2015 Josh Gao <jmgao@google.com> 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.
8dcdb57dafd554e801de97012e7d0ef6ec63a5ac 24-Oct-2015 Josh Gao <jmgao@google.com> 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
/system/core/adb/commandline.cpp
2535ea1e181ea1a0de1c5199db40bede5dc32d95 15-Oct-2015 David Pursell <dpursell@google.com> am ca0d66d5: Merge "adb: non-interactive shell stdin."

* commit 'ca0d66d597dde0a76adc3f5da15aedff4b6cb70b':
adb: non-interactive shell stdin.
1ed57f0dc333c0bc0800e222c569cca8a71deb89 07-Oct-2015 David Pursell <dpursell@google.com> 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
/system/core/adb/commandline.cpp
28a3e4958e74c4a3537e36329a3511410918c4e4 08-Oct-2015 Elliott Hughes <enh@google.com> am 1407b286: Merge "Fix adb -d/-e error reporting."

* commit '1407b28628afec6c06eb6cb818f800083df668e1':
Fix adb -d/-e error reporting.
8d28e191c5ba81b82e51e3fd120d03851e1d905f 07-Oct-2015 Elliott Hughes <enh@google.com> 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
/system/core/adb/commandline.cpp
428f3434ae9c245cda8676bcbdbfa0a5d97faa86 01-Oct-2015 David Pursell <dpursell@google.com> am de3faec6: am fd18d9e2: Merge "adb: put legacy shell: service back in."

* commit 'de3faec64d407e76013913cb39cf569f692e8f8f':
adb: put legacy shell: service back in.
de3faec64d407e76013913cb39cf569f692e8f8f 01-Oct-2015 David Pursell <dpursell@google.com> am fd18d9e2: Merge "adb: put legacy shell: service back in."

* commit 'fd18d9e254874557aa44d42bd6d6bdf4352b0e36':
adb: put legacy shell: service back in.
70ef7b40f96e44ebb86f4eb23ccfa1a9230cdb65 30-Sep-2015 David Pursell <dpursell@google.com> 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
/system/core/adb/commandline.cpp
b8db64313adf4052e2d55734dfad202388c1473e 24-Sep-2015 Yabin Cui <yabinc@google.com> 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.
56ece709b093aa7570aa2915fa98682113acc5cb 24-Sep-2015 Yabin Cui <yabinc@google.com> am e4975da3: Merge "Adb: use VLOG() to replace D() for verbose logging."

* commit 'e4975da33326295885f4c606288516d73459c68e':
Adb: use VLOG() to replace D() for verbose logging.
aed3c61c4437ebb05eadfb3bf85d6962c30b9935 23-Sep-2015 Yabin Cui <yabinc@google.com> 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
/system/core/adb/commandline.cpp
90f297ada10254c0156f6e8488edf7663cd582ff 22-Sep-2015 David Pursell <dpursell@google.com> am b0d84d16: am 36856b73: Merge "adb: add -Tt options to `adb shell`."

* commit 'b0d84d16ffeabd3aa1b9d9ecf48110ff4f8508e7':
adb: add -Tt options to `adb shell`.
b0d84d16ffeabd3aa1b9d9ecf48110ff4f8508e7 22-Sep-2015 David Pursell <dpursell@google.com> am 36856b73: Merge "adb: add -Tt options to `adb shell`."

* commit '36856b7306b50e22f98c3299a6c951cb74fd1854':
adb: add -Tt options to `adb shell`.
4e2fd36bc8c16147cab323b0418a7666812d3bc7 22-Sep-2015 David Pursell <dpursell@google.com> 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
/system/core/adb/commandline.cpp
de6aed81c8c8b9a7c339c58c9018bb260ff064b7 15-Sep-2015 David Pursell <dpursell@google.com> am a3ef4fad: am 0af19a0e: Merge "adb: Fix missing shell protocol usage."

* commit 'a3ef4fad70692c88819b95a41437c03e9a3398a6':
adb: Fix missing shell protocol usage.
a3ef4fad70692c88819b95a41437c03e9a3398a6 15-Sep-2015 David Pursell <dpursell@google.com> am 0af19a0e: Merge "adb: Fix missing shell protocol usage."

* commit '0af19a0e82d7808678f3b92a8c5b4b8cb80ee216':
adb: Fix missing shell protocol usage.
71c83126a86de8986b24e5c7cd1a239d2fcc7fa1 15-Sep-2015 David Pursell <dpursell@google.com> 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
/system/core/adb/commandline.cpp
e4c0454083f6e0a1d104235eb89c855ea1876b3c 14-Sep-2015 David Pursell <dpursell@google.com> am 07448e07: am 76f4a653: Merge changes from topic \'adb_shell\'

* commit '07448e072e50703b01aca9f99cf03ead030746de':
adb: add client side shell protocol and enable.
adb: implement shell protocol.
07448e072e50703b01aca9f99cf03ead030746de 14-Sep-2015 David Pursell <dpursell@google.com> am 76f4a653: Merge changes from topic \'adb_shell\'

* commit '76f4a6533c6b803e267225b42c5dda63f23bf3ea':
adb: add client side shell protocol and enable.
adb: implement shell protocol.
606835ae5c4b9519009cdff8b1c33169cff32cb1 09-Sep-2015 David Pursell <dpursell@google.com> 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
/system/core/adb/commandline.cpp
824a51eae48e941053ae6a15f514f7d9ae85e8d7 09-Sep-2015 Yabin Cui <yabinc@google.com> am bd9305ee: am 0df24ea2: Merge "adb: refactor _is_valid_ack_reply_fd"

* commit 'bd9305eeb7152058ba8255f0c2601d512c906f98':
adb: refactor _is_valid_ack_reply_fd
bd9305eeb7152058ba8255f0c2601d512c906f98 09-Sep-2015 Yabin Cui <yabinc@google.com> am 0df24ea2: Merge "adb: refactor _is_valid_ack_reply_fd"

* commit '0df24ea234fcfb9ac57ed94701868426a41d8642':
adb: refactor _is_valid_ack_reply_fd
a13df3070f03da937219d92549a4dab8fb45b65c 08-Sep-2015 Spencer Low <CompareAndSwap@gmail.com> 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>
/system/core/adb/commandline.cpp
04aa49346a015e179dff7a28853380eb0f4424fa 05-Sep-2015 David Pursell <dpursell@google.com> am 74b6e8ec: am e4c1bb53: Merge "adb: `features` passes transport features."

* commit '74b6e8ecfdb4e7f46d53f174e8ba21ce74f90482':
adb: `features` passes transport features.
74b6e8ecfdb4e7f46d53f174e8ba21ce74f90482 05-Sep-2015 David Pursell <dpursell@google.com> am e4c1bb53: Merge "adb: `features` passes transport features."

* commit 'e4c1bb53068db184ee4cb19513ffe7764a09722f':
adb: `features` passes transport features.
880be434a9ec197100fe5c6f0b299353d13b916b 05-Sep-2015 David Pursell <dpursell@google.com> 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
/system/core/adb/commandline.cpp
9bbc68dd0782966b3e5e583afabb7b94c02e860a 03-Sep-2015 Yabin Cui <yabinc@google.com> am 7d0b4ada: am 6562c151: Merge "adb: clean up debug tracing a little."

* commit '7d0b4ada0bf539a0f48b00e211799400aa733f4d':
adb: clean up debug tracing a little.
7d0b4ada0bf539a0f48b00e211799400aa733f4d 03-Sep-2015 Yabin Cui <yabinc@google.com> am 6562c151: Merge "adb: clean up debug tracing a little."

* commit '6562c1513b2b7bd88da8b1d0c88b89e66b2dcd69':
adb: clean up debug tracing a little.
7a3f8d6691b3fbd8014a98de8455dbcfcc9629e4 03-Sep-2015 Yabin Cui <yabinc@google.com> 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
/system/core/adb/commandline.cpp
59224c9537c0a0e96e3ead81084133ecab41c598 01-Sep-2015 Elliott Hughes <enh@google.com> resolved conflicts for merge of 46603db5 to mnc-dr-dev-plus-aosp

Change-Id: I3fb7ff8e9d9313c294620ae0ce63a17766940ec4
1f9d3b07a6d1e1c1d537e4d9711fc2b3e43f3cb9 01-Sep-2015 Siva Velusamy <vsiva@google.com> am c9525ec3: Merge "adb: set thread names (linux & mac)"

* commit 'c9525ec366232aa6a0968be1cc8e8abc37df789f':
adb: set thread names (linux & mac)
49ee7cf9a10f66ffa9a3490c69db5fa46e0a966b 29-Aug-2015 Siva Velusamy <vsiva@google.com> adb: set thread names (linux & mac)

Bug: 23423333
Change-Id: I0069f32ddbae2a10fb130064f721facf45b2cc09
/system/core/adb/commandline.cpp
24f165f121f3268c3239cabe5ac675a946fe6732 22-Aug-2015 Elliott Hughes <enh@google.com> 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
/system/core/adb/commandline.cpp
e4baae6d066c7d39af127a2ba1df5e91475db1a9 25-Aug-2015 Elliott Hughes <enh@google.com> am 12d762e1: am e8e272c5: Merge "EINTR is handled by adb_read/unix_read and friends."

* commit '12d762e17694c0137aa7570b4b71536e59643bb0':
EINTR is handled by adb_read/unix_read and friends.
8fcd8bc046188abe0b0e87754af472d4838b4c50 25-Aug-2015 Elliott Hughes <enh@google.com> EINTR is handled by adb_read/unix_read and friends.

No need to clutter the code with cases that won't happen.

Change-Id: I47c5a2e6170f902d2618719f44492234a4869567
/system/core/adb/commandline.cpp
6b5f77c9bb0923e0072651a52a500c8c10b4d32b 24-Aug-2015 Elliott Hughes <enh@google.com> am c583c511: am 186f1dee: Merge "adb sync cleanup."

* commit 'c583c5112bb6634114cd9759c1cfbad61a13b397':
adb sync cleanup.
aa2454919098ee14cd232669f1e7dbb33ed07ccf 03-Aug-2015 Elliott Hughes <enh@google.com> adb sync cleanup.

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
/system/core/adb/commandline.cpp
f3f5bce204d264970dcc91b8f0a4149174b4add6 14-Aug-2015 David Pursell <dpursell@google.com> am 6a701bd9: am b53b521e: Merge "Add `adb features`."

* commit '6a701bd94b067c2ab873964f63c3d954bc59610f':
Add `adb features`.
90d4b739ab94fded63086de1261e70a3d39ceb1d 21-May-2015 Dan Albert <danalbert@google.com> Add `adb features`.

Shows the features supported by the active adb server.

Change-Id: I4a58a2ca082823c43f7a49e2c62ff80df6426756
/system/core/adb/commandline.cpp
56d11898aa6937df3d1342b7d99dca8813d162a4 13-Aug-2015 Elliott Hughes <enh@google.com> am 80e83972: am 9537ca80: Merge "adb: start-server and kill-server error output"

* commit '80e83972d0bce74d218f72b76339e6761ad6b03b':
adb: start-server and kill-server error output
f18fc0879be9cd506be6b1e051feb543b0746bdb 12-Aug-2015 Spencer Low <CompareAndSwap@gmail.com> adb: start-server and kill-server error output

- 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>
/system/core/adb/commandline.cpp
efc8077246a3e816957a774f3d272b909c1c1b12 12-Aug-2015 Elliott Hughes <enh@google.com> am c01231b3: am 2fb00423: Merge "Always include the adb version in the log."

* commit 'c01231b399c38f00afe0872b3a51837518b713dc':
Always include the adb version in the log.
42ae2604f43ef88be748f125e8733f2c08b83fae 12-Aug-2015 Elliott Hughes <enh@google.com> Always include the adb version in the log.

"Are you running the right version?" seems to be a common cause of debugging
confusion.

Change-Id: I4a4ba95e876dafc05e515058ca059ea370273f78
/system/core/adb/commandline.cpp
6396f64fd795e0ff493e3d59b07ce27076c1170d 11-Aug-2015 Elliott Hughes <enh@google.com> am 61ff977b: am 1f36ae49: Merge "adb: win32: write ACK to separate pipe instead of stdout"

* commit '61ff977ba49f43d87fed86eb5b2e2bfc279f902b':
adb: win32: write ACK to separate pipe instead of stdout
5c398d2ce96150e94e596e959bfe2246b94de660 09-Aug-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: write ACK to separate pipe instead of stdout

The win32 version of 9f2d1a9cfc04e1d5970823da1878097288a9a9cd. 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>
/system/core/adb/commandline.cpp
184585c417a4411b18ba41d938501ab3f5b25267 07-Aug-2015 Elliott Hughes <enh@google.com> am af60acef: am 98714882: Merge "adb start-server: Use a separate fd for sending initial OK"

* commit 'af60acef8231f03f7c736ed8ce86bd59979f9f6c':
adb start-server: Use a separate fd for sending initial OK
9f2d1a9cfc04e1d5970823da1878097288a9a9cd 07-Aug-2015 Siva Velusamy <vsiva@google.com> adb start-server: Use a separate fd for sending initial OK

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
/system/core/adb/commandline.cpp
5e6d1dcfac43422a135b1540c4bb245bfe89b294 01-Aug-2015 Elliott Hughes <enh@google.com> am 3d561748: am ec035950: Merge "Clean up -p handling slightly."

* commit '3d5617487c07f1fcbdf23755e0ca01559e3c5f3b':
Clean up -p handling slightly.
048b27c0665faecf72372de2884790ef60dfe1fd 31-Jul-2015 Elliott Hughes <enh@google.com> Clean up -p handling slightly.

Change-Id: I8a5cd4a7adb0dde9d09e0cbb620874b1bca35e43
/system/core/adb/commandline.cpp
e0b43a17852081c2fe1c0d2207006e421ffcc74b 31-Jul-2015 Elliott Hughes <enh@google.com> resolved conflicts for merge of 4e90b0ae to mnc-dev-plus-aosp

Change-Id: Iff0f469f09a0ad442db5b593345eaf52c3ca8104
5c74270f95107952a893584d02b33f9a79f6b3c4 31-Jul-2015 Elliott Hughes <enh@google.com> More adb cleanup.

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
/system/core/adb/commandline.cpp
d2117974e4c22ff6b8967c3b5cd2d497a6ffc856 31-Jul-2015 Elliott Hughes <enh@google.com> resolved conflicts for merge of 486645ee to mnc-dev-plus-aosp

Change-Id: I027a4de6e4ebae3bee6b7d2e56bd39c284b8a062
47d67c96ec991ef1690b4c07188335cbc4bfa2aa 06-May-2015 Alex Vallée <avallee@chromium.org> Write mkdirs in more idiomatic C++ style.

~ 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
/system/core/adb/commandline.cpp
24419f3c2e5b821e8f3efcfef32c9d530f0bd0d9 28-Jul-2015 Elliott Hughes <enh@google.com> am ce2047a9: am 1a706865: Merge "Fix const-ness of strrchr callers."

* commit 'ce2047a947eaf3c02e39c22a7b461e8a0acd87f2':
Fix const-ness of strrchr callers.
3e7048c027ffa081d2fea84b661a6da895a9f1fb 28-Jul-2015 Elliott Hughes <enh@google.com> Fix const-ness of strrchr callers.

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
/system/core/adb/commandline.cpp
d704ede39253c1b28900c54b57f7dc57cb0367e8 23-Jul-2015 Elliott Hughes <enh@google.com> am 2fc8a91e: am 6b40d0aa: Merge "adb: win32: fix exec-in and exec-out to use binary mode"

* commit '2fc8a91eb35556b6f2bb4018b0fe2c08de55fe1c':
adb: win32: fix exec-in and exec-out to use binary mode
fee06481213be7c2c5ba772bc45e56baa7802a95 23-Jul-2015 Elliott Hughes <enh@google.com> am d66e949b: am 2e7c39ec: Merge ""adb tcpip" should require a numeric argument."

* commit 'd66e949b14305b367d3de4ba00901bff1122bb0e':
"adb tcpip" should require a numeric argument.
6b40d0aaa1e8142dbe14a1fb1bfd7ff04de54e53 23-Jul-2015 Elliott Hughes <enh@google.com> Merge "adb: win32: fix exec-in and exec-out to use binary mode"
19d80b878c3a91bec31bece096ca6ab012de77e7 22-Jul-2015 Elliott Hughes <enh@google.com> "adb tcpip" should require a numeric argument.

Defaulting to port 0 just breaks stuff.

Bug: http://b/22636927
Change-Id: I6239900e0828e71b31171d0184c24824957c99c8
/system/core/adb/commandline.cpp
e45a665040bfd317d9ed36ecac64a33d951e1fd7 16-Jul-2015 Elliott Hughes <enh@google.com> am c06c3001: am a1c344b9: Merge "Move mkdirs to adb_utils."

* commit 'c06c3001156cbbdf8d6b3e187e0f92c51c5a80b3':
Move mkdirs to adb_utils.
14216148210fef447aaed46d5f764844a605d3ae 06-May-2015 Alex Vallée <avallee@chromium.org> Move mkdirs to adb_utils.

There were duplicate implementations in commandline.cpp and
file_sync_client.cpp.

Change-Id: Ib448f76c0d7ffdcd577336b1c610a881425bc2db
/system/core/adb/commandline.cpp
fcbc32de34ceea570824b98f243d40a228df1989 09-Jul-2015 Dan Albert <danalbert@google.com> am 00599eca: am e84205bf: Merge "Revert "Turn on -Wformat-nonliteral.""

* commit '00599eca7446f28762da3854566cff0b2ba46799':
Revert "Turn on -Wformat-nonliteral."
286bb6ddbd52584af0c6c76fbe0498f3dea4b944 09-Jul-2015 Dan Albert <danalbert@google.com> Revert "Turn on -Wformat-nonliteral."

One of my build aliases doesn't play nice with USE_MINGW=1, so my build lied to me. Will revert until I fix it up.

This reverts commit 459df8f3a14d4c614f0211049800cf7cad6d30ad.

Change-Id: I7905c5ae5ee85fb2d228ce63d81c79f140998c18
/system/core/adb/commandline.cpp
f9b81ccd7560deeade1f8bfc3fedbd5a1b460986 09-Jul-2015 Dan Albert <danalbert@google.com> am fcdc3141: am a35affb5: Merge "Turn on -Wformat-nonliteral."

* commit 'fcdc3141d3209afb8a8a62764fa66911a7104e74':
Turn on -Wformat-nonliteral.
459df8f3a14d4c614f0211049800cf7cad6d30ad 08-Jul-2015 Dan Albert <danalbert@google.com> Turn on -Wformat-nonliteral.

Apparently there are two classes of this warning in clang.
-Wformat-security is only emitted for cases of
`func(nonliteral_fmt_string)` (no args), and -Wformat-nonliteral is
emitted for cases *with* arguments. For whatever reason, the latter
isn't included in -Wextra and must be manually enabled.

To make this more easily portable to Windows, move the existing
gnu_printf/__printf__ decision into base/macros.h as ATTRIBUTE_FORMAT.

Change-Id: I3b0990e1d1f0a2e9c13b32f5cd60478946cb5fc6
/system/core/adb/commandline.cpp
5ca8b9b0e639aec6e5492b9c2df9945f48a7bed2 13-Jun-2015 Elliott Hughes <enh@google.com> am dc5993b3: am 4931ae54: Merge "Minor "adb help" fixes."

* commit 'dc5993b3bac7797fb4163e3ea78cdc80f2f0d024':
Minor "adb help" fixes.
7e067cff7a635f3089568192a197140225d20495 12-Jun-2015 Elliott Hughes <enh@google.com> Minor "adb help" fixes.

One day we should slim this down. (Maybe implement the "help" versus
"help all" distinction that doesn't currently exist but was documented
before this change.)

Bug: https://code.google.com/p/android/issues/detail?id=158394
Change-Id: Ie24b588ffea00d262ce7ab0e5c328120ba8af240
/system/core/adb/commandline.cpp
b7dfb79b53c516e54a8964ba66e207a3bb4db9ee 23-May-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: fix exec-in and exec-out to use binary mode

adb exec-in and exec-out are designed to read/write binary data
according to the commit description at:
https://android.googlesource.com/platform/system/core/+/5d9d434%5E!/

On Windows, when adb_read and adb_write are used, they are always in
binary mode (because sysdeps_win32.cpp calls Windows APIs direct). But
unix_read, unix_write, fread, fwrite, read, write use the text
translation mode of the C Runtime file descriptor, which is by default
textmode.

adb exec-in and exec-out use copy_to_file() which uses unix_read() and
fwrite() when reading/writing stdin and stdout, thus, copy_to_file()
should switch to binary mode for those cases (it already uses binary
mode for file descriptors other than stdin and stdout).

copy_to_file() is also called by adb backup, adb restore, and adb
install-multiple, but those do not use stdin or stdout, so those
codepaths should not be affected by this change.

Change-Id: I3446d9b363d20a2c2f6be2b96e55b653d99df2f9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/commandline.cpp
cb0322f53604c2b292e23317389add3c54613438 02-Jun-2015 Svetoslav <svetoslavganov@google.com> am 23d84074: Improve adb install help.

* commit '23d84074652b77385431fc0d1505b7d43b7dba9e':
Improve adb install help.
23d84074652b77385431fc0d1505b7d43b7dba9e 02-Jun-2015 Svetoslav <svetoslavganov@google.com> Improve adb install help.

Bug: 21365060
Change-Id: I0a4ea5cf3a2f37a82161b30f7eec5781d175aa8f
/system/core/adb/commandline.cpp
06e914eb8e7273a44a407d4679665ce09f865388 30-May-2015 Elliott Hughes <enh@google.com> am 5dd45034: am ce817c38: Merge "Fix error handling/reporting for "adb forward" and "adb reverse"."

* commit '5dd45034c3785792c59b3ef663ac2b669637d607':
Fix error handling/reporting for "adb forward" and "adb reverse".
424af02f363a305a349ff99e1cc253ac5bc642c9 30-May-2015 Elliott Hughes <enh@google.com> Fix error handling/reporting for "adb forward" and "adb reverse".

We really need better infrastructure for parsing adb subcommands, but
in the meantime...

At least this cleans up a little more of the implementation too.

Bug: http://b/20736014
Change-Id: I76209847da3724906c71924017bcb69fa31e0b49
/system/core/adb/commandline.cpp
420979613649e6abcf4823ff7c73beb2cab9f477 28-May-2015 Lorenzo Colitti <lorenzo@google.com> am 0983a6d5: Merge "Document the -g option to adb install." into mnc-dev

* commit '0983a6d54c202fde75523f1340bd9c9a168ab98c':
Document the -g option to adb install.
0b3baac51217b14be9eacb8865f31be8f6b4bbc3 27-May-2015 Lorenzo Colitti <lorenzo@google.com> Document the -g option to adb install.

Change-Id: I012165df343c24953f1c1cfcdce379bf1b67c624
/system/core/adb/commandline.cpp
6001c87cbcafba68975fd9b3aa69f4952396f83c 13-May-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: fix StringPrintf format string checking of %zd and PRIu64

At runtime, vsnprintf (and android::base::StringPrintf which calls it)
call a mingw version of vsnprintf, not the vsnprintf from MSVCRT.DLL.
The mingw version properly understands %zd and PRIu64 (the latter,
provided that you #include <inttypes.h>).

The problem was that android::base::StringPrintf was causing
compile-time errors saying that %zd and PRIu64 were not recognized. It
seems that this was because the attribute on the function prototypes
specified `printf' instead of `gnu_printf'. Once that was fixed to match
vsnprintf's attribute, the warnings went away.

This uses similar preprocessor techniques as <android/log.h>.

Also restore a %zd usage to avoid a static_cast<>, and make
print_transfer_progress()'s format string compile-time checkable (and
tweak some types and %llu => PRIu64).

Change-Id: I80b31b9994858a28cb7c6847143b86108b8ab842
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/commandline.cpp
207ddb20ac2f25de19d74fe88f2a526e0ee5cfa6 08-May-2015 Elliott Hughes <enh@google.com> Fix "adb remount" for devices without an oem partition.

On a device without an oem partition, we now have an /oem directory
anyway. This causes find_mount to fail, and that was returning nullptr
from a std::string-returning function. Boom!

Also clean up the bits of code I had to trace through between "adb remount"
on the host to the crash on the device as I debugged this.

The only other meaningful change is the error checking in
adb_connect_command --- adb_connect can also return -2.

Bug: http://b/20916855
Change-Id: I4c3b7858e13f3a3a8bbc7d30b3c0ee470bead587
(cherry picked from commit 5677c23e8d0c085be8d8429a5d125147d11e9bb2)
/system/core/adb/commandline.cpp
ee5ce0d14f099e7295a0aed54accd9d952e6a6a1 08-May-2015 Elliott Hughes <enh@google.com> Merge "Fix "adb remount" for devices without an oem partition."
02418b3e093b025ee9b9ae2e51a37810cc5322d6 08-May-2015 Elliott Hughes <enh@google.com> Try to include the SHA in a ddmslib-compatible way.

Bug: http://b/20918202
Change-Id: I0c1a48459372b0d28aaf9d09d82540e44b438c9c
(cherry picked from commit f3bbfa6a216669c4cd91d5f936662e89e0ae07ca)
/system/core/adb/commandline.cpp
5677c23e8d0c085be8d8429a5d125147d11e9bb2 08-May-2015 Elliott Hughes <enh@google.com> Fix "adb remount" for devices without an oem partition.

On a device without an oem partition, we now have an /oem directory
anyway. This causes find_mount to fail, and that was returning nullptr
from a std::string-returning function. Boom!

Also clean up the bits of code I had to trace through between "adb remount"
on the host to the crash on the device as I debugged this.

The only other meaningful change is the error checking in
adb_connect_command --- adb_connect can also return -2.

Bug: http://b/20916855
Change-Id: I4c3b7858e13f3a3a8bbc7d30b3c0ee470bead587
/system/core/adb/commandline.cpp
f3bbfa6a216669c4cd91d5f936662e89e0ae07ca 08-May-2015 Elliott Hughes <enh@google.com> Try to include the SHA in a ddmslib-compatible way.

Bug: http://b/20918202
Change-Id: I0c1a48459372b0d28aaf9d09d82540e44b438c9c
/system/core/adb/commandline.cpp
142ec75cf882bf023853f0321cd559377daccc60 07-May-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: fix adb emu command

The adb emu command was never working because the socket connection to
the emulator was closed without reading all of the data that the
emulator sent. On Windows, this caused the emulator's recv() call to
error-out, so it never got the command that was sent.

Before settling on this fix, I also experimented changing the arguments
to the socket shutdown() call and that didn't seem to help. I also tried
removing the call to shutdown() and that didn't help. So that should
rule out shutdown() as the problem. One experiment that helped was
delaying before calling adb_close(), but that is of course fragile and
doesn't address the real issue, which is not closing the socket until
the commands have been read.

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

Change-Id: I8fa4d740a2faa2c9922ec50792e16564a94f6eed
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/commandline.cpp
c1cfbd304ad1f4f5f136a175ed687de41701235a 06-May-2015 Dan Albert <danalbert@google.com> Include the git sha in the adb version.

Also add --version to adbd to display the same thing.

Change-Id: I47dfbad16c892c42ea938aedd085ba77492791ba
(cherry picked from commit 1ba1d7c1ee644967ff4743b0d257290cbeca7a83)
/system/core/adb/commandline.cpp
1ba1d7c1ee644967ff4743b0d257290cbeca7a83 06-May-2015 Dan Albert <danalbert@google.com> Include the git sha in the adb version.

Also add --version to adbd to display the same thing.

Change-Id: I47dfbad16c892c42ea938aedd085ba77492791ba
/system/core/adb/commandline.cpp
9b0f354fa25e3d5add516000c761e07c81c3bbc1 05-May-2015 Elliott Hughes <enh@google.com> Simplify adb_thread_create.

Change-Id: I36d6021ef8fbc23e8bcd4ddbe1dac0eba467cc70
/system/core/adb/commandline.cpp
3bd73c12c07dcefc965abeef535ac53c4754d682 05-May-2015 Elliott Hughes <enh@google.com> Give enum types CamelCase names for clarity.

Change-Id: I1c89f1cc155ee839f372fb14d972a288183b8bcd
/system/core/adb/commandline.cpp
32687beaf258d216115de51dbca89d1e9cbc376d 05-May-2015 Elliott Hughes <enh@google.com> Remove non-functional "adb persist".

It isn't documented, it doesn't work, and it was only hacked into
"adb shell" anyway. (It's not a bad idea, though, but if we do it
we should do it properly.)

Change-Id: I930a5c6dd1d2850bfdf131f2e989ae04100f7db9
/system/core/adb/commandline.cpp
aceb9c08df80da9c929af2998c54870455b79a03 05-May-2015 Elliott Hughes <enh@google.com> Implement the ssh(1) escaping rules.

The first rule of ssh(1) escaping is that there is no escaping.

This doesn't undo any of my recent security fixes because they're all
calling escape_arg themselves.

This fixes "adb shell rm /data/dalvik-cache/arm/*".

Also remove do_cmd which caused concern during code review.

Bug: http://b/20564385
Change-Id: I4588fd949d51e2a50cff47ea171ed2d75f402d0d
(cherry picked from commit 2b10111d25adcfe3627103b73edad22f188c97ba)
/system/core/adb/commandline.cpp
2b10111d25adcfe3627103b73edad22f188c97ba 05-May-2015 Elliott Hughes <enh@google.com> Implement the ssh(1) escaping rules.

The first rule of ssh(1) escaping is that there is no escaping.

This doesn't undo any of my recent security fixes because they're all
calling escape_arg themselves.

This fixes "adb shell rm /data/dalvik-cache/arm/*".

Also remove do_cmd which caused concern during code review.

Bug: http://b/20564385
Change-Id: I4588fd949d51e2a50cff47ea171ed2d75f402d0d
/system/core/adb/commandline.cpp
e1a55004e9fa46055c59f86e952e9e457c36c3f2 02-May-2015 Elliott Hughes <enh@google.com> Add WriteFdFmt and clean up more code.

Also say *which* device wasn't found.

Bug: http://b/20666660
Change-Id: I50e234ad89e39ae0a8995083c0b642c61275c5a3
(cherry picked from commit ab52c181fa4c1c9891644635dc5653cda5b90e2b)
/system/core/adb/commandline.cpp
ab52c181fa4c1c9891644635dc5653cda5b90e2b 02-May-2015 Elliott Hughes <enh@google.com> Add WriteFdFmt and clean up more code.

Also say *which* device wasn't found.

Bug: http://b/20666660
Change-Id: I50e234ad89e39ae0a8995083c0b642c61275c5a3
/system/core/adb/commandline.cpp
92af733ee202caa3b5475fe27fcc81582f11e7c8 01-May-2015 Elliott Hughes <enh@google.com> More adb buffer fixes.

This patch factors out a lot of the basic protocol code: sending OKAY,
sending FAIL, and sending a length-prefixed string.

ADB_TRACE has been non-optional for a long time, so let's just remove
the #ifs.

Also actually build the device tracker test tool (and remove its duplicate).

Bug: http://b/20666660
Change-Id: I6c7d59f18707bdc62ca69dea45547617f9f31fc6
(cherry picked from commit e67f1f87d9b1188ec8617035db7006c37ee7b21e)
/system/core/adb/commandline.cpp
e67f1f87d9b1188ec8617035db7006c37ee7b21e 01-May-2015 Elliott Hughes <enh@google.com> More adb buffer fixes.

This patch factors out a lot of the basic protocol code: sending OKAY,
sending FAIL, and sending a length-prefixed string.

ADB_TRACE has been non-optional for a long time, so let's just remove
the #ifs.

Also actually build the device tracker test tool (and remove its duplicate).

Bug: http://b/20666660
Change-Id: I6c7d59f18707bdc62ca69dea45547617f9f31fc6
/system/core/adb/commandline.cpp
f1a58f8f33509201cabe71c6a9d01aa6b8f99966 29-Apr-2015 Elliott Hughes <enh@google.com> More fixed-length buffer removal.

Bug: http://b/20666660
Change-Id: I0c738e9fed2defed48a9cf2d0a4f7b99c08dcf3d
(cherry picked from commit 6452a89aa8934231e12ab77e0d90f12c3e892ad1)
/system/core/adb/commandline.cpp
6452a89aa8934231e12ab77e0d90f12c3e892ad1 29-Apr-2015 Elliott Hughes <enh@google.com> More fixed-length buffer removal.

Bug: http://b/20666660
Change-Id: I0c738e9fed2defed48a9cf2d0a4f7b99c08dcf3d
/system/core/adb/commandline.cpp
71aeb798154a515d5f4a91ecb9adb0896ab9a9e6 29-Apr-2015 Elliott Hughes <enh@google.com> Move __adb_error to std::string, and improve various errors.

Also remove an sprintf. Also fix various bits of code that were
reporting stale adb_error values when they meant strerror.

(cherry-pick of 078f0fcf4c63b8d8e8c10a18855eae04ca321e06.)

Bug: http://b/20666660
Change-Id: Ibeb48b7bc21bb0ec30ba47889d1d671ee480e1b7
/system/core/adb/commandline.cpp
078f0fcf4c63b8d8e8c10a18855eae04ca321e06 29-Apr-2015 Elliott Hughes <enh@google.com> Move __adb_error to std::string, and improve various errors.

Also remove an sprintf. Also fix various bits of code that were
reporting stale adb_error values when they meant strerror.

Bug: http://b/20666660
Change-Id: Ibeb48b7bc21bb0ec30ba47889d1d671ee480e1b7
/system/core/adb/commandline.cpp
876881b22ad5d735cdb3ae2ac1afa6c336378808 22-Apr-2015 Elliott Hughes <enh@google.com> Merge "Add missing null checks after allocations."
dc3b459ff9f0ff71d404ba7198083e532a0dd894 22-Apr-2015 Elliott Hughes <enh@google.com> Add missing null checks after allocations.

Bug: http://b/20317729
Change-Id: I62bb761d48ee59a1f4ddd0cdd0632432305ca2ca
/system/core/adb/commandline.cpp
1555147bc47349dd786098e9d660bbed205d25fc 22-Apr-2015 Elliott Hughes <enh@google.com> Plumb more of the error reporting through.

This doesn't fix the bug, but it does flatten the bug to the well-known
and long-standing "adb shell" doesn't return exit statuses, so when we
fix that, this one will fix itself.

Bug: http://b/20423886
Change-Id: I48351e46f05dd3f2f6e57f0df1d851333458d0ef
/system/core/adb/commandline.cpp
d236d071b960a387f536712f0314b99696167178 21-Apr-2015 Elliott Hughes <enh@google.com> Fix "adb sync" for devices without vendor and oem.

Bug: http://b/20440110
Change-Id: I2481992198890f5ca50412c2b7ca361101961413
/system/core/adb/commandline.cpp
53daee6a2b415caa0ff3e425c7fa613c834bca61 19-Apr-2015 Elliott Hughes <enh@google.com> Fix the Windows adb build.

It looks like we can't use clang on Windows yet because libc++ isn't ready.
So move back to GCC for the Windows host clang. Work around the mingw
printf format string problems that made us want to switch to clang in the
first place, and #include "sysdeps.h" in adb_utils.cpp to work around the
absence of lstat(2) on Windows.

Change-Id: Icd0797a8c0c2d1d326bdd704ba6bcafcbaeb742f
/system/core/adb/commandline.cpp
6c34bbaa6845a1c3ccb116d45b1a873ba6256fc8 18-Apr-2015 Elliott Hughes <enh@google.com> Use escape_arg in "adb backup".

This doesn't fix the injection vulnerability, but it makes "adb backup"
no worse than the other commands, and lets me fix them all at once.

Bug: 20323053
Change-Id: I39843c065d9d738b6b7943b2ffd660e4a031cc36
/system/core/adb/commandline.cpp
a7090b94c181f3efe5b53d2c8367b78d99074dfe 18-Apr-2015 Elliott Hughes <enh@google.com> Remove yet more fixed-length buffers (and their overruns).

Bug: 20317724
Change-Id: If137fc96f5f23576ccecd388ac87afefa47337c6
/system/core/adb/commandline.cpp
61a004c05f100741048d284fa527ac28c242d0bc 18-Apr-2015 Elliott Hughes <enh@google.com> Merge "Fix more buffer overruns."
5830577bd82fdb7c39555da20a4cf585b8bb376a 17-Apr-2015 Elliott Hughes <enh@google.com> Fix more buffer overruns.

Also add some tests.

Bug: 20323050
Change-Id: I9eaf3dc04efd85206663c4cca4f8c1208620a89a
/system/core/adb/commandline.cpp
2940ccff8605e929cc56353254f29f37823fdda7 17-Apr-2015 Elliott Hughes <enh@google.com> Use PRI* macros to fix the Windows build.

Change-Id: Icd400be05c2bc726265832875b5a05dba7966847
/system/core/adb/commandline.cpp
2baae3a876ada7e22986e92188f7933cae34ce3b 17-Apr-2015 Elliott Hughes <enh@google.com> Remove various fixed-length buffers (and their overflows).

Bug: 20323052
Bug: 20323051
Bug: 20317728
Bug: 20317727
Bug: 20317726
Bug: 20317725
Change-Id: I57a5e30a5b7867715f55cee7429aa36d7ce21484
/system/core/adb/commandline.cpp
a2f2e56796fef024c7374d033bd7d34af71fdf5a 17-Apr-2015 Elliott Hughes <enh@google.com> Move sysdeps_win32 to C++.

Change-Id: I27ca41b64d62bb3611b3a39a5c3bb4377d0773bc
/system/core/adb/commandline.cpp
dfa09fd635e341d5e47d67123a0e938710be5949 01-Mar-2013 Alistair Buxton <a.j.buxton@gmail.com> Disable CR/LF translation for adb interactive shell.

adb shell uses termios to disable canonical input processing in order to
get raw control codes but it does not disable CR/LF translation. The default
for Linux terminals is to convert CR to LF unless the running program
specifically asks for this to be disabled. Since adb does not, there is no
way to send a CR to any program run on adb shell. Many programs do in fact
differentiate and so are broken by this behaviour, notably nano. This patch
sets the termios flags to disable all line ending translation.

Change-Id: I8b950220f7cc52fefaed2ee37d97e0789b40a078
Signed-off-by: Alistair Buxton <a.j.buxton@gmail.com>
/system/core/adb/commandline.cpp
175b7bbfb4d935e1867a1d6df14e6ef94f2db2f4 29-Mar-2015 Tao Bao <tbao@google.com> adb: Add option to reboot into sideload mode in recovery

Currently it requires manual key press to enter the sideload mode. This
CL adds 'adb reboot sideload' to reboot the device into sideload mode
directly with text display on. With 'adb reboot sideload-auto-reboot',
it will reboot after the sideload regardless of the installation result,
unless interrupted by user.

Since it needs to write to /cache/recovery/command file, 'adb root' is
required before calling 'adb reboot sideload' and the one with
'-auto-reboot'.

Also it requires the matching CL in bootable/recovery.

Change-Id: Ib7bd4e216a1efc01e64460659c97c6005bbaec1b
/system/core/adb/commandline.cpp
50184062b87a121458fff7d8bda6656c59c71c77 02-Mar-2015 Spencer Low <CompareAndSwap@gmail.com> adb shell: Win32: fix Ctrl-C, tab completion, line editing, server echo

The 'adb shell' command on Windows has had problems:

* Ctrl-C killed the local Windows adb.exe process instead of sending the
Ctrl-C to the Android device.

* Local echo was enabled, causing everything typed to be displayed twice.

* Line input was enabled, so the Android device only received input
after hitting enter. This meant that tab completion did not work because
the tab wasn't seen by the shell until pressing enter.

* The usual input line editing keys did not work (Ctrl-A to go to the
beginning of the line, etc.).

This commit fixes these issues by reconfiguring the Win32 console and
then translating input into what Gnome Terminal would send, in effect
somewhat emulating a Unix terminal.

This does not fix all Win32 console issues, but is designed to be better
than what we had before, and to make the common day-to-day usage much
more comfortable and usable.

Change-Id: Idb10e0b634e27002804fa99c09a64e7176cf7c09
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/commandline.cpp
3313426fad9eaaf53017cdbde889ebcec91358ec 19-Mar-2015 Dan Albert <danalbert@google.com> File header cleanup.

* sysdeps.h should always be included first.
* TRACE_TAG needs to be defined before anything is included.
* Some files were missing copyright headers.
* Save precious bytes on my SSD by removing useless whitespace.

Change-Id: I88980e6e00b5be1093806cf286740d9e4a033b94
/system/core/adb/commandline.cpp
ec7a66713144a16361724fe88332b28bbf3f4b3c 16-Mar-2015 Elliott Hughes <enh@google.com> Revert "Revert "adb: support /oem partition""

This reverts commit 6084a0124f868c7ec43f6c415a27a168f27ff694.

The original build breakage is fixed by (a) building the verity
code for eng builds as well as userdebug builds and (b) moving
the exported remount service functions into a new header file.

Change-Id: Ice0c4f97d4db38ab7eb333c7a6e56bbd11123f5b
/system/core/adb/commandline.cpp
6084a0124f868c7ec43f6c415a27a168f27ff694 16-Mar-2015 Dan Albert <danalbert@google.com> Revert "adb: support /oem partition"

This is broken on userdebug builds, and it isn't completely clear why. The declaration for make_block-device_writable in adb.h wasn't updated to match the definition (which uses a std::string instead of a char*). adb.h is currently extern "C", and it isn't clear why this is only broken for userdebug, so I'd like to revert while we investigate.

This reverts commit 81416fdb186070fe4db3ca5fed2e713a4eecaac1.

Change-Id: I47f321574f9f21052e2c7332e8b0f6ef9ab98277
/system/core/adb/commandline.cpp
81416fdb186070fe4db3ca5fed2e713a4eecaac1 03-Nov-2014 MÃ¥rten Kongstad <marten.kongstad@sonymobile.com> adb: support /oem partition

Add support for /oem partition in commands 'adb remount' and 'adb sync'.

Change-Id: I5defc74ccaa37feaef74b9268e22b4075f98a59f
/system/core/adb/commandline.cpp
bac3474a8256cb32a29e8d46f78cad95a5502692 26-Feb-2015 Dan Albert <danalbert@google.com> Move adb to C++.

I keep trying to clean things up and needing std::strings. Might as
well just do this now.

usb_linux_client.c is going to stay as C because GCC isn't smart
enough to deal with the designated initializers it uses (though for
some reason it is in C mode).

The Darwin files are staying as C because I don't have a way to test
that they build.

The Windows files are staying as C because while I can actually build
for them, it's slow and painful.

Change-Id: I75367d29205a9049d34460032b3bb36384f43941
/system/core/adb/commandline.cpp