Commit graph

79 commits

Author SHA1 Message Date
David Pursell
f3f5bce204 am 6a701bd9: am b53b521e: Merge "Add adb features."
* commit '6a701bd94b067c2ab873964f63c3d954bc59610f':
  Add `adb features`.
2015-08-14 16:13:13 +00:00
Dan Albert
90d4b739ab Add adb features.
Shows the features supported by the active adb server.

Change-Id: I4a58a2ca082823c43f7a49e2c62ff80df6426756
2015-08-14 08:25:23 -07:00
Elliott Hughes
56d11898aa am 80e83972: am 9537ca80: Merge "adb: start-server and kill-server error output"
* commit '80e83972d0bce74d218f72b76339e6761ad6b03b':
  adb: start-server and kill-server error output
2015-08-13 16:46:46 +00:00
Spencer Low
f18fc0879b 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>
2015-08-12 20:14:55 -07:00
Elliott Hughes
efc8077246 am c01231b3: am 2fb00423: Merge "Always include the adb version in the log."
* commit 'c01231b399c38f00afe0872b3a51837518b713dc':
  Always include the adb version in the log.
2015-08-12 17:45:41 +00:00
Elliott Hughes
42ae2604f4 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
2015-08-12 08:32:10 -07:00
Elliott Hughes
6396f64fd7 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
2015-08-11 01:50:26 +00:00
Spencer Low
5c398d2ce9 adb: win32: write ACK to separate pipe instead of stdout
The win32 version of 9f2d1a9cfc. The big
technique is to fit a Win32 HANDLE value in an int because it only uses
32-bits. This allows most of the other adb code to stay the same.

Also, fix a regression in the 'adb server nodaemon' command that was
erroneously returning an error when --reply-fd was not used, which
should not be necessary for this particular command.

Change-Id: I37e9c609014b813af93bf0d6c12f665b59c93c41
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-08 15:07:07 -07:00
Elliott Hughes
184585c417 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
2015-08-07 21:17:00 +00:00
Siva Velusamy
9f2d1a9cfc 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
2015-08-07 11:31:07 -07:00
Elliott Hughes
5e6d1dcfac am 3d561748: am ec035950: Merge "Clean up -p handling slightly."
* commit '3d5617487c07f1fcbdf23755e0ca01559e3c5f3b':
  Clean up -p handling slightly.
2015-07-31 22:32:00 +00:00
Elliott Hughes
048b27c066 Clean up -p handling slightly.
Change-Id: I8a5cd4a7adb0dde9d09e0cbb620874b1bca35e43
2015-07-31 13:18:22 -07:00
Elliott Hughes
e0b43a1785 resolved conflicts for merge of 4e90b0ae to mnc-dev-plus-aosp
Change-Id: Iff0f469f09a0ad442db5b593345eaf52c3ca8104
2015-07-30 20:07:12 -07:00
Elliott Hughes
5c74270f95 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
2015-07-30 17:46:58 -07:00
Elliott Hughes
d2117974e4 resolved conflicts for merge of 486645ee to mnc-dev-plus-aosp
Change-Id: I027a4de6e4ebae3bee6b7d2e56bd39c284b8a062
2015-07-30 16:33:50 -07:00
Alex Vallée
47d67c96ec 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
2015-07-30 15:08:53 -07:00
Elliott Hughes
24419f3c2e am ce2047a9: am 1a706865: Merge "Fix const-ness of strrchr callers."
* commit 'ce2047a947eaf3c02e39c22a7b461e8a0acd87f2':
  Fix const-ness of strrchr callers.
2015-07-28 21:54:23 +00:00
Elliott Hughes
3e7048c027 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
2015-07-28 08:07:21 -07:00
Elliott Hughes
d704ede392 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
2015-07-23 18:47:50 +00:00
Elliott Hughes
fee0648121 am d66e949b: am 2e7c39ec: Merge ""adb tcpip" should require a numeric argument."
* commit 'd66e949b14305b367d3de4ba00901bff1122bb0e':
  "adb tcpip" should require a numeric argument.
2015-07-23 02:06:36 +00:00
Elliott Hughes
6b40d0aaa1 Merge "adb: win32: fix exec-in and exec-out to use binary mode" 2015-07-22 22:43:45 +00:00
Elliott Hughes
19d80b878c "adb tcpip" should require a numeric argument.
Defaulting to port 0 just breaks stuff.

Bug: http://b/22636927
Change-Id: I6239900e0828e71b31171d0184c24824957c99c8
2015-07-21 16:27:46 -07:00
Elliott Hughes
e45a665040 am c06c3001: am a1c344b9: Merge "Move mkdirs to adb_utils."
* commit 'c06c3001156cbbdf8d6b3e187e0f92c51c5a80b3':
  Move mkdirs to adb_utils.
2015-07-16 21:39:46 +00:00
Alex Vallée
1421614821 Move mkdirs to adb_utils.
There were duplicate implementations in commandline.cpp and
file_sync_client.cpp.

Change-Id: Ib448f76c0d7ffdcd577336b1c610a881425bc2db
2015-07-15 19:37:18 +00:00
Dan Albert
fcbc32de34 am 00599eca: am e84205bf: Merge "Revert "Turn on -Wformat-nonliteral.""
* commit '00599eca7446f28762da3854566cff0b2ba46799':
  Revert "Turn on -Wformat-nonliteral."
2015-07-09 21:05:16 +00:00
Dan Albert
286bb6ddbd 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 459df8f3a1.

Change-Id: I7905c5ae5ee85fb2d228ce63d81c79f140998c18
2015-07-09 20:35:09 +00:00
Dan Albert
f9b81ccd75 am fcdc3141: am a35affb5: Merge "Turn on -Wformat-nonliteral."
* commit 'fcdc3141d3209afb8a8a62764fa66911a7104e74':
  Turn on -Wformat-nonliteral.
2015-07-09 20:21:31 +00:00
Dan Albert
459df8f3a1 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
2015-07-09 10:47:24 -07:00
Elliott Hughes
5ca8b9b0e6 am dc5993b3: am 4931ae54: Merge "Minor "adb help" fixes."
* commit 'dc5993b3bac7797fb4163e3ea78cdc80f2f0d024':
  Minor "adb help" fixes.
2015-06-13 02:25:37 +00:00
Elliott Hughes
7e067cff7a 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
2015-06-12 14:33:17 -07:00
Spencer Low
b7dfb79b53 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>
2015-06-08 17:41:53 -07:00
Svetoslav
cb0322f536 am 23d84074: Improve adb install help.
* commit '23d84074652b77385431fc0d1505b7d43b7dba9e':
  Improve adb install help.
2015-06-02 14:22:54 +00:00
Svetoslav
23d8407465 Improve adb install help.
Bug: 21365060
Change-Id: I0a4ea5cf3a2f37a82161b30f7eec5781d175aa8f
2015-06-01 23:59:20 +00:00
Elliott Hughes
06e914eb8e 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".
2015-05-30 01:56:48 +00:00
Elliott Hughes
424af02f36 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
2015-05-29 18:03:57 -07:00
Lorenzo Colitti
4209796136 am 0983a6d5: Merge "Document the -g option to adb install." into mnc-dev
* commit '0983a6d54c202fde75523f1340bd9c9a168ab98c':
  Document the -g option to adb install.
2015-05-28 04:06:58 +00:00
Lorenzo Colitti
0b3baac512 Document the -g option to adb install.
Change-Id: I012165df343c24953f1c1cfcdce379bf1b67c624
2015-05-28 12:03:44 +09:00
Spencer Low
6001c87cbc 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>
2015-05-13 19:30:30 -07:00
Elliott Hughes
207ddb20ac 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 5677c23e8d)
2015-05-08 10:49:31 -07:00
Elliott Hughes
ee5ce0d14f Merge "Fix "adb remount" for devices without an oem partition." 2015-05-08 17:49:11 +00:00
Elliott Hughes
02418b3e09 Try to include the SHA in a ddmslib-compatible way.
Bug: http://b/20918202
Change-Id: I0c1a48459372b0d28aaf9d09d82540e44b438c9c
(cherry picked from commit f3bbfa6a21)
2015-05-08 09:03:12 -07:00
Elliott Hughes
5677c23e8d 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
2015-05-08 08:43:10 -07:00
Elliott Hughes
f3bbfa6a21 Try to include the SHA in a ddmslib-compatible way.
Bug: http://b/20918202
Change-Id: I0c1a48459372b0d28aaf9d09d82540e44b438c9c
2015-05-07 21:56:31 -07:00
Spencer Low
142ec75cf8 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>
2015-05-06 18:54:08 -07:00
Dan Albert
c1cfbd304a 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 1ba1d7c1ee)
2015-05-06 09:11:16 -07:00
Dan Albert
1ba1d7c1ee Include the git sha in the adb version.
Also add --version to adbd to display the same thing.

Change-Id: I47dfbad16c892c42ea938aedd085ba77492791ba
2015-05-05 18:04:37 -07:00
Elliott Hughes
9b0f354fa2 Simplify adb_thread_create.
Change-Id: I36d6021ef8fbc23e8bcd4ddbe1dac0eba467cc70
2015-05-05 13:41:21 -07:00
Elliott Hughes
3bd73c12c0 Give enum types CamelCase names for clarity.
Change-Id: I1c89f1cc155ee839f372fb14d972a288183b8bcd
2015-05-05 13:10:43 -07:00
Elliott Hughes
32687beaf2 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
2015-05-05 12:50:26 -07:00
Elliott Hughes
aceb9c08df 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 2b10111d25)
2015-05-05 12:45:42 -07:00