Commit graph

929 commits

Author SHA1 Message Date
Jack Pham
47c3ce56ed adbd: enable USB SuperSpeed (again)
The descriptors to enable USB 3.0 SuperSpeed support had previously
been added in commit d6ee9f26a5
but were removed when the v1/v2 descriptor handling was refactored
in commits ab3446dd34 and again in
c49f51c451. Now that the dust has
settled, add back the SS descriptors to re-enable USB 3.0.

Bug: 23385314
Change-Id: I8de7c7e50d9216a7492ce7863e3aaf92ff805eff
(cherry picked from commit a190c800bf)
2015-08-24 18:03:03 +00:00
Thierry Strudel
df33ffadd2 fs_config: replace getenv('OUT') by new fs_config parameter
Using a getenv('OUT') in such a deep down function is a wrong design
choice. Replacing with explicit parameter that may be NULL in case
device specific files can be accessed from /.
Since TARGET_COPY_OUT_SYSTEM may be defined to something different than
system we also ensure that we use a path relative to TARGET_OUT to
compute path to fs_config_* files.

Bug: 21989305
Bug: 22048934
Change-Id: Id91bc183b29beac7379d1117ad83bd3346e6897b
Signed-off-by: Thierry Strudel <tstrudel@google.com>
2015-07-09 21:47:07 -07:00
Elliott Hughes
1cddc2092f Ignore ro.adb.secure in user builds.
Require authorization by default, and remove the ability to override
that in user builds. (userdebug and eng are still free to do whatever
they want.)

Bug: http://b/21862859
Change-Id: Ibf8af375be5bf1141c1ad481eee7a59fb10a7adb
(cherry picked from commit 5cba504215)
2015-06-19 13:26:02 -07:00
Spencer Low
d62bce8040 adb: win32: fix key files reading/writing
The issue is that adb uses fopen() with "e" (presumably to open the file
with O_CLOEXEC), but that flag causes MSVCRT.DLL to return an error. So
when adb_auth_host.cpp goes to read or write the adbkey files, it fails.

The quick fix is to not use the "e" option on adb host code since it
isn't necessary there, compared to adbd.

An alternative fix would be to have a fopen() wrapper on Windows that
filters out the "e" option.

Bug: http://b/21806456
Bug: https://code.google.com/p/android/issues/detail?id=175077
Change-Id: I7d8ba2847dab0ed558ffe156e79093251eb253c9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
(cherry picked from commit 9b9603148b)
2015-06-12 11:02:37 -07:00
Svetoslav
23d8407465 Improve adb install help.
Bug: 21365060
Change-Id: I0a4ea5cf3a2f37a82161b30f7eec5781d175aa8f
2015-06-01 23:59:20 +00:00
Lorenzo Colitti
0b3baac512 Document the -g option to adb install.
Change-Id: I012165df343c24953f1c1cfcdce379bf1b67c624
2015-05-28 12:03:44 +09:00
Elliott Hughes
2181c722ce 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
(cherry picked from commit 84b0bf2264)
2015-05-15 14:50:47 -07:00
Elliott Hughes
a51d8b9a1c Failure to find an oem partition should not be a remount failure.
Many devices don't have an /oem partition, so find_mount should be
expected to fail, but shouldn't cause the overall remount to fail.

Also clean up all the error handling and reporting, and remove the
dead int* globals.

Bug: http://b/21024141
Change-Id: Ie31021b03c9cab8e972269d7d1ffe383cd30ee9e
(cherry picked from commit 9aa4fda4e6)
2015-05-11 13:36:13 -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
Benson Leung
c33e62bdc6 Merge "Be tolerant of devices that don't report serials." into mnc-dev 2015-05-08 17:37:10 +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
Dan Albert
6043e15311 Be tolerant of devices that don't report serials.
The USB spec explicitly says this is optional, so we shouldn't be
relying on it.

Bug: http://b/20883914
Change-Id: Icf38405b00275199bcf51a70c47d428ae7264f2b
2015-05-07 15:56:03 -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
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
Elliott Hughes
e1a55004e9 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 ab52c181fa)
2015-05-01 17:37:28 -07:00
Elliott Hughes
92af733ee2 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 e67f1f87d9)
2015-05-01 17:09:34 -07:00
Elliott Hughes
f1a58f8f33 More fixed-length buffer removal.
Bug: http://b/20666660
Change-Id: I0c738e9fed2defed48a9cf2d0a4f7b99c08dcf3d
(cherry picked from commit 6452a89aa8)
2015-04-30 12:31:11 -07:00
Elliott Hughes
0156589846 Add missing 'else' to fix all devices showing up as "host".
Bug: http://b/20705355
Change-Id: I4f7830278f0c2bc87d95d148d85455b8da894645
(cherry picked from commit 3ce9575af7)
2015-04-29 22:44:47 -07:00
Elliott Hughes
2e06d3057e Fix Win32 build.
(cherry-pick of 1b600a902cc0b3a6065c962293292a5ac689fafe.)

Change-Id: Icf2c8df99b4b88bbf85a4097731733c5795fba44
2015-04-29 12:37:33 -07:00
Elliott Hughes
71aeb79815 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
2015-04-29 11:42:13 -07:00
Elliott Hughes
d81f75ae41 Remove strtok from adb.
Also fix android::base::Split to behave like Java, Python, and google3.

(cherry picked from commit 8d5fa6da44)

Change-Id: I9388ae37ee8dd4a4a6c2a9a19f068b70d9a78353
2015-04-28 10:55:24 -07:00
Elliott Hughes
03a90d6633 Support the full length of USB serial numbers.
Two bugs: we couldn't report the serial number correctly if it was long
enough, and it wasn't possible to connect to a device whose serial number
was long enough to overflow a different fixed-length buffer.

Bug: http://b/20317730

(cherry picked from commit 9309ecbcec)

Change-Id: I04c160a215418a57bd4fb27b7f63060c8be6f12e
2015-04-27 17:19:01 -07:00
Elliott Hughes
ce6363bbbc Improve logging of USBDEVFS_CLAIMINTERFACE failures.
Bug: https://code.google.com/p/android/issues/detail?id=170054
Change-Id: I9b11eb019093e3322da0a8e70d6e17de4c25ab75
2015-04-25 14:44:23 -07:00
Elliott Hughes
876881b22a Merge "Add missing null checks after allocations." 2015-04-22 20:05:46 +00:00
Elliott Hughes
dc3b459ff9 Add missing null checks after allocations.
Bug: http://b/20317729
Change-Id: I62bb761d48ee59a1f4ddd0cdd0632432305ca2ca
2015-04-21 19:43:22 -07:00
Elliott Hughes
1555147bc4 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
2015-04-21 17:58:55 -07:00
Elliott Hughes
8e6edc0d89 Add a couple more adb shell regression tests.
Bug: http://b/15479704
Change-Id: Id3e7f0df101ad61db509df313c13210a8bd8b124
2015-04-21 16:25:54 -07:00
Badhri Jagan Sridharan
82b0f7ba92 Merge "adb: set sys.usb.ffs.ready to signal usb pullup" 2015-04-21 19:58:46 +00:00
Badhri Jagan Sridharan
5f97370bab adb: set sys.usb.ffs.ready to signal usb pullup
This change sets sys.usb.ffs.ready to 1 to
trigger configfs based enumeration.

Change-Id: I222495fc667cce59675579069d164b0b484f3653
2015-04-21 12:44:31 -07:00
Elliott Hughes
0053bb3f1a Add a test for shell escaping.
Until I fixed this, we would fail this example:

  $ adb shell sh -c 'echo hello; echo world'
  hello
  /system/bin/sh:  echo world: not found

Bug: http://b/19734868
Change-Id: I11a437cd0c0362303028f23fbaa103611b75707e
2015-04-21 12:15:31 -07:00
Elliott Hughes
d236d071b9 Fix "adb sync" for devices without vendor and oem.
Bug: http://b/20440110
Change-Id: I2481992198890f5ca50412c2b7ca361101961413
2015-04-21 10:17:07 -07:00
Elliott Hughes
e434ad1dd7 Merge "Always explain why bind(2) failed." 2015-04-21 16:52:21 +00:00
Elliott Hughes
14b65736c5 Merge "Use ' quoting to escape arguments." 2015-04-21 16:47:43 +00:00
Colin Cross
dc1e482b20 Fix windows adb build
libc++ is not available on windows yet, but it already defaults to
static libstdc++.

Change-Id: I85a766ead84f71fe1f2f59be6ac739b0b833b6db
2015-04-20 12:43:02 -07:00
Colin Cross
b2b06de5fc Merge "statically link adb and fastboot against libc++" 2015-04-20 18:05:29 +00:00
Elliott Hughes
7b506090e1 Always explain why bind(2) failed.
This has confused several people lately.

Bug: http://b/20219978
Change-Id: I2537ceb83bff0b3166c230c728d4389a983db858
2015-04-20 08:09:20 -07:00
Elliott Hughes
53daee6a2b 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
2015-04-19 13:17:01 -07:00
Elliott Hughes
5498adefb0 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
2015-04-17 20:55:04 -07:00
Elliott Hughes
6c34bbaa68 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
2015-04-17 20:30:09 -07:00
Elliott Hughes
a7090b94c1 Remove yet more fixed-length buffers (and their overruns).
Bug: 20317724
Change-Id: If137fc96f5f23576ccecd388ac87afefa47337c6
2015-04-17 17:58:35 -07:00
Elliott Hughes
2083fa6b01 Switch adb over to clang.
Change-Id: Ib5511dcba56e80ffce6bc293d99251ccfd61c330
2015-04-17 15:27:13 -07:00
Elliott Hughes
61a004c05f Merge "Fix more buffer overruns." 2015-04-17 22:24:27 +00:00
Elliott Hughes
5830577bd8 Fix more buffer overruns.
Also add some tests.

Bug: 20323050
Change-Id: I9eaf3dc04efd85206663c4cca4f8c1208620a89a
2015-04-17 15:23:31 -07:00
Elliott Hughes
2940ccff86 Use PRI* macros to fix the Windows build.
Change-Id: Icd400be05c2bc726265832875b5a05dba7966847
2015-04-17 14:07:52 -07:00
Elliott Hughes
2baae3a876 Remove various fixed-length buffers (and their overflows).
Bug: 20323052
Bug: 20323051
Bug: 20317728
Bug: 20317727
Bug: 20317726
Bug: 20317725
Change-Id: I57a5e30a5b7867715f55cee7429aa36d7ce21484
2015-04-17 10:59:34 -07:00
Elliott Hughes
0b8ecb3290 Merge "Remove extern "C" barriers to using C++." 2015-04-17 17:31:51 +00:00
Elliott Hughes
2d4121c0dc Remove extern "C" barriers to using C++.
Change-Id: Ic046d6aa540738cb46b54531bc59ba3b47b0136d
2015-04-17 09:47:42 -07:00
Elliott Hughes
7be29c819b Show $ADB_VENDOR_KEYS if authentication fails.
Incorrectly set $ADB_VENDOR_KEYS is the most likely cause of failed
adb connections. Make it easier to debug such problems by including
the value in use in the error message.

Bug: 20165551
Change-Id: I64c1d98ae6d3fb40eea9e1f0ddcfcf4f2d9d7318
2015-04-16 22:54:44 -07:00
Dan Albert
a4802ca08b Merge "Move usb_osx to C++." 2015-04-17 04:37:47 +00:00
Dan Albert
c4f8fa7b36 Merge "Link libraries needed for Darwin adb tests." 2015-04-17 04:37:41 +00:00