History log of /system/core/adb/adb_utils.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
a9e2b99a7fdd31bcd6d852c6db26fe592236a24f 26-May-2016 Yurii Zubrytskyi <zyy@google.com> [adb] Issue the "auth" emulator command before any other one

Emulator console now requires authentication; this means
'adb emu ...' commands silently fail because of it.
This CL adds an 'auth <token>' command to each user command,
making sure it won't be silently ignored.

Bug: https://code.google.com/p/android/issues/detail?id=211233
Change-Id: Id9ca4999fd2e6393cc88278eaf444243e13c0ec0
/system/core/adb/adb_utils.cpp
74e0fe73c02531e2aa3c4b9f72527bb7a1731158 26-Feb-2016 Josh Gao <jmgao@google.com> adb: symlinks to dirs count as dirs for pull destination.

This matches scp's behavior when pulling a directory that collides
with a symlink to a directory.

Bug: http://b/27362811
Change-Id: I0936d1ad48f13e24cd382e8e8400cc752bac3b66
(cherry picked from commit 1e611a33d524a7c7a31181aca10d1f4a4c9fc1b2)
/system/core/adb/adb_utils.cpp
addab3d84dccd01cae9ca7b8a4b274b935f18fd4 17-Feb-2016 Josh Gao <jmgao@google.com> adb: don't emulate fdevent or socketpair on Windows.

Change-Id: I16cf7d4427eb79f36db39e91f85402a268fa72f5
(cherry picked from commit 3777d2ecc05d397ca501f4ee296e4e66568bb1bd)
/system/core/adb/adb_utils.cpp
a1071c6924654de89e077f50f47271bc3e08c569 11-Feb-2016 Spencer Low <CompareAndSwap@gmail.com> adb: mkdirs fixes

Fix pathological case where the directory to be created can't be created
because there is already a file there. This was previously returning
success because the wrong var was passed to directory_exists().

Fix test to exercise this situation. Also clarify tests.

Change-Id: I0dc0f14084e0eda4e1498874d4ab2a6445d322ac
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
(cherry picked from commit 85c45bd5a185f09f24bb0d790b2038fe72b567a9)
/system/core/adb/adb_utils.cpp
706955ff0d159d28bb6eb06dc10178624c505f4e 21-Jan-2016 David Pursell <dpursell@google.com> base: add network address parsing function from adb.

This CL moves the network address parsing function from adb to libbase
so that it can be used by fastboot as well as adb.

libbase seemed like the right choice because:
1. It already has some parsing functions (parseint)
2. The net address parsing function uses the libbase string
functions so we have a libbase dependency anyway.

The parsing function has been modified slightly to make the canonical
address optional, and debug logging on success has been removed.

For adb the only functional difference is that parsing a network
address will no longer print the result to the debug log, which seemed
unnecessary.

Bug: http://b/26236380
Change-Id: Ife6df02937225fc66de87884d3572d79c092c522
/system/core/adb/adb_utils.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/adb_utils.cpp
4f71319df011d796a60a43fc1bc68e16fbf7d321 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename of base/ to android-base/.

Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
/system/core/adb/adb_utils.cpp
363af568b8491af1a4256b09b04cfa8a0606d8cc 08-Nov-2015 Spencer Low <CompareAndSwap@gmail.com> adb/base: minor compiler portability improvements

I've been using these changes to compile with Visual Studio.

- GetFileBasename(): __FILE__ uses \ with Visual Studio.

- adb_trace.cpp: Apparently VS needs an ampersand before the function name.

- "expr1 ? : expr2" is a GCC extension.

- <algorithm> contains std::min().

- seekdir can't always be #define'd because some headers have members
named seekdir.

- adb_utils.cpp: Not really a compiler issue, just a random fix:
0x7F/DEL is not printable.

Change-Id: I0dfb634f1ba4ccbc0d1b9f71b00e838fbebb3b41
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_utils.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`.
45b6fc878ab5ba0f76b6bb1947fe04ac6667c2f5 04-Nov-2015 Josh Gao <jmgao@google.com> adb: make mkdirs/secure_mkdirs do what they say.

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
/system/core/adb/adb_utils.cpp
787f3442cc7d7b1f07189d77413893e2c2c81447 04-Nov-2015 Josh Gao <jmgao@google.com> adb: make adb_basename match the POSIX behavior.

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
/system/core/adb/adb_utils.cpp
6dfef255b8fa77e3b5c0a69b7f276ea8e25e22cd 07-Oct-2015 Yabin Cui <yabinc@google.com> adb: keep file flags in fdevent_install.

Bug: 24615098
Change-Id: Ia791ecbe612f09aca3bbd5787513f121fae54da5
/system/core/adb/adb_utils.cpp
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/adb_utils.cpp
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/adb_utils.cpp
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/adb_utils.cpp
22191c30a63da7ca951281fffcb1fd59ae40dd54 02-Aug-2015 Spencer Low <CompareAndSwap@gmail.com> adb: fix mkdirs / adb pull with relative paths, fix win32 issues

Relative paths were being prefixed with OS_PATH_SEPARATOR on unix and
win32 causing adb to incorrectly try to make directories at the root.
Plus, absolute paths didn't work on win32 (C: got prefixed into \C:).

This fix is to use dirname (available on win32 via mingw's crt) to do
the messy parsing.

I added a test for the relative path case.

Change-Id: Ibb0a4a8ec7756351d252a4d267122ab18e182858
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_utils.cpp
5200c6670f041550c23821fec8e8e49b30ef6d29 31-Jul-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: initial IPv6 support and improved Winsock error reporting

Call getaddrinfo() for connecting to IPv6 destinations.

Winsock APIs do not set errno. WSAGetLastError() returns Winsock errors
that are more numerous than BSD sockets, so it really doesn't make sense
to map those to BSD socket errors. Plus, even if we did that, the
Windows C Runtime (that mingw binaries use) has a strerror() that does
not recognize BSD socket error codes.

The solution is to wrap the various libcutils socket_* APIs with
sysdeps.h network_* APIs. For POSIX, the network_* APIs just call
strerror(). For Windows, they call SystemErrorCodeToString() (adapted
from Chromium).

Also in this change:

- Various other code was modified to return errors in a std::string*
argument, to be able to surface the error string to the end-user.

- Improved error checking and use of D() to log Winsock errors for
improved debuggability.

- For sysdeps_win32.cpp, added unique_fh class that works like
std::unique_ptr, for calling _fh_close().

- Fix win32 adb_socketpair() setting of errno in error case.

- Improve _socket_set_errno() D() logging to reduce confusion. Map
a few extra error codes.

- Move adb_shutdown() lower in sysdeps_win32.cpp so it can call
_socket_set_errno().

- Move network_connect() from adb_utils.cpp to sysdeps.h.

- Merge socket_loopback_server() and socket_inaddr_any_server() into
_network_server() since most of the code was identical.

Change-Id: I945f36870f320578b3a11ba093852ba6f7b93400
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_utils.cpp
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/adb_utils.cpp
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/adb_utils.cpp
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/adb_utils.cpp
d48dbd89c8661607b338b696c14c9609050f3f29 24-Jul-2015 Elliott Hughes <enh@google.com> Fix Win32 adb build.

Change-Id: I0a07379c470b7fa7f9bdef68c17ccb7bd0bd2079
/system/core/adb/adb_utils.cpp
381cfa9a8bc262dcd823a8bb6adc189595a2fe7d 24-Jul-2015 Elliott Hughes <enh@google.com> Report getaddrinfo failures correctly.

Also move us off the "convenience" function because you can't get useful
error reporting from it.

Change-Id: I5fcc6a6d762f5f60906980a7835f01a35045be65
/system/core/adb/adb_utils.cpp
3d5f60dbba3bc0feabc05457d181547b295bb3b2 18-Jul-2015 Elliott Hughes <enh@google.com> Recognize IPv6 addresses for "adb connect".

Bug: http://b/22559299
Change-Id: I32891d706b5010c38db84a056e76dd279b780f75
/system/core/adb/adb_utils.cpp
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/adb_utils.cpp
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/adb_utils.cpp
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/adb_utils.cpp
84b0bf22644b35d6b3d3f7dc96311a484c3519b3 15-May-2015 Elliott Hughes <enh@google.com> Fix ' escaping in adb.

You can't just use \' inside a single-quoted string.

Bug: http://b/20323053
Bug: http://b/3090932
Change-Id: I73754b097671d02dc11c35052f0534b6dd789e4f
/system/core/adb/adb_utils.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/adb_utils.cpp
14b65736c5ed487ebba93d3ccc3e261ece71f833 21-Apr-2015 Elliott Hughes <enh@google.com> Merge "Use ' quoting to escape arguments."
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/adb_utils.cpp
5498adefb00cd979137361b98fcbf8d51f72ebeb 18-Apr-2015 Elliott Hughes <enh@google.com> Use ' quoting to escape arguments.

The specific motivating case is "text;ls;1.apk", but rather than continue
adding individual characters to the list of characters to be escaped, let's
just switch to quote all arguments with ', which only leaves ' itself to be
escaped.

Bug: 20323053
Bug: 19734868
Change-Id: I8bd71db9373bc2d1169fc11e46c889da6638550a
/system/core/adb/adb_utils.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/adb_utils.cpp
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/adb_utils.cpp