History log of /system/core/adb/file_sync_client.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
58021d15c94eb6a81d2673634956b5374af6a1e5 24-Feb-2017 Colin Cross <ccross@android.com> Move adb_dirname and adb_basename to libbase

adb already provides an implementation of dirname and basename that
take and produce std::strings, move it into libbase so it can be
used in the implementation of GetExecutableDirectory.

Test: out/host/linux-x86/nativetest64/adb_test/adb_test
Test: out/host/linux-x86/nativetest64/libbase_test/libbase_test
Test: adb shell /data/nativetest64/libbase_test/libbase_test64
Change-Id: Ideb1627607b14562121316d4ed27fa6fb0930684
/system/core/adb/file_sync_client.cpp
aac1145a5bdcc25d3e4bb60ebbad8e2a5c94fc5e 06-Dec-2016 Josh Gao <jmgao@google.com> adb: remove extraneous stat in sync_recv.

We do a remote stat to get the file's size before pulling in sync_recv,
but all of the callers to sync_recv have already done a stat. Pass the
expected file size into sync_recv to remove its stat.

Bug: http://b/31289465
Test: python test_device.py
Change-Id: I7ca8ed11c6134e5954acac86626f880ade3ec696
/system/core/adb/file_sync_client.cpp
5a1e3fdaf82aee348b1b22992a8c1d15db38413b 06-Dec-2016 Josh Gao <jmgao@google.com> Revert "Revert "adb: extend sync protocol's stat support.""

This reverts commit afa4b5d6eb45bbee8671a1bb93ea70506fb326e3.

Add functions to translate errno to and from the linux asm-generic
values, since mips has different values.

Bug: http://b/33058958
Test: python test_device.py with both old and new adbd
Change-Id: I1a122235f3e793ed10b3bf3ad293388015134150
/system/core/adb/file_sync_client.cpp
a3577e1ac558d83428c492e806549e278e5dc8fb 05-Dec-2016 Josh Gao <jmgao@google.com> Revert "Revert "adb: move adb_strerror to sysdeps/win32/errno.cpp.""

This reverts commit 43c02b27cd50a75f0fecb44e56a9bf32c6923aef.

Test: mma
Change-Id: I6b22ead8a4b964973ee2fdb8deba42bea74880cf
/system/core/adb/file_sync_client.cpp
afa4b5d6eb45bbee8671a1bb93ea70506fb326e3 05-Dec-2016 Josh Gao <jmgao@google.com> Revert "adb: extend sync protocol's stat support."

This reverts commit d6d5c38469203a63c686517d765a7e6d2bc24656.
/system/core/adb/file_sync_client.cpp
43c02b27cd50a75f0fecb44e56a9bf32c6923aef 05-Dec-2016 Josh Gao <jmgao@google.com> Revert "adb: move adb_strerror to sysdeps/win32/errno.cpp."

This reverts commit 4fba3d2638ecec0f87fe8d8913490bfbd7234d19.
/system/core/adb/file_sync_client.cpp
4fba3d2638ecec0f87fe8d8913490bfbd7234d19 30-Nov-2016 Josh Gao <jmgao@google.com> adb: move adb_strerror to sysdeps/win32/errno.cpp.

Bug: none
Test: mma
Change-Id: I9df4d6faf9883a78f50ca6b2b7c35f095d06ae20
/system/core/adb/file_sync_client.cpp
d6d5c38469203a63c686517d765a7e6d2bc24656 22-Nov-2016 Josh Gao <jmgao@google.com> adb: extend sync protocol's stat support.

Extend the file sync protocol to support calling regular stat (instead
of lstat), return error codes, and provide the entire stat struct.

Bug: http://b/33058958
Test: python test_device.py with both old and new adbd
Change-Id: I841123debc380f86194a19e91c97d85160112144
/system/core/adb/file_sync_client.cpp
05a3abfef34b7b7b0f4358c15fe5410cc088aa03 19-Nov-2016 Josh Gao <jmgao@google.com> adb: make sure that file mode macros match linux.

We use <sys/stat.h> mode macros on the host to parse modes sent over
from the device, so they had better match. Add static_asserts to ensure
this.

(Also, fix the cases where they don't.)

Test: mma -j48, compiled the static_asserts on darwin manually
Change-Id: I883e4e6c7489ea64d3c02d26790ac8293366d989
/system/core/adb/file_sync_client.cpp
da1f279509dc11b436818d0ef0b0bfb49d147fa0 18-Nov-2016 Josh Gao <jmgao@google.com> adb: fix progress percentage when pulling symlinks.

The adb protocol currently only supports lstat with no way of finding
the target of a symlink, so pulling a symlink that points to a file
looks like pulling a file with length equal to the length of path to
the symlink's target. Pulling a file that's sufficiently large can
overflow the int used to calculate percentage, and result in a bogus
completion percentage being displayed.

Bug: http://b/29277448
Test: adb pull /dev/block/platform/soc.0/f9824900.sdhci/by-name/system
Change-Id: I42d180550ac2aa9e4705676ccbb20f5db789fb8d
/system/core/adb/file_sync_client.cpp
94dc19ff57a2c5a09d74362d0c1a1231cc027d7f 15-Sep-2016 Josh Gao <jmgao@google.com> adb: let `adb push` follow symlinks.

Bug: http://b/31491920
Test: touch foo; ln -s foo bar; adb push bar /data/local/tmp
Test: python test_device.py
Change-Id: I0a00b3d49fdf7206e27d66ac110b56e22449a1ad
/system/core/adb/file_sync_client.cpp
1286c1f878ebbd8389745608ac57c75666822a4f 05-Aug-2016 Josh Gao <jmgao@google.com> adb: correctly fix merge conflict.

Change-Id: Ic637c0ef5499e2893cd0adfcc41dd5d3481524c2
/system/core/adb/file_sync_client.cpp
4ff7f9f62ae5d283fb62ee87c615a801642cba8f 05-Aug-2016 Josh Gao <jmgao@google.com> resolve merge conflicts of e012de5 to stage-aosp-master

Change-Id: I3d9f8b4421fa6122261dbd821561a2236f810a47
fb0c5cb28c13693c82f213ac99cb6b546ea44eda 04-Aug-2016 Josh Gao <jmgao@google.com> adb: improve display of transfer rate.

Show transfer rate for individual files, and for the overall transfer.

Bug: http://b/30411535
Change-Id: If2f3008f1287b1d1add4a23c3430b39885b6c904
Test: inspected output manually
/system/core/adb/file_sync_client.cpp
1a9979ec1ee913157a0e8e570ca93feacf58634e 04-Aug-2016 Josh Gao <jmgao@google.com> adb: add missing newline when printing transfer rate.

Previously, we weren't printing a newline when reporting transfer
rates, so only the last transfer rate printed would be visible.

Bug: http://b/30667841
Change-Id: Id341147912d057673de4ad26a8f618f04a8c02f3
Test: inspected output manually
/system/core/adb/file_sync_client.cpp
baa215ea59842f0f94880b1a59830a557954588a 04-Aug-2016 Josh Gao <jmgao@google.com> adb: fix output of `sync -l`

sync with list-only was using SyncConnection::Error to print its output
persistently, which would prepend "adb: error: " to messages.

Change-Id: I90df5fc1123b8c613c811cf66c37aef05663b1e4
/system/core/adb/file_sync_client.cpp
4c4fa90462afc8b187a65238f26d9b66db66e428 01-Aug-2016 Chih-Hung Hsieh <chh@google.com> Merge \"Fix clang-tidy performance warnings in syste/core.\"
am: 4efbce14b5

Change-Id: I84f6b0134fae6e9f40710f243f4825e3f31fa15f
8f7b9e3d39cdae8363816aa7bcbab0d79fd70cea 28-Jul-2016 Chih-Hung Hsieh <chh@google.com> Fix clang-tidy performance warnings in syste/core.

* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
/system/core/adb/file_sync_client.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/file_sync_client.cpp
379612b1283c7289fbf21e1105b8bec9b0fed7ae 03-Mar-2016 Josh Gao <jmgao@google.com> adb: mkdir the correct directory name when pulling.

The directory name should be based off of the local path, not the remote
path.

Change-Id: I75b089b8734e9dbf8e466b1e00ea18549fd101bb
(cherry picked from commit 89ec3a8d0feac727257b428a91b6f84b6a4b1395)
/system/core/adb/file_sync_client.cpp
48bc0d7853c34a174fa6c9ddd85c30a1b54b137d 03-Mar-2016 Josh Gao <jmgao@google.com> adb: cleanup file skipping logic.

Bug: http://b/26355212
Change-Id: Iafa250ce6c5ea8da9f5f00125165e5b67ef1013f
(cherry picked from commit a31ea55c555aaa9cddab06c038f6e3285770f664)
/system/core/adb/file_sync_client.cpp
f22bc60fc9b16148cd82e2c23b22ca3f62b00d96 01-Mar-2016 Josh Gao <jmgao@google.com> adb: report progress for small files.

Bug: http://b/27407725
Change-Id: I7515144402a487fb3d4d403e2f5f82423c1b5ed6
(cherry picked from commit 9fd2f77dcce09aa38bf8f1798ebaac2abeef1598)
/system/core/adb/file_sync_client.cpp
a63b17f76c54d937c779848ae3f4212539f8873f 26-Feb-2016 Josh Gao <jmgao@google.com> adb: fix directory creation logic.

Previously, for `adb pull $remote $local`, we would do the equivalent of
mkdir -p on `dirname $local`. This patch changes the behavior to only
creating directories that are being pulled, like scp.

Bug: http://b/27362811
Change-Id: I79f975ee9f2d9bc9e8be6a7c4f2de6d7ae2d2d23
(cherry picked from commit 71728ca300d1bc168fae89c8139e72db3d4591cb)
/system/core/adb/file_sync_client.cpp
89ec3a8d0feac727257b428a91b6f84b6a4b1395 03-Mar-2016 Josh Gao <jmgao@google.com> adb: mkdir the correct directory name when pulling.

The directory name should be based off of the local path, not the remote
path.

Change-Id: I75b089b8734e9dbf8e466b1e00ea18549fd101bb
/system/core/adb/file_sync_client.cpp
a31ea55c555aaa9cddab06c038f6e3285770f664 03-Mar-2016 Josh Gao <jmgao@google.com> adb: cleanup file skipping logic.

Bug: http://b/26355212
Change-Id: Iafa250ce6c5ea8da9f5f00125165e5b67ef1013f
/system/core/adb/file_sync_client.cpp
9fd2f77dcce09aa38bf8f1798ebaac2abeef1598 01-Mar-2016 Josh Gao <jmgao@google.com> adb: report progress for small files.

Bug: http://b/27407725
Change-Id: I7515144402a487fb3d4d403e2f5f82423c1b5ed6
/system/core/adb/file_sync_client.cpp
71728ca300d1bc168fae89c8139e72db3d4591cb 26-Feb-2016 Josh Gao <jmgao@google.com> adb: fix directory creation logic.

Previously, for `adb pull $remote $local`, we would do the equivalent of
mkdir -p on `dirname $local`. This patch changes the behavior to only
creating directories that are being pulled, like scp.

Bug: http://b/27362811
Change-Id: I79f975ee9f2d9bc9e8be6a7c4f2de6d7ae2d2d23
/system/core/adb/file_sync_client.cpp
da8119596fc6b9bb3d2208cc675036efac24fb6b 20-Feb-2016 Josh Gao <jmgao@google.com> adb: check for an error response from adbd between each write.

When sending a file, do a 0-timeout poll to check to see if an error has
occurred, so that we can immediately report failure.

Bug: http://b/26816782
Change-Id: I4a8aa8408a36940bfda7b0ecfa5d13755f4aa14d
(cherry picked from commit afcdcd703e3023dfc60638cf6b67b530ec18cb18)
/system/core/adb/file_sync_client.cpp
afcdcd703e3023dfc60638cf6b67b530ec18cb18 20-Feb-2016 Josh Gao <jmgao@google.com> adb: check for an error response from adbd between each write.

When sending a file, do a 0-timeout poll to check to see if an error has
occurred, so that we can immediately report failure.

Bug: http://b/26816782
Change-Id: I4a8aa8408a36940bfda7b0ecfa5d13755f4aa14d
/system/core/adb/file_sync_client.cpp
323899b6d3d63a9cf3fbb7f47946a9c411e5f8d2 03-Feb-2016 Josh Gao <jmgao@google.com> adb: don't append a slash to a path that already ends with one.

Bug: http://b/26964908
Change-Id: I1fbd752fd97f5414a306b46f7bfce3373362f8b3
/system/core/adb/file_sync_client.cpp
a00e6ef1fff0c45a8d07a42dead9caf49b945f53 18-Dec-2015 Elliott Hughes <enh@google.com> Give adb a proper progress bar.

This factors out the duplication in the single-file progress, and adds a
whole-sync progress percentage to the front of the line. A number that's
both more interesting and easier to read.

This also fixes the >100 percentage reporting for files of unknown size.

Bug: http://b/26189482
Change-Id: I51501ccef6ae1f52425db0eb0862d87e90947a6c
/system/core/adb/file_sync_client.cpp
c8e793685c816531cd2f2af7229b3f6b41d14a7c 11-Dec-2015 Josh Gao <jmgao@google.com> Merge "adb: make pulling symlinks and devices work."
f264224191793d754aff8937849cf956d689bdfa 09-Dec-2015 Josh Gao <jmgao@google.com> adb: make pulling symlinks and devices work.

Bug: http://b/25972989
Bug: http://b/26085751
Change-Id: I43842871522ea5f67a8c258dcb6ddafa8dd744c8
/system/core/adb/file_sync_client.cpp
77f539ab4918514706f986f77529c17a38650be0 09-Dec-2015 Elliott Hughes <enh@google.com> Simplify adb LinePrinter newline handling.

We had mostly-working hacks before, but it's time to just modify LinePrinter
to suit our needs. If we tell LinePrinter what kind of output we're giving
it, it can manage things automatically.

This fixes the minor bug where we'd sometimes have a blank line after an
error message.

Change-Id: I07ff52437f2402de311e237dd1b2dd338d9b668a
/system/core/adb/file_sync_client.cpp
4f71319df011d796a60a43fc1bc68e16fbf7d321 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename of base/ to android-base/.

Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
/system/core/adb/file_sync_client.cpp
1702f427b53b88d9517bb994844a9a15e02f2bba 02-Dec-2015 Josh Gao <jmgao@google.com> Merge "adb: don't divide by zero"
d0d87f78e55362e3792ddec5faeab247f3493858 02-Dec-2015 Elliott Hughes <enh@google.com> Merge "Fix "adb sync" (and "adb push") error reporting."
b0e039f4ca1dd59a13078bb9bb4c24daac93cd84 30-Nov-2015 Josh Gao <jmgao@google.com> adb: don't divide by zero

If we stat a file and get a size of 0, and then successfully read bytes
from that file, we would previously divide by zero when calculating the
percentage completion of the file. This case happens either when we're
racing against something else writing to the file, or when we're pulling
magical files such as the ones in /dev/cpuctl/ that lie about their
size.

Bug: http://b/25925733
Change-Id: I980b9c14f44a1eb4a42bc8736c94fa6db06c08d1
/system/core/adb/file_sync_client.cpp
7b284b2f22a3c1076bbb483d6ab49afe191adc3d 30-Nov-2015 Josh Gao <jmgao@google.com> adb: don't pull symlinks when pulling a directory

The previous change to do this (f96dc73b) only skipped individually
named symlinks, not symlinks inside of a directory that was being
pulled.

Bug: http://b/25601283
Change-Id: I25bdcbc546a9d3a0dbd8dacdb065fb134d96022b
/system/core/adb/file_sync_client.cpp
d3266e058e9b4c609491e4115887407446d8ace1 30-Nov-2015 Josh Gao <jmgao@google.com> adb: remove extraneous newline from skip message

Change-Id: I12314da589bf0db14b37ae4c1f526665182f4776
/system/core/adb/file_sync_client.cpp
dd6cc4d7eee1669a44cbe1f72ce3325aba2bf0f9 30-Nov-2015 Josh Gao <jmgao@google.com> adb: correctly count skipped files in push/pull

Bug: http://b/25650207
Change-Id: I055b08216938640c4f7c5e96a7ea3719bf90ba70
/system/core/adb/file_sync_client.cpp
cc65c3b9f8edc6fb48ffe725376e65fac42851d6 21-Nov-2015 Elliott Hughes <enh@google.com> Fix "adb sync" (and "adb push") error reporting.

This patch ensures that we read any error response from the server if the
server closes the connection. Unfortunately, that's not sufficient to ensure
that we always see the server's error message --- sometimes the data just
gets thrown away because we keep writing without reading. Setting SO_LINGER
avoids this.

Bug: http://b/25230872
Change-Id: I96c019cc72bd139198de79bf29e6536cc462c20f
/system/core/adb/file_sync_client.cpp
6aab58c49914a9e50d1862d29e240e98b441f9c3 21-Nov-2015 Elliott Hughes <enh@google.com> Move SendLargeFile into SyncConnection.

Just a trivial refactor. Code change comes later.

Change-Id: If9e509a8c44649e5be4daaca57972939b037b8db
/system/core/adb/file_sync_client.cpp
f6e65e3f80e59866bfe74f4d82a9850216a65234 17-Nov-2015 Josh Gao <jmgao@google.com> adb: don't use adb_dirname in between getting and printing errno.

adb_dirname might trample over the errno value we want to print. Move
the adb_dirname call out to a local to prevent this.

Change-Id: I8a62cb2e1be8704225a9c3b72dd01259c7eaaae4
/system/core/adb/file_sync_client.cpp
f96dc73b9f218f464640a9cdd80c389723665d5c 12-Nov-2015 Josh Gao <jmgao@google.com> adb: don't pull symlinks.

Pulling symlinks was broken for directories, and it doesn't seem like
there's a good way to make it not broken, given that the protocol doesn't
have readlink (and we don't want to create symlinks on Windows, anyway).
The behavior for files doesn't seem to be especially useful, either.

Bug: http://b/25601283
Change-Id: Ie1d27e93dd09cbc0c178623b390041d1cb11f726
/system/core/adb/file_sync_client.cpp
1a0253092d07cc6497c4dc207ec0cbf03c0020e5 09-Nov-2015 Josh Gao <jmgao@google.com> adb: properly handle path separators on Windows.

Bug: http://b/25573669
Change-Id: Ic82981e1dfe40d5e3b3ffa06e18e62ecf80d81fc
/system/core/adb/file_sync_client.cpp
07db1196e7bd5856b5e2ebe4ea6791d2ae8c9e76 08-Nov-2015 Josh Gao <jmgao@google.com> adb: don't explode directories when pushing/pulling.

Previously, `adb pull /data/local/tmp` would spew all of the contents of
/data/local/tmp into the current directory. This patch makes push/pull
keep directories intact.

Bug: http://b/25394682
Change-Id: I2304ae9e61745a2b9536f58a6012640bf8ff422a
/system/core/adb/file_sync_client.cpp
12a2ae9a0c21edaf8e80984519108631bdf3c9e6 08-Nov-2015 Josh Gao <jmgao@google.com> adb: improve error handling, comments.

This commit fixes two cases:
`adb pull /data/local/tmp nonexistent/path` would succeed.
`adb pull /data/local/tmp nonexistent/` would fail.

Change-Id: I60c39eb2816946686241af42cfa2ad5cdc63fb0e
/system/core/adb/file_sync_client.cpp
0bb1ce06ea46f14d5b6bc57db8c8d6c463b5b1de 10-Nov-2015 Josh Gao <jmgao@google.com> Merge "adb: don't try to pull character or block devices."
8d00a39eff5f4047a4a4ad007900df2bdd1c1e9a 10-Nov-2015 Josh Gao <jmgao@google.com> adb: don't try to pull character or block devices.

Change-Id: I1a9e2c0097fe9c4017a9b338e812366c8e1154f0
/system/core/adb/file_sync_client.cpp
21abf5a7c1099b06625f516997c4291f577c3444 08-Nov-2015 Josh Gao <jmgao@google.com> adb: demote skipping a file from an error to a warning.

Change-Id: If6c88e8855369bd7feb570ac5310fc7f44994083
/system/core/adb/file_sync_client.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/file_sync_client.cpp
7fc45c3326ba4ecaa49ec0713dce61b053c9b9e4 07-Nov-2015 Josh Gao <jmgao@google.com> Merge "adb: pull empty directories."
a837df85908bdf5b00fa6d328dd622b59b91ef8b 07-Nov-2015 Josh Gao <jmgao@google.com> adb: remove superfluous checks.

Change-Id: I4d9ceb301b0d242b0bad9a0faa8e2a1824f36cca
/system/core/adb/file_sync_client.cpp
6580096c97a2cb0750f4f7cb60bc05e7e84f4d7d 04-Nov-2015 Josh Gao <jmgao@google.com> adb: pull empty directories.

Pushing empty directories is more troublesome, and probably either
requires changes to the server, or hacky `adb shell mkdir` stuff.

Bug: http://b/25395071
Change-Id: I4db6a993429a56e5c5ca994752418503b6f5d7c4
/system/core/adb/file_sync_client.cpp
cd7c1ed700707e3f3aea341c38d38e18ae410987 04-Nov-2015 Josh Gao <jmgao@google.com> adb: make local_build_list match remote_build_list.

local_build_list previously was returning an int, 0 on success and -1 on
failure, while remote_build_list was returning a bool, true on success
and false on failure.

Change-Id: Iced6c4142e2f843048d81c4e133d6b6dc75a35dd
/system/core/adb/file_sync_client.cpp
d97315731ff13274916be0f731ede15e81187c79 04-Nov-2015 Josh Gao <jmgao@google.com> adb: C++ify more of the push/pull functions.

Change-Id: Ie82d51ecadf5c94f3b138f5b13a17c3b46c61899
/system/core/adb/file_sync_client.cpp
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/file_sync_client.cpp
fc7c3b682b4c9cf77e45ec2db8610d7d963705c6 03-Nov-2015 Josh Gao <jmgao@google.com> adb: rename 'flag' to something less meaningless.

Change-Id: I7f7644a0a6f9a7d48508ddaad2e6a51266ae8ee6
/system/core/adb/file_sync_client.cpp
19d9454ee3c2c3c11272ec34cee0e263a621fd98 03-Nov-2015 Josh Gao <jmgao@google.com> Merge "adb: C++ify local_build_list and remote_build_list."
fe54c96ab28a59a87c0c26ac4e6664826b4644ea 03-Nov-2015 Josh Gao <jmgao@google.com> Merge "adb: allow multiple args to push/pull."
cda6a2bd3e9c8c9644e833162d513009681e8e25 03-Nov-2015 Josh Gao <jmgao@google.com> adb: C++ify local_build_list and remote_build_list.

Change-Id: I71586488869c4827c5bd7294faa7c0f433bb9fbc
/system/core/adb/file_sync_client.cpp
983c41c35375227fe11de41b83e1861f07647313 03-Nov-2015 Josh Gao <jmgao@google.com> adb: add SyncConnection::Printf.

Replaces `sc.Print(android::base::StringPrintf(...)` with one call
to sc.Printf.

Change-Id: Ib7c98103dbca0b6a951f8e5a0f860ec6eacf6772
/system/core/adb/file_sync_client.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/file_sync_client.cpp
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/file_sync_client.cpp
b708d1628332ea9266d08f0297cd9e9ee341a64f 28-Oct-2015 Elliott Hughes <enh@google.com> Show transfer progress in adb sync/pull/push.

Change-Id: If5439877d060f9bab29cf84be996071cf680c2d4
/system/core/adb/file_sync_client.cpp
6d92997ec4285caebe94064158a8cc017bbf5caa 27-Oct-2015 Elliott Hughes <enh@google.com> Don't use VLAs in adb.

This makes no measurable difference to the sync time; "adb sync" of
everything on /system for a Nexus 9 still takes 20s.

Change-Id: Ifa2626f7453937e43856b9c4ee06e1f5db0aa273
/system/core/adb/file_sync_client.cpp
8b43c3e65a05aff709a7e62a85198cdd7abfa88f 24-Oct-2015 Elliott Hughes <enh@google.com> Fix adb sync/pull/push error reporting.

I fixed the server side to send detailed error reports, but the client-side
code for pull was broken because it had already read the "FAIL" header before
calling the general error reporting code that expects to be able to read
the header. This meant we'd always report that we failed to read the failure
message.

Also add a couple of missing "\n"s, make sure every error message is prefixed
by "adb: ", and remove a useless path length check that would silently ignore
over-long paths rather than relying on SendRequest to detect and report the
problem.

Bug: http://b/6205106
Change-Id: I23862ececf03b761115ffa3f7725b7e1cecb48c7
/system/core/adb/file_sync_client.cpp
ae5a6c06cdd9ae1a0a7cdc42711f0a5594e54dcd 27-Sep-2015 Elliott Hughes <enh@google.com> Speed up adb sync.

Sending the SEND/DATA/DONE packets all in one write makes small file and
symbolic link transfer orders of magnitude faster. Transferring all the
symbolic links in /system/bin or all the cacerts in /system/etc goes down
from about 6s in each case to less than 0.5s.

Change-Id: Ia1706cef25535d0b685d3744241a0557a52b22ff
/system/core/adb/file_sync_client.cpp
081696d27c3b3c6bc0e2b97449c1da791fa00d25 03-Sep-2015 Elliott Hughes <enh@google.com> Improve adb sync_send error reporting.

Bug: http://b/23786900
Change-Id: I71f10de8d767eaf8bf0f5d9b8c304527e2b953ff
/system/core/adb/file_sync_client.cpp
d8cce1817b02c23124e85b138d85acd8fc24a757 28-Aug-2015 Spencer Low <CompareAndSwap@gmail.com> adb: fix adb install and adb push exit code, error handling, unittest

adb push was not returning a bad exit code when write_data_file() or
write_data_link() failed. I encountered this when running the unittest
on Windows which can get into situations where stat() succeeds, but
open() fails due to pre-existing exclusive file access (which typically
doesn't exist on unix).

The same code is used by adb install, so this also fixes its error
handling.

Fixed some fd leaks and propagation of errors when reading a file.

Fixed a unittest to close temp files before reading them.

Change-Id: Ieba0026fa4c79eb0484676e4f2faaac9603ef584
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/file_sync_client.cpp
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/file_sync_client.cpp
42640e5224a861690de006952470451d18337256 24-Aug-2015 Elliott Hughes <enh@google.com> Merge "Add missing #include <memory> for std::unique_ptr on Windows."
a925dba0e087042f7a7ecbcde46576acef15aa7d 24-Aug-2015 Elliott Hughes <enh@google.com> Add missing #include <memory> for std::unique_ptr on Windows.

Change-Id: Ic02f53003a20a646cbbf2aa08e0e10be9bd8b97f
/system/core/adb/file_sync_client.cpp
f4465203b618fa57b6669c4d5627f32fb025b73e 24-Aug-2015 Elliott Hughes <enh@google.com> There are no big endian hosts, grandpa.

Change-Id: I6f64f702f919fe4af10d82c5f395a051571815ed
/system/core/adb/file_sync_client.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/file_sync_client.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/file_sync_client.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/file_sync_client.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/file_sync_client.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/file_sync_client.cpp
3edd54b3a873a18d9c2f66ce955036471f4c3c0a 06-May-2015 Elliott Hughes <enh@google.com> Add some missing 'static's.

Change-Id: Id76bb1e954e8fa36a11a38b5445c87f4a64af799
/system/core/adb/file_sync_client.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/file_sync_client.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/file_sync_client.cpp
2d4121c0dcc93382bcd7ea6476f433d8254919dd 17-Apr-2015 Elliott Hughes <enh@google.com> Remove extern "C" barriers to using C++.

Change-Id: Ic046d6aa540738cb46b54531bc59ba3b47b0136d
/system/core/adb/file_sync_client.cpp
46270d233a76b63497b5bcf456e00f6defd429bd 13-Mar-2015 Elliott Hughes <enh@google.com> adb doesn't actually use libzipfile.

Change-Id: Ia7d22214bc8422c88edaaf9bb716d7e12e0bb381
/system/core/adb/file_sync_client.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/file_sync_client.cpp