Commit graph

1985 commits

Author SHA1 Message Date
Treehugger Robot
7e4d1db957 Merge "adb: kill adb_mutex_t, adb_cond_t." 2016-09-22 02:15:00 +00:00
Josh Gao
0cd3ae1c28 adb: kill adb_mutex_t, adb_cond_t.
Now that we have support for std::mutex and std::condition_variable on
Windows, remove our mutex compatibility layer in favor of the C++ one.

Bug: http://b/31653591
Test: mma && $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test && \
      python test_adb.py && python test_device.py
      (also on Windows)

Change-Id: I5b7ed9c45cc2a32edcf4e77b56dc28e441f15f34
2016-09-21 17:22:22 -07:00
Josh Gao
efee71c2de Merge "adb: parse tcp socket specs with base::ParseNetAddress." 2016-09-21 20:26:36 +00:00
Josh Gao
14d3a1ac9d Merge "base: rename unique_fd::clear() to unique_fd::reset()." 2016-09-21 01:03:06 +00:00
Josh Gao
1099215e30 adb: parse tcp socket specs with base::ParseNetAddress.
libbase already has IPv6-aware address parsing, so use it instead of
adb's handrolled IPv4-only parsing.

Bug: http://b/31537253
Change-Id: I4e9ce56b55d7d02787c0fa67b724490bf49ce479
Test: mma && adb start-server && \
      adb -L 'tcp:[::ffff:127.0.0.1]:5037' devices && \
      adb -L 'tcp:localhost:5037' devices && \
      adb -L 'tcp:127.0.0.1:5037' devices && \
      adb -L 'tcp:5037' devices && \
      $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
2016-09-20 13:55:43 -07:00
Treehugger Robot
4159568548 Merge "Fix bug: Doesn't respect ANDROID_ADB_SERVER_PORT" 2016-09-19 20:35:11 +00:00
Josh Gao
5d1b1a8b91 base: rename unique_fd::clear() to unique_fd::reset().
unique_fd is modeled on unique_ptr, so make this consistent.

Test: m checkbuild
Change-Id: Ia6a77095dc18746fbb432e96bb8dccfc049c57f6
2016-09-19 11:24:58 -07:00
Tao Wu
135f4ab3dd Fix bug: Doesn't respect ANDROID_ADB_SERVER_PORT
BUG: 31549442
Test: export ANDROID_ADB_SERVER_PORT=12345;killall adb;adb devices

Change-Id: If2bfaf44c6567af16cae0d4def2f11be39c2d437
Signed-off-by: Tao Wu <lepton@google.com>
2016-09-16 17:13:48 -07:00
Pirama Arumuga Nainar
a3d7b240f1 Merge "Use <condition_variable> and <mutex.h> from MinGW" 2016-09-16 21:59:35 +00:00
Josh Gao
94dc19ff57 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
2016-09-14 17:08:22 -07:00
Pirama Arumuga Nainar
7eaef8a494 Use <condition_variable> and <mutex.h> from MinGW
New MinGW prebuilts update includes pthreads and C++11 threads support.
Use mutex.h and condition_variable provided by MinGW.

Test: Build AOSP with new MinGW prebuilts
Change-Id: Ia8f890f86652612df3fc2618c2bfbb450a5a2f52
2016-09-06 13:49:07 -07:00
Treehugger Robot
85a78f19b1 Merge "Precise command constants on adb/protoxol.txt" 2016-09-06 05:04:13 +00:00
Elliott Hughes
7f4ab76240 Fix adb.
9460de1ce80a41cd6171a7e03d9fa7aef2db9dce had a backwards test that means
all adb commands abort. Fix the sense of the test.

Bug: http://b/30445394
Change-Id: I4b8ee697f7d305b57f9cd1a70ae919869dee994d
2016-09-01 20:48:45 -07:00
Treehugger Robot
1f5a49f77a Merge changes from topic 'adb_cmd_socket'
* changes:
  adb: allow use of arbitrary socket specs for command socket.
  adb: extract the adb-specific unique_fd out into its own header.
  adb: add helper to get the ~/.android directory.
2016-09-02 01:03:12 +00:00
Josh Gao
78cc20f007 libcutils: try all addresses in socket_network_client_timeout.
If a connection fails to an address that resolves to multiple
sockaddrs, attempt connecting to subsequent addresses if the initial
connection fails to a reason other than timeout. This is primarily
useful for localhost, which can resolve to both an IPv4 and and IPv6
address.

Also, add an adb test to verify that this behavior.

Bug: http://b/30313466
Change-Id: Ib2df706a66cf6ef8c1097fdfd7aedb69b8df2d6e
Test: python test_adb.py (+ the test fails before this patch)
2016-09-01 15:56:58 -07:00
Josh Gao
9c869b58a8 adb: allow use of arbitrary socket specs for command socket.
Bug: http://b/30445394
Change-Id: I474ede35ec3c56ad86da503c9703f83ef5e80862
2016-09-01 15:49:06 -07:00
Josh Gao
924d35a8d5 adb: extract the adb-specific unique_fd out into its own header.
Some POSIX-only files would like to use functions declared in
adb_utils.h without being forced to use the sysdeps stuff for open,
close, etc. Extract the adb-specific unique_fd into its own header so
those files can use adb_utils.h alongside the real unique_fd.

Change-Id: I10344ef26b7e72fce46bf7e3033f89aa54bd6118
Test: mm
2016-09-01 15:49:06 -07:00
Josh Gao
e0b7502c7f adb: add helper to get the ~/.android directory.
Extract the logic for creating ~/.android out of get_user_key_path into
its own function. Also, fall back to getpwuid_r when $HOME isn't
defined.

Change-Id: I676a7c750cb364f89b544818ffda07903d14fb97
Test: ran adb with ~/.android missing
2016-09-01 15:43:22 -07:00
Elliott Hughes
82ff315bb0 Add android::base::GetExecutablePath, switch adb and fastboot over.
We'd long had two copies of this stuff, so rather than rewrite both
Linux versions to use android::base::Readlink, let's kill the duplication
too...

Bug: http://b/30988271
Change-Id: I4de58a94a22a4b1faf969a6fc70ca1560a4d5121
2016-09-01 09:24:24 -07:00
Felipe Leme
680f4a4888 DO NOT MERGE: Split 'generating' and 'pulling' in 2 messages.
BUG: 30799929
Change-Id: I0af0ad2478c57ffc5b2c953118e01677f788d14a
(cherry picked from commit 9c0be90528)
(cherry picked from commit 321c21e2df)
2016-08-30 13:06:37 -07:00
Felipe Leme
f33fcb6418 DO NOT MERGE: Ignore bugreportz output when it's not supported.
On devices running M or below, calling 'bugreportz -v' writes
'/system/bin/sh: bugreportz: not found' in the stdout output, which must
be redirected to stderr so it's not shown in the flat-file bugreport,
above the bugreport header.

BUG: 30451114

Change-Id: I942c92fdf6ae85e0cde7b9f94b9eb0b1fecad77a
(cherry picked from commit 9a882a3ef3)
(cherry picked from commit b0022b036e)
2016-08-30 13:06:35 -07:00
Felipe Leme
b3239728bb DO NOT MERGE: Deprecated 'adb bugreport' with flat files.
Starting on Android N, zipped bugreports contain more information than
flat-file, text bugreports. On N, calls to 'adb bugreport' would still
generate a flat-file bugreport, but with a warning.

With this change, 'adb bugreport' will generate a zipped bugreport in
the current directory, using the bugreport name provided by the
device. Similarly, calling 'adb bugreport dir' will generate a bugreport
with a device-provided name, but in such directory.

BUG: 30451114
BUG: 29448020

Change-Id: Ibc8920dd44a5f62feb15bf3fefdcb0bdbf389a90
(cherry picked from commit 307951e124)
(cherry picked from commit f8d9e4eb00)
2016-08-30 13:06:33 -07:00
Felipe Leme
6e2869680c DO NOT MERGE: Minor improvements on bugreport generation.
- Skipped artificial 100/100 message, since pulling will take care of
  the final 100% progress.
- Consolidated unsupported lines in just one message.
- Let user know the bugreport can still be recovered when it could not
  be copied to the destination directory.

BUG: 30451114

Change-Id: Icfce9c1e8e7ed407719728b9874679ac40b21eab
(cherry picked from commit 80a65d03c9)
(cherry picked from commit 5f6eacaeda)
2016-08-30 13:06:32 -07:00
Felipe Leme
daf4628f36 DO NOT MERGE: Removed extra 'pulling file' message.
Taking a zip bugreport has 2 phases: generating the bugreport and
pulling the file.

Initially adb was printing 2 messages, but since the latter is almost
instantaneously, it could be confusing to have 2 lines...

Fixes: 30451250
Change-Id: I1c6cc6163492c1fb6064667dfdb7aaf6ed4c4c6f
(cherry picked from commit f7c38b4c03)
(cherry picked from commit 33ae849fef)
2016-08-30 13:06:30 -07:00
Felipe Leme
6f5080faa5 DO NOT MERGE: Show bugreport progress.
adb calls bugreportz to generate a bugreport; initially, bugreportz
would only report the final status of the operation (OK or FAIL), but
now it sends intermediate PROGRESS lines reporting its progress (in the
form of current/max).

Similarly, the initial implementation of 'adb bugreport <zip_file>'
would print an initial 'please wait' message and wait for the full
stdout before parsing the result, but now it uses a new callback class
to handle the stdout as it is generated by bugreportz.

BUG: 28609499

Change-Id: I6644fc39a686279e1635f946a47f3847b547d1c1
(cherry picked from commit cd42d658b2)
(cherry picked from commit 97b73a0daf)
2016-08-30 13:06:28 -07:00
Felipe Leme
0d4f0508c0 DO NOT MERGE: Refactored functions that copy sdout and stderr to strings to use a callback.
BUG: 28609499

Change-Id: I04aea346e18678ea00797f7f659480edba4436c2
(cherry picked from commit 07ac8554b4)
(cherry picked from commit d18854218e)
2016-08-30 13:06:26 -07:00
Felipe Leme
698e065e14 DO NOT MERGE: Split bugreport() into its own file and added unit tests.
bugreport() will be soon refactored to track progress, which will
require more comprehensive unit tests.

As such, it's better to move it to its own files, which in turn also
requires moving send_shell_command() and usage() to commandline.h.

Fixes: 30100363
Bug: 30268737

Change-Id: I3cdf114a0b5547293320042ff0749a60886440b0
(cherry picked from commit 78e0963e4b)
(cherry picked from commit 218e1ff759)
2016-08-30 13:06:23 -07:00
Todd Kennedy
248722e7eb DO NOT MERGE: use 'cmd' command for install-multiple
adb install-multiple makes a minimum of 3 calls to the 'pm' command. This
causes at least 3 separate "pm" processes to be spun up. Instead, use the
'cmd' command which runs in the existing system_server process.

Bug: 27483932
Change-Id: Ia1bed405c3d7e675a1a56ff82c692aaa94388a5c
(cherry picked from commit 4838ae1ab5)
2016-08-30 13:06:12 -07:00
Christopher Tate
c42f1bb3e9 DO NOT MERGE: Ensure the target sees a proper EOD marker during restore
Malformed or corrupt archives may be missing their in-band EOD
content, so make sure that the target sees one regardless rather
than continuing to block on read, expecting in-band signaling.

Bug 28056941

Change-Id: Ic39966d3448787a8c511783d39172032ed9589c3
(cherry picked from commit 2bcdda8e5d)
2016-08-30 13:06:05 -07:00
Eyal Lezmy
39e999e991 Precise command constants on adb/protoxol.txt
Try to improve the documentation by adding, for each commands explained
on the adb/protocol.txt file (CONNECT, WRITE, AUTH, ...), the
corresponding constant used by the protocol (A_CNXN, A_WRTE,
A_AUTH, ...).

I've seen a few engineers having problems matching these both
information by simply reading the doc and they loose time before
getting it. Most of the time they understand it by finally reading the
source code.

By adding this simple information at the end of each command
description I'm sure it will help onboarding developers to
understand more quickly the way the ADB protocol works.

Change-Id: Ibb949fd6a6d34a2bc7f47f0e7af2f57138c9a369
Signed-off-by: Eyal Lezmy <eyal.lezmy@gmail.com>
2016-08-30 01:30:12 +02:00
Josh Gao
cfb21412e5 adb: factor out socket specification.
Move the logic for string socket specification out to separate
functions to facilitate using arbitrary sockets for the adb command
socket.

Bug: http://b/30445394
Change-Id: Icd8fdb853272edc029fb3a0f5b18e941dc8ef52c
Test: adb_test, adbd_test, test_device.py
2016-08-25 17:12:26 -07:00
Josh Gao
e461b37965 Merge changes I0ee130db,I33d356fd
* changes:
  adb: remove unnecessary addr arguments to accept.
  adb: check our socketpair ends in our win32 emulation.
2016-08-25 01:59:23 +00:00
Josh Gao
78e1eb1949 adb: remove unnecessary addr arguments to accept.
Follow up to https://android-review.googlesource.com/#/c/261412/

Change-Id: I0ee130db302940f3224cc823a26b02fc45da0fca
Test: mma
2016-08-24 13:06:06 -07:00
Josh Gao
5990191c4e adb: check our socketpair ends in our win32 emulation.
In our Win32 socketpair emulation, check that the ends are properly
connected before returning.

Change-Id: I33d356fd9ebcac89fc6a89a5200e926032220383
Test: no additional failing tests in adb_test.exe
2016-08-24 13:06:06 -07:00
Elliott Hughes
8615d79d85 Merge "Most accept/accept4 calls in system/core don't actually want the remote address."
am: 299d64144b

Change-Id: I3fb9678dfed08f0b1d6e90e547ecae6cdcabc9a1
2016-08-23 23:03:20 +00:00
Elliott Hughes
3dcfa3fb1c Most accept/accept4 calls in system/core don't actually want the remote address.
So don't write the extra code for it or waste the kernel's time
copying it around.

Change-Id: I93de64064c2d4fe58ba5b5322cfa69bf31a76dad
2016-08-23 12:50:00 -07:00
Josh Gao
e4d79532de Merge "adb: increase the authentication throttling limit."
am: 393e5258f6

Change-Id: I483cf75ced8d9fb896c2f5e417d258970d7cabb1
2016-08-23 01:11:28 +00:00
Josh Gao
8270912ed0 Merge changes I9761298a,I8d3312b2
am: 0b4fcb75d4

Change-Id: I330c467e408bc10ebdab0f5708d24d2297cf39a2
2016-08-22 21:38:53 +00:00
Josh Gao
c8cb38803a adb: increase the authentication throttling limit.
Previously, after 10 failed authentications, we'd sleep for a second,
and we're up to 11 vendor keys in internal now...

Bug: http://b/30927527
Change-Id: I094e830521f6a2768a880c6684f32ff1ce2a3c2e
2016-08-22 13:12:32 -07:00
Josh Gao
8a0d0773bd adb: fix public key authorization.
This was broken by commit e8b663fe, which removed the null-terminator
from the message sent. For some reason, adbd requires the key to be
null terminated, despite an explicit length being part of the message.

Bug: http://b/30971808
Change-Id: I9761298a57ed76ca2bc02b05490f98cdffbaa0c3
Test: manually tested, adb authorization dialog box shows up
2016-08-22 12:58:38 -07:00
Josh Gao
2e671202c3 adb: add support for vendor key directories.
Allow directories to be specified in ADB_VENDOR_KEYS. On Linux, monitor
this directory for new keys to be added.

Additionally, deduplicate keys by hashing their public key.

Bug: http://b/29273531
Bug: http://b/30927527
Change-Id: I8d3312b216b7f2c11900f2235f1f1b1d1c7aa767
Test: manually tested by adding a key to a directory, and verifying
      that devices became authorized after replugging.
2016-08-19 17:32:50 -07:00
Josh Gao
81a3f71e45 Merge "Clean up key handling in adb."
am: b859830450

Change-Id: I8d8ff82167a97e89eacbfcc97f3b704466927aa3
2016-08-12 21:21:57 +00:00
Elliott Hughes
0aeb50500c Clean up key handling in adb.
This includes the locking we need to be able to re-load the keys at runtime.

We should rename "adb_auth_client.cpp" to "adb_auth_adbd.cpp" or
"adbd_auth.cpp" in a later change.

Change-Id: I9e1d5b6b7d0497d6f6e5d9c4fb660118cdff05a8
Test: "adb devices" works against a non-AOSP device with $ADB_VENDOR_KEYS set, says "unauthorized" without.
Bug: http://b/29273531
2016-08-11 13:53:18 -07:00
Elliott Hughes
f2f4e784a4 Merge "std::unqiue_ptr<..., decltype(&fn)> seems to be the preferred idiom."
am: 2f21b7cecd

Change-Id: I9fa6d99a61053dae4ad60c0b73ddac755b29cf61
2016-08-08 21:17:54 +00:00
Elliott Hughes
aea1683c12 std::unqiue_ptr<..., decltype(&fn)> seems to be the preferred idiom.
This is the only decltype(fn)* outside aapt2 in the whole tree.

Change-Id: I2e19d2031b56fdb808c62c2c07ca6080c9ec6fe3
2016-08-08 12:52:37 -07:00
Josh Gao
87ef590bc1 Merge "libcrypto_utils: convert to Soong."
am: c1a9a21ffe

Change-Id: I9cf76646d4537750c4d4080234d3384fb307e610
2016-08-08 18:33:49 +00:00
Josh Gao
c1a9a21ffe Merge "libcrypto_utils: convert to Soong." 2016-08-08 18:29:10 +00:00
Josh Gao
47763c3a09 libcrypto_utils: convert to Soong.
Bug: http://b/30708454
Change-Id: Iaad64272ced766f87e67f2877e990afccc558065
2016-08-05 18:07:36 -07:00
Josh Gao
1286c1f878 adb: correctly fix merge conflict.
Change-Id: Ic637c0ef5499e2893cd0adfcc41dd5d3481524c2
2016-08-05 00:39:16 -07:00
Josh Gao
4ff7f9f62a resolve merge conflicts of e012de5 to stage-aosp-master
Change-Id: I3d9f8b4421fa6122261dbd821561a2236f810a47
2016-08-04 22:04:05 -07:00