Commit graph

1135 commits

Author SHA1 Message Date
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
Dan Albert
7447dd05bd Move usb_osx to C++.
Change-Id: I21673211a702cc4f31d4311c36e2a4b22e55fac8
2015-04-16 19:20:40 -07:00
Dan Albert
f8d6b9b1ef Link libraries needed for Darwin adb tests.
Change-Id: I1c3c3a7bbd3824f5f3a37ee80c24d1c2a9b98748
2015-04-16 19:13:58 -07:00
Colin Cross
55bf5f0017 statically link adb and fastboot against libc++
libc++.so is not widely available on the host, so we compile against
one built as part of the platform.  This causes problems for adb and
fastboot, which are distributed through a number of channels - the
sdk, distro packages, downloaded from the build server, or manually
copied.  Instead of forcing all users to handle libc++.so too,
statically link against libc++.

Change-Id: I51b75258653a23558c8b598802005f6c1166a439
2015-04-16 17:09:46 -07:00
Elliott Hughes
a2f2e56796 Move sysdeps_win32 to C++.
Change-Id: I27ca41b64d62bb3611b3a39a5c3bb4377d0773bc
2015-04-16 16:47:02 -07:00
Elliott Hughes
2acec9153e Switch usb_linux_client to C++.
Change-Id: I8172e81e6c4665aa16e9e8e0c33b048dbb9ad848
2015-04-16 14:38:37 -07:00
Elliott Hughes
1a4d85a5e8 Move get_my_path_darwin to C++.
As long as we have C in here, we can't use C++ in our headers.

Change-Id: Ibccaa77a5af506dc504aa9c39c8dca5dcdbeccab
2015-04-16 13:24:58 -07:00
Sami Tolvanen
284c5cb2a1 Merge "Set verity mode as the verified property value" 2015-04-07 08:45:24 +00:00
Alistair Buxton
dfa09fd635 Disable CR/LF translation for adb interactive shell.
adb shell uses termios to disable canonical input processing in order to
get raw control codes but it does not disable CR/LF translation. The default
for Linux terminals is to convert CR to LF unless the running program
specifically asks for this to be disabled. Since adb does not, there is no
way to send a CR to any program run on adb shell. Many programs do in fact
differentiate and so are broken by this behaviour, notably nano. This patch
sets the termios flags to disable all line ending translation.

Change-Id: I8b950220f7cc52fefaed2ee37d97e0789b40a078
Signed-off-by: Alistair Buxton <a.j.buxton@gmail.com>
2015-04-05 10:02:34 -07:00
Elliott Hughes
09a45a1927 Fix "adb devices -l".
Change 055f1aa4ff switched to using isalnum(3)
but didn't take into account that isalnum has the opposite sense to the
function it replaced, so the tests should have been inverted.

Bug: http://b/20056546
Change-Id: I90630c0bea69ddbb4a95dc09f79f49d23fd497de
2015-04-03 16:12:15 -07:00
Elliott Hughes
bcc2b5f44a Remove LOCAL_ADDITIONAL_DEPENDENCIES in cases where it's not needed.
Change-Id: I720b8ef1050da45a7833adef8219b6acb2cf3a38
2015-04-02 14:31:07 -07:00
Sami Tolvanen
454742392f Set verity mode as the verified property value
Set the verity mode as the value for partition.%s.verified to make it
easier for userspace to determine in which mode dm-verity was started.

Change-Id: Icc635515f8a8ede941277aed196867351d8387cb
2015-03-31 09:12:00 +01:00
Tao Bao
175b7bbfb4 adb: Add option to reboot into sideload mode in recovery
Currently it requires manual key press to enter the sideload mode. This
CL adds 'adb reboot sideload' to reboot the device into sideload mode
directly with text display on. With 'adb reboot sideload-auto-reboot',
it will reboot after the sideload regardless of the installation result,
unless interrupted by user.

Since it needs to write to /cache/recovery/command file, 'adb root' is
required before calling 'adb reboot sideload' and the one with
'-auto-reboot'.

Also it requires the matching CL in bootable/recovery.

Change-Id: Ib7bd4e216a1efc01e64460659c97c6005bbaec1b
2015-03-31 00:19:52 +00:00
Dan Albert
868402e5bf Revert "Remove the emulator special case from the "adb root" code."
adb root doesn't work on the emulator, so this prevents root access
to a userdebug emulator.

Since the emulator has always been root even on userdebug builds, it
may be that adb root has never worked on the emulator.

Bug: 19974213

This reverts commit abd6773b41.
2015-03-28 19:04:15 +00:00
Spencer Low
50184062b8 adb shell: Win32: fix Ctrl-C, tab completion, line editing, server echo
The 'adb shell' command on Windows has had problems:

* Ctrl-C killed the local Windows adb.exe process instead of sending the
Ctrl-C to the Android device.

* Local echo was enabled, causing everything typed to be displayed twice.

* Line input was enabled, so the Android device only received input
after hitting enter. This meant that tab completion did not work because
the tab wasn't seen by the shell until pressing enter.

* The usual input line editing keys did not work (Ctrl-A to go to the
beginning of the line, etc.).

This commit fixes these issues by reconfiguring the Win32 console and
then translating input into what Gnome Terminal would send, in effect
somewhat emulating a Unix terminal.

This does not fix all Win32 console issues, but is designed to be better
than what we had before, and to make the common day-to-day usage much
more comfortable and usable.

Change-Id: Idb10e0b634e27002804fa99c09a64e7176cf7c09
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-03-26 12:26:08 -07:00
Dan Albert
8743ef9841 Additional cleanup of start_device_log.
Addresses nnk's post commit review comments on
https://android-review.googlesource.com/#/c/139381/

Remove unneeded code for creating /data/adb.

Add an O_CLOEXEC.

Move the closing of stdin out to main().

Append the pid of the current process to the log file to avoid
clobbering the log if the process crashes and restarts within the same
second.

Change-Id: Ide0be86b4b33256486634c29ba02efaf10cf913d
2015-03-20 09:49:15 -07:00
Dan Albert
ea2175ab6b Use text based trace masks for adbd.
Previously the adbd trace mask had to be set as raw hex rather than
with the colon separated list. We all have better things to do than
memorize bitmasks, so make adbd use the same trace mask setting code
as adb.

Change-Id: I0bf0ab61c070d06d1cc2acf1ed90b2b77ccd261b
2015-03-19 21:50:10 -07:00
Dan Albert
a16b0f4c3a Merge "The generic failure case disappeared..." 2015-03-20 03:50:36 +00:00
Dan Albert
28f07697eb Merge "File header cleanup." 2015-03-20 03:14:28 +00:00
Dan Albert
08f66bc771 The generic failure case disappeared...
Was manifesting as a write to a full disk hanging indefinitely.

Bug: 19846181
Change-Id: Ia581e0bbbb331c221bdb68882c238d0cb9f8a0b3
2015-03-19 20:10:30 -07:00
Dan Albert
3313426fad File header cleanup.
* sysdeps.h should always be included first.
 * TRACE_TAG needs to be defined before anything is included.
 * Some files were missing copyright headers.
 * Save precious bytes on my SSD by removing useless whitespace.

Change-Id: I88980e6e00b5be1093806cf286740d9e4a033b94
2015-03-19 15:32:33 -07:00
Dan Albert
683238c3c4 Fix clang-format file for correct indent settings.
Change-Id: I8786baf33c0b84e3614e9d40c404eeef94b91236
2015-03-19 13:27:20 -07:00
Dan Albert
b4ebc475e6 Merge "Fix memory leak on jdwp_process_free()" 2015-03-19 16:53:57 +00:00
Pavel Labath
64d9adcea8 Fix file descriptor leakage in adbd
adb_auth_init in adb_auth_client.cpp sets FD_CLOEXEC on the control
socket, which prevents the leakage. However if ro.adb.secure
property is unset (as it is on the emulator), adb_auth_init is not
invoked, which results in the control socket fd leaking into any
process started by the deamon (specifically, any command executed
through adb shell).

Split the fd cleanup into a separate function that is called
unconditionally.

Change-Id: I73ea84977542ddfc4ac20599593ecf3745ae9108
2015-03-17 11:24:34 -07:00
Elliott Hughes
ec7a667131 Revert "Revert "adb: support /oem partition""
This reverts commit 6084a0124f.

The original build breakage is fixed by (a) building the verity
code for eng builds as well as userdebug builds and (b) moving
the exported remount service functions into a new header file.

Change-Id: Ice0c4f97d4db38ab7eb333c7a6e56bbd11123f5b
2015-03-16 20:05:21 -07:00
Dan Albert
6084a0124f Revert "adb: support /oem partition"
This is broken on userdebug builds, and it isn't completely clear why. The declaration for make_block-device_writable in adb.h wasn't updated to match the definition (which uses a std::string instead of a char*). adb.h is currently extern "C", and it isn't clear why this is only broken for userdebug, so I'd like to revert while we investigate.

This reverts commit 81416fdb18.

Change-Id: I47f321574f9f21052e2c7332e8b0f6ef9ab98277
2015-03-16 21:35:53 +00:00
Mårten Kongstad
81416fdb18 adb: support /oem partition
Add support for /oem partition in commands 'adb remount' and 'adb sync'.

Change-Id: I5defc74ccaa37feaef74b9268e22b4075f98a59f
2015-03-16 11:17:13 -07:00
Dan Albert
98ff77204c Create libbase.
Move StringPrintf and the string based file I/O from libutils to
libbase.

Change-Id: I0297a6063874b9d92100e0dd5123fddfbda932fe
2015-03-14 16:36:18 -07:00
Elliott Hughes
46270d233a adb doesn't actually use libzipfile.
Change-Id: Ia7d22214bc8422c88edaaf9bb716d7e12e0bb381
2015-03-13 09:40:45 -07:00
Dan Albert
83ca56ac98 Fix build from -Werror=maybe-uninitialized.
This won't actually ever be uninitialized because the code will take a
failure path if the code that initializes it fails. The goto seems to
thwart this check though.

Not sure why this is only firing on userdebug builds yet. I'll look in
to it tomorrow.

Change-Id: Ie9d837d6baea255d2a4d169355b53dfd775eacce
2015-03-09 18:29:07 -07:00
Dan Albert
bac3474a82 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
2015-03-09 14:06:11 -07:00
Dan Albert
9b1fd969a7 Merge "Fix a writex transcription error." 2015-03-09 20:29:07 +00:00
Dan Albert
f3519a8747 Fix a writex transcription error.
Change-Id: I71b11127d41ebac6caf68926089c5a3b99d8c21e
2015-03-09 13:22:02 -07:00
Dan Albert
857d7db69d Make the root/unroot test more robust.
* Check the current adb user to choose the order of root/unroot.
* Re-root the device when finished.

Change-Id: I47a14b89e2c405bd63722e4d2043fcc629fb5e58
2015-03-09 10:45:50 -07:00
SungHyun Kwon
abb80e0f95 Fix memory leak on jdwp_process_free()
if many jdwp connection are created(), the memory will be leaked.

When it deletes heap memory on jdwp_process_free(),
the proc->fde just set to null.

so it need to free() in fdevent_destory().
2015-03-03 17:56:18 +09:00
Nick Kralevich
268eb4f384 check if uid=0 before attempting remount
If "adb remount" is done without having done "adb root" first,
scary looking SELinux denials are emitted before the operation
eventually fails. Avoid the scary looking messages by refusing
remount attempts if we're not running with privileges.

Change-Id: I298621251a10e38345ef77875003a97c8b5a0270
2015-02-25 16:27:31 -08:00
Dan Albert
cc731cc767 Test readx/writex (now renamed).
Renamed readx/writex to ReadFdExactly/WriteFdExactly respectively.
These read/write a full fixed-size buffer. If the whole buffer cannot
be read/written, these functions return an error.

Rename write_string to WriteStringFully.

Move the TEMP_FAILURE_RETRY definition in sysdeps.h out of the
!Windows section. It seems Windows won't actually interrupt a call,
but it's easier to just define it than to #ifdef each call.

Change-Id: Ia8ddffa2a52764a2f9a281c96c937660e002b9b9
2015-02-25 15:07:57 -08:00
Dan Albert
7fd821e907 Remove _(GNU|XOPEN)_SOURCE makefile cruft.
None of the functions that require these are used.

Change-Id: I10cffab127795b94340131f8737f7924b9138f9e
2015-02-25 11:08:21 -08:00
Dan Albert
055f1aa4ff Add some basic tests to adb.
Change-Id: I946b5b1e5650540db3b4f75892214c4218b3baf3
2015-02-25 10:57:26 -08:00
Dan Albert
dc0f8ecb24 Fix the mac build.
Change-Id: Ieb6f2650ce5f39f1d8c938d0ca8cbec459d8e2fd
2015-02-25 10:26:17 -08:00
Dan Albert
72bf2a7100 Merge "Move transport declarations into transport.h." 2015-02-25 05:33:35 +00:00
Dan Albert
7664901a35 Move transport declarations into transport.h.
There are a few cloexec issues in here as an added bonus.

Change-Id: I1699d719d733f47878bdba0454230cf5ab6a60b6
2015-02-24 21:30:22 -08:00
Dan Albert
103c1be03f Add .clang-format file.
Not going to format the whole world just yet, but this helps for `git
clang-format`.

Change-Id: I482819419647e4c752d3b044bde8d637e1fae1e5
2015-02-24 16:56:39 -08:00
Dan Albert
5329d3fd54 Merge "Add a project wide clang switch." 2015-02-25 00:20:39 +00:00
Dan Albert
9697ce520d Add a project wide clang switch.
I'll probably make this the default soon, but I'm not brave enough to
do that without checking the recovery image first.

Change-Id: I9cde687b08a588e3797645a308f381e4ec553447
2015-02-24 15:54:34 -08:00
Elliott Hughes
70385f3017 Merge "Remove the emulator special case from the "adb root" code." 2015-02-24 23:53:55 +00:00
Dan Albert
b2e57b738f Make Python tests only check the current device.
In practice testing all connected devices is a pain, since it's
probably each device is running a different build. It would probably
make sense to just move this functionality up into a higher level test
runner (which could just live in main).

Also rename test_devices to test_shell, since it doesn't really test
`adb devices`.

Change-Id: Ie96d3e83b30acfac4e3bcbd9821690c0ad4d2f7e
2015-02-24 14:36:03 -08:00
Dan Albert
fdf8722491 Fix Mac build.
Prior to https://android-review.googlesource.com/#/c/134253/ the
makefile had assumed !Windows was the same as Linux, so the Mac was
actually getting all the Linux sources as well. I mistakenly didn't
add fdevent.cpp to the Darwin sources in that change.

Change-Id: I4e12a394e9a2baf7c1e3c711a01a6b5fccbf79d9
2015-02-24 14:27:33 -08:00
Elliott Hughes
abd6773b41 Remove the emulator special case from the "adb root" code.
The emulator is essential an "eng" build, so the regular properties
should suffice.

Change-Id: Id63b3918f9b0b04b0d887ed886535b9976a9cc85
2015-02-24 14:10:51 -08:00
Dan Albert
88cf1c8c4a Fix Windows SDK build.
Change-Id: I9c0f9c92c28867ff17f1ec83aac935d18348c335
2015-02-24 14:08:03 -08:00
Elliott Hughes
3b967f52f2 Add missing <stdlib.h> to adb_listeners.c.
Change-Id: If9505880a33131b27bfaa19f3efd45c83a6810ed
2015-02-24 12:37:13 -08:00
Dan Albert
a75b4935a4 Merge "Move more into libadb and libadbd." 2015-02-24 19:44:34 +00:00
Dan Albert
9f3540d017 Merge "Oops. Fix make variable name. Thanks again, make." 2015-02-24 19:44:12 +00:00
Dan Albert
8ef39424e8 Merge "Ignore another stupid lint warning." 2015-02-24 19:44:05 +00:00
Nanik Tolaram
b627a0e2ed Add more logging message and dead code
* Add more logging message to aid in easier debugging

* Remove unnecessary dead/commented code

Change-Id: I9c7fe8f6b674cab41601001458010ab176b89776
Signed-off-by: Nanik Tolaram <nanikjava@gmail.com>
2015-02-23 22:38:39 +00:00
Dan Albert
3c43858986 Move more into libadb and libadbd.
None of this needs to be shared with minadbd, but these sources are
still needed for anything linking libadb (such as tests).

Change-Id: I3024f714da42364bf27a991986f00676e2bbbf2c
2015-02-20 17:24:30 -08:00
Dan Albert
bf10647b61 Oops. Fix make variable name. Thanks again, make.
Change-Id: Iecbb41acc835bb8eb20b668c89a3ff065470fcb7
2015-02-20 17:20:37 -08:00
Dan Albert
f1591691ee Ignore another stupid lint warning.
Change-Id: I8e586e472a139cc3039f1371f8a99935d20aa0f0
2015-02-20 17:19:22 -08:00
Dan Albert
7e84308b74 Merge "Lose adb.c and sockets.c to libadb." 2015-02-19 23:47:18 +00:00
Dan Albert
e1ca623faa Lose adb.c and sockets.c to libadb.
Also kill the device side libadb. This was added for the now dead
device side adb, and is no longer used.

Bug: 17626262
Change-Id: I3b28915641fd5b4f16fc86cf1f4f4e9711093001
2015-02-19 13:49:35 -08:00
Dan Albert
18daa159ec Merge "Document the behavior of props affecting adb root." 2015-02-19 20:33:31 +00:00
Dan Albert
13f9c406d7 Document the behavior of props affecting adb root.
Change-Id: Icfdc3ba696556d6db64835e61dde6f40b491d1a7
2015-02-19 12:29:01 -08:00
Dan Albert
6795cd8db5 Fix Windows adb build.
Change-Id: I560bedfcf77556b36acadc19f5dac71b3628ea2b
2015-02-19 11:36:53 -08:00
Dan Albert
bd0b750897 Move adb_main to its own file.
Change-Id: If6e98c089b39f73bd8f4a878a82669bfeee367f3
2015-02-18 18:32:54 -08:00
Dan Albert
e9fca14c9e Move the listener code into its own file.
Change-Id: I7332455ed1a213daedeaa4a81260edf08b2fd131
2015-02-18 18:22:52 -08:00
Dan Albert
ba3a251749 Move the adb auth code into its own file.
Change-Id: I84cf0bd7777f0147119e7c6afc4096c2e93156a2
2015-02-18 18:22:52 -08:00
Dan Albert
1403aa36b2 Merge "Move emulator tracing into its own file." 2015-02-19 02:10:10 +00:00
Dan Albert
21c3eaf4cc Move emulator tracing into its own file.
adb.c is far too monolithic.

Change-Id: I4a9ee97927e4a96a38ea5859d84efac86bfdfc35
2015-02-18 17:21:17 -08:00
Elliott Hughes
4c9d24a3ed Fix build.
Change-Id: I31fc562068ebbba5e9872ee91694feb611fc957f
2015-02-18 16:57:30 -08:00
Elliott Hughes
8e16a7e2a3 Merge "adb: add "adb unroot" to restart adb in non-root mode" 2015-02-19 00:18:38 +00:00
Dan Pasanen
9885881d06 adb: add "adb unroot" to restart adb in non-root mode
Change-Id: Ice6b94a71a62648ac073d129914a07372411fb25
2015-02-18 12:37:11 -08:00
Dan Albert
9449376328 Move USB transport code to libadb.
Also note that we need both a libadb and a libadbd (for now) to
differentiate between code using ADB_HOST=1 and ADB_HOST=0.

Bug: 17626262
Change-Id: I873a8fb442a8a69258fe39af17781714a8fae4f6
2015-02-18 10:55:28 -08:00
Dan Albert
1ac334ec66 Merge "Add extern "C" to all the adb headers." 2015-02-18 17:52:40 +00:00
Dan Albert
818fb4b448 Add extern "C" to all the adb headers.
Change-Id: Iaefa3e18d6ee2e065eb97271a796613b2a8e7d6e
2015-02-18 00:21:16 -08:00
Dan Albert
54ac73aa34 Ignore useless cpplint messages in adb.
Change-Id: I6411eb3963d215b228e50cd967a2174e5036ed73
2015-02-18 00:20:37 -08:00
eric.yan
a859219fec fix bug that passing invalid fd to fstats on win32 builds
lfd returned by adb_open is not the actual file desc.
on win32 builds. calling through fstat with invalid fd
will lead to crash, using stat instead.

Change-Id: I7fdc8b825162eaa42efe8755265842c300b00e39
Signed-off-by: eric.yan <eric.yan@yulong.com>
Signed-off-by: severecold <severecold@gmail.com>
2015-02-09 13:41:27 +00:00
Elliott Hughes
187eade127 Remove netcfg's unused options.
Only "netcfg" for a list of interfaces and "netcfg <interface> dhcp" still
seem to be used.

Change-Id: I9f0b580474258fa648deb5287f98d8ec5533ca6f
2015-02-03 11:59:22 -08:00
Elliott Hughes
c463025a19 Revert "Remove netcfg's unused options."
This reverts commit f8e83054cb.

Change-Id: Iede772f96ff9008277df433dcbb5f6603de65283
2015-02-03 19:56:35 +00:00
Elliott Hughes
f8e83054cb Remove netcfg's unused options.
Only "netcfg" for a list of interfaces and "netcfg <interface> dhcp" still
seem to be used.

Change-Id: Iaf499c06b09ffe5e0925339b9cd6e502f3234a86
2015-02-03 11:08:07 -08:00
Elliott Hughes
506aea4361 The bsddroid project has been dead since 2010.
And even if it wasn't, they should probably keep this stuff in their own
repository.

Change-Id: If9fa2e47ee2700098d8a99f6986f7e89fc6dfdf3
2015-01-31 11:24:14 -08:00
Sami Tolvanen
9c4c5a6ed9 Merge "Verify token length before adb signs it" 2015-01-28 14:32:52 +00:00
Elliott Hughes
a034362be4 Merge "Make server port option work on windows" 2015-01-28 03:29:06 +00:00
Spencer Low
0de77ffec6 adb: tracing: don't make strings if runtime tracing is disabled
If tracing was not enabled (the ADB_TRACE environment variable was not
set specially), writex() and readx() would still call dump_hex() which
would construct hex tracing strings, which would be immediately
discarded and not printed (because tracing is not enabled).

The fix is to only call dump_hex() if ADB_TRACING evalutes to true, the
same way that dump_packet() is only called if ADB_TRACING evaluates to
true.

Change-Id: I1651680da344389475ebdeea77ba1982960d5764
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-01-27 15:42:14 -08:00
Sami Tolvanen
7b9c20d3b2 Verify token length before adb signs it
Currently, a host running adb will sign a token of any length passed
to it by a device, effectively acting as a signing oracle. If the
ADB_VENDOR_KEYS environment variable is used to specify an additional
key to use, this behavior is not only unexpected, but probably also
unwanted. Further discussion can be found from this thread:

  http://www.metzdowd.com/pipermail/cryptography/2015-January/024423.html

This change adds a check to ensure token length matches TOKEN_SIZE
before it's signed, which prevents an attacker from signing longer
messages.

Change-Id: I7b2cc1f051941bf9b66e1c02980850bede501793
2015-01-27 17:19:35 +00:00
Spencer Low
f055c193b8 adb: Win32: set socket buffer sizes properly
On Windows, adb_socket_setbufsize() was taking a file descriptor value
from the compatibility layer in sysdeps_win32.c (namely, an index into
the _win32_fhs array) and passing it to the Winsock setsockopt() call,
which wants a Winsock SOCKET handle. Basically, adb_socket_setbufsize()
was passing `fd` instead of `_fh_from_int(fd)->fh_socket`, resulting in
adb effectively setting a socket buffer size on a random socket in the
process.

The fix is to introduce adb_setsockopt() which just calls setsockopt()
on non-Win32, and which uses the Winsock SOCKET handle on Win32. The
change also moves Win32 disable_tcp_nagle() to a header and adds an
extra sanity check to adb_shutdown().

Change-Id: I4354e818d27538f7ff5b0e70b28bdb6300e1b98b
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-01-26 21:56:26 -08:00
Dan Albert
1f09bdaf59 Protect from eng vs userdebug build breaks.
Using a const bool rather than an ifdef means the compiler can still
protect us from breaking code paths that aren't included in every
build variant.

Change-Id: Ic45c8fb52cd66c3ce090d760cdb92104e31265f5
2015-01-26 17:49:17 -08:00
Dan Albert
fe68578716 Merge "Fix userdebug build." 2015-01-27 01:30:24 +00:00
Dan Albert
030b76fc1d Fix userdebug build.
Apparently this code I thought was unused is just unused for eng
builds...

Bug: 17626262
Change-Id: I2e5f411a2ead7f23d9f5822935de66c992750a03
2015-01-26 17:14:23 -08:00
Dan Albert
4626b71057 Fix win_sdk build.
Hadn't caught this in the previous submission because I tested the
build with another change on top of it that also fixes this.

Bug: 17626262
Change-Id: Ia40127618a5466e382081760d614ff7fc09d50a3
2015-01-26 17:07:47 -08:00
Dan Albert
630b9afeb0 Begin moving code from adb to libadb.
Much of adb is duplicated in bootable/recovery/minadb and fastboot.
Changes made to adb rarely get ported to the other two, so the trees
have diverged a bit. We'd like to stop this because it is a
maintenance nightmare, but the divergence makes this difficult to do
all at once. For now, we will start small by moving common files into
a static library. Hopefully some day we can get enough of adb in here
that we no longer need minadb.

Bug: 17626262
Change-Id: Ic8d5653bfcc0fec4e1acbece124402355084b864
2015-01-26 16:45:34 -08:00
Christopher Ferris
fb538fb13d Merge "Fix the v2 descriptor handling." 2015-01-26 21:28:06 +00:00
Christopher Ferris
c49f51c451 Fix the v2 descriptor handling.
There was a misinterpretation of how the v2 header works. The flags
in the header indicate what is in the rest of the structure.

Bug: 19127803

Change-Id: I5fa0dae6da51522c9afc4c94838eb6f462208683
2015-01-26 12:50:35 -08:00
Spencer Low
943ef23b3d adbd: tcpip command uses port number from uninitialized memory
If you run `adb tcpip`, adbd tries to process a string of 'tcpip:' using
this code:

    } else if(!strncmp(name, "tcpip:", 6)) {
        int port;
        if (sscanf(name + 6, "%d", &port) == 0) {
            port = 0;
        }
        ret = create_service_thread(restart_tcp_service, (void *) (uintptr_t) port);

If a zero-length string is passed to sscanf(), it returns EOF (-1) which
causes the if statement to skip the block, leaving the port variable
uninitialized.

I found this by running `adb tcpip` and sometimes getting 'invalid port'
and sometimes a device would start listening on a random port number.

The fix is to check the sscanf() return value for the success case (the
number of items successfully parsed), as is already done in other parts
of the adb code. I also fixed-up another instance of the same
code-pattern in services.c.

Change-Id: I8c9c33485ad076828da0ac74f048fdad561669d3
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-01-25 17:38:36 -08:00
David 'Digit' Turner
1bc38a4cdc Merge "adb: Fix 'adb forward --no-rebind'." 2015-01-23 16:45:46 +00:00
David 'Digit' Turner
f0e0c2e458 adb: Fix 'adb forward --no-rebind'.
Due to a typo, the --no-rebind option never worked (it always failed).
The root of the problem was that the client was sending on the wire
a command like:

  host:forward:norebind::tcp:<port>;tcp:<port>
                       ^^
Instead of:

  host:forward:norebind:tcp:<port>;tcp:<port>
                       ^

Note the erroneous double-column.

The fix is local to the adb client and thus doesn't require a new
version of the server or guest adbd on the device-side.

This also fixes 'adb reverse --no-rebind'.

See https://code.google.com/p/chromium/issues/detail?id=451109

Change-Id: I680fd432b5470072f6a9968ca32a7f90c600ac68
2015-01-23 10:02:58 +01:00
Riley Andrews
d83a9c55f4 Python unit test for adb.
Change-Id: I1b2b8004f47b708e6a1d6a4ad20816e7beb21a0f
2015-01-13 15:08:56 -08:00
Elliott Hughes
0a049b1d8d Clean up adb Win32 symlink #ifdefs.
Change-Id: I83ef30e82d820f91960c29f6b737e6e900caaca6
2015-01-12 17:00:09 -08:00
Yabin Cui
fdb3da5953 Merge "Use getmntent when accessing /proc/mounts." 2015-01-06 17:41:40 +00:00
Yabin Cui
d6bd9bf459 Use getmntent when accessing /proc/mounts.
Bug: 18887435
Change-Id: I6d7f95bbdb976428d4722bd640745e73c9839160
2015-01-05 20:28:36 -08:00
Sami Tolvanen
13449cd714 Fix disable-verity when the underlying block device is RO
If verity is enabled and the underlying block device is marked
read-only, disable-verity fails. We cannot use the existing code
for enable-verity to make the device writable as the device in
/proc/mounts will be the verity device instead of the underlying
device we want to change. This change makes the correct device
writable when altering verity state.

Change-Id: I423ee50fb34d78cff2fe843318b9081c03c5142d
2015-01-05 20:31:25 +00:00
Bernhard Rosenkränzer
2bd4124259 Fix build with clang
Remove 2 unused functions and 1 unused label in the
!ALLOW_ADBD_DISABLE_VERITY case

Change-Id: Id6b29f57bcb95e54f5a4014021d47d8ca6e4556e
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
2014-12-12 15:48:52 -08:00
Riley Andrews
4d04d24b9e fix memory leak in copy_remote_dir_local
Bug https://code.google.com/p/android/issues/detail?id=82436


Change-Id: I4bfa865638742e1b7cedd17f5b33dcc10c7f711c
2014-12-12 22:03:14 +00:00
Chih-Hung Hsieh
058932c4ff Remove unused local variable.
Clang compiler gives it a warning and error.

Change-Id: Id35b740e265b393b5e31e05bd83544f391d8ff08
2014-12-10 14:14:09 -08:00
Riley Andrews
98f58e83c0 Fix some style issues in adb_commandline().
Change-Id: I8ed7899e7e137405594b3f3cbb0a87eae411dfc9
2014-12-09 17:25:39 -08:00
Riley Andrews
c8514c886e Refactor the host adb argument parsing loop to remove a goto
Change-Id: I3412ac473abc4efa51a6275658e65f7191b5439d
2014-12-09 17:25:39 -08:00
Paul Lawrence
1d931bca26 Fix build
(cherry-pick of 731136ca36bb7af1490856373d463e3a6c4df1c8.)

Change-Id: I9b493fd5fc5c5f62f02bc5234ccca2a5118380b4
2014-12-09 17:06:00 -08:00
Paul Lawrence
982089d838 Add adb enable-verity
Note that it is *easy* to break your phone with this feature. It is
not a bug that reenabling verity after changing one byte of the system
partition stops the device booting.

(cherry-pick of 7c442e1700e6312727283db402dec6f666f1b55a.)

Bug: 18529433
Change-Id: I632e91281884471a362960f1ba30312d2669b8ff
2014-12-09 17:04:43 -08:00
Paul Lawrence
ec900bba20 Revert "Revert "Enable verity on userdebug, and add disable-verity to adb""
This reverts commit 152d2d4234.

Fixed build error, and also fixed memory leak spotted from warning.

(cherry-pick of bbb36319119edde9377fb80015235893c30d2bc9.)

Bug: 17691572
Change-Id: I23b5ba537f7b557432041d4338b38b9be434e981
2014-12-09 17:02:17 -08:00
Paul Lawrence
34637555c2 adb warns on remount when verity is enabled
(cherry-pick of f643beced1d154726dca7115014d2d1fdfcca993.)

Bug: 18119147
Change-Id: I75e5edf83fa01dbf2495e24df4597dce41f13654
2014-12-09 16:32:26 -08:00
Badhri Jagan Sridharan
ab3446dd34 adbd & fastbootd: Support for new f_fs descriptor format
The patch "[RFC] usb: gadget: f_fs: Add flags
to  descriptors block" marks the current
usb_functionfs_descs_head format deprecated
and introduces support for sending SuperSpeed
descriptors.

This CL makes adbd to send Descriptors in the
new format. Adbd would fall back to the old
format, if kernel is not able to recognize
the new format. This is done to prevent
adbd from breaking in the older versions
of the kernel.

(cherry-pick of fad60336daa5a7adf82d8140cbddd1c735770e71.)

Bug: 17394972
Change-Id: I05095ccdcc74bf6953cbef847d7583eab137e12e
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
2014-12-09 16:20:15 -08:00
leozwang
298b6c70a0 Fix build on mac.
On mac require a case.
Also, this code is not portable, will fix it in long run.

(cherry-pick of 0f1fda9ee80ba086e4c8960a7d153798e3cf3285.)

Change-Id: I76194b62cea29bd3d21c7ba6c3da4d549bea4738
2014-12-09 16:12:51 -08:00
leozwang
cbf0267f5b Add more debug information.
Re-commit https://googleplex-android-review.googlesource.com/#/c/519430/
Add fix for win_sdk build.

Add socketpair debug log.
Also output thread information in log on host side.

(cherry-pick of adb09fa01a16d8c5c92c2f8d325e1678c531223f.)

Change-Id: I21021bc111a3f7362a91b70593e3738125878118
2014-12-09 16:08:24 -08:00
Christopher Ferris
67a7a4ae27 Fix adb/fastboot windows compilations.
Many of the windows files where not including stdlib.h even though they
are using malloc/free calls.

(cherry-pick of ae7bf0959bd3f79afbf365e41f015ed1c304afdc.)

Change-Id: If6959df9909d9d9928e9f4a2a96018166361cf3c
2014-12-09 16:03:29 -08:00
Elliott Hughes
02ef15f1d7 Merge "Introduce "adb keygen"" 2014-12-10 00:01:06 +00:00
Elliott Hughes
dbb7c46d68 Merge "ADB on linux: Handle USB SuperSpeed extra Descriptors" 2014-12-08 22:35:41 +00:00
Nick Kralevich
bea3f9c345 Introduce "adb keygen"
Introduce the "adb keygen" command.

  Usage: adb keygen <filename>

This command creates an adb public/private key pair in a user
specified file. This can be used to create new adb keys, or rotate
existing keys.

Modify adb's key generation routines to use the HOSTNAME/LOGNAME
environment variables if available. This allows someone to override
the username/hostname embedded within the adb public key file if
desired. Fallback to the old mechanisms if those environment
variables aren't available.

Bug: 18342715
Change-Id: Ibccee6088d4609aa05ad6687d3a1d8a8689d3e8a

(cherry picked from commit af782b9f2a)

Change-Id: Ic76ffc9412171dddc879af0bbf6e20fbe1a8f057
2014-12-08 13:44:39 -08:00
Elliott Hughes
a5e9b065ef Merge "adb: enable superspeed support" 2014-12-08 19:23:30 +00:00
Zhuang Jin Can
d6ee9f26a5 adb: enable superspeed support
Change-Id: I5a350bfa5641365d7a0939d89c6f477c335e948a
Signed-off-by: Zhuang Jin Can <jin.can.zhuang@intel.com>
Signed-off-by: Robert Chiras <robert.chiras@intel.com>
2014-12-08 16:31:18 +02:00
Trevor Drake
b79a2d55f7 Clean up adb/Android.mk
Removed redundant LOCAL_C_INCLUDES.
Switch from using libunz to libz

Change-Id: Ic90c582fa56453bbac09561158e73f240dd47503
2014-12-07 15:13:29 +00:00
Elliott Hughes
023bc0a426 Merge "Fix deadlocks." 2014-12-03 18:38:05 +00:00
Elliott Hughes
97ac0e1bb4 Kill HAVE_BIG_ENDIAN, HAVE_ENDIAN_H, and HAVE_LITTLE_ENDIAN.
Change-Id: I9e25ac9d27e95b04fb8bf7a66c619af0139d8b8f
2014-11-21 23:10:45 -08:00
Ajay Dudani
8432ddc822 system/core: Remove AID_GRAPHICS from adb groups
Remove AID_GRAPHICS from adb access groups to limit framebuffer
access.

Change-Id: I7fc6dca8b02a45d67d1ecc4a4daf6c38741ffb94
2014-11-21 18:08:05 -08:00
Elliott Hughes
c66aed8a14 Remove the adb usb vendor id whitelist.
If there are bad vendors, we should blacklist them. Whitelisting the entire
world is crazy.

Change-Id: I1f4c27fd34fc420e2a3b4b2c8749198030db69f1
2014-11-21 10:44:10 -08:00
Elliott Hughes
97e1e17042 Merge "Disable vendor id filtering for OS X." 2014-11-21 18:42:28 +00:00
Elliott Hughes
0750f78659 Merge "Remove explict use of ASCII encoding" 2014-11-21 18:37:19 +00:00
Elliott Hughes
01d49e854f Merge "adb: Add USB vendor ID for Ubiquiti Networks, Inc." 2014-11-21 17:44:06 +00:00
Al Sutton
2a4b5f9e80 Remove explict use of ASCII encoding
Replace the use of CFStringGetCString with kCFStringEncodingASCII specified
with CFStringGetFileSystemRepresentation which will ensure the correct
character encoding is used to conver the CFString into a NULL terminated
char array suitable for use with POSIX APIs.

Change-Id: Ibab1dc05c4f4db8604d329a493b4241992b8e69d
2014-11-21 15:56:59 +00:00
Al Sutton
8e01cc6e0b Disable vendor id filtering for OS X.
Companion patch for change I2bf583a27f9a3f98ef006ea62b906a4f89960507.

Due to the use of USB class 0xff it's not possible to register a listener
which uses the OS methods for filtering notifications, so this patch
also introduces a check in the notification listener which checks the
class, subclass, and protocol for the interface each notification relates 
to.

Change-Id: I380cc80f96addc5057660efb2179b35f9378886a
2014-11-21 14:14:58 +00:00
Elliott Hughes
aa3e17e1b6 Merge "Return path including executable instead of without" 2014-11-20 18:35:12 +00:00
Al Sutton
26b53bb75e Return path including executable instead of without
The previous implementation returned the path the executable was in instead
of returning the path including the executable (i.e. it returned ...bin
instead of ...bin/executable). This is not what the original methods did
and caused the process forking of adb to fail.

This patch corrects the implementation.

Change-Id: Ib58497cab35706041f170c1bc97c31fd5d965f90
2014-11-20 13:33:57 +00:00
Elliott Hughes
55664906a8 Disable vendor id filtering for Linux.
It's time we switched to blacklisting any problematic devices rather than
slowly whitelisting the entire world. This seems to work for me, but let's
see how other people get on before coming back to actually remove the list.

We'll also need to find a Mac to test the equivalent Mac change.

Change-Id: I2bf583a27f9a3f98ef006ea62b906a4f89960507
2014-11-19 22:07:34 -08:00
Al Sutton
f456d47c50 Fix building on modern versions of Xcode and OS X.
Recent versions of XCode fail to compile the adb and fastboot binaries due to
two functions being deprecated in 10.9 (GetCurrentProcess and
ProcessInformationCopyDictionary), and the use of -Werrror.

This patch replaces the method implementations which use calls to methods
deprecated in the 10.9 SDK with versions which only call non-deprecated methods.

Change-Id: I855bf26aff45093ca9022924f3ecd1b80f2305a8
2014-11-19 19:50:48 +00:00
Jeremy Chang
868cf42557 adb: Add USB vendor ID for Ubiquiti Networks, Inc.
Change-Id: Iedb86b9ff8dc55aea5d0df201a98c96418002207
Signed-off-by: Jeremy Chang <jeremy@ubnt.com>
2014-11-19 22:13:24 +08:00
Elliott Hughes
0655d38b0c Merge "Revert "adb: Add USB vendor ID for Honeywell"" 2014-11-18 21:15:44 +00:00
Elliott Hughes
3e01bb85d6 Revert "adb: Add USB vendor ID for Honeywell"
This reverts commit 8c4c8e8988.

Change-Id: Ia1cad862f42e5bea3174ed2cc0eea5232fc0a858
2014-11-18 21:15:28 +00:00
Yabin Cui
d325e866c4 kill HAVE_TERMIO_H
Bug: 18398307
Change-Id: Idbb89a074cdf16869cae3f667e89472781f37a5f
2014-11-17 18:19:11 -08:00
Yabin Cui
e77b6a0862 kill HAVE_FORKEXEC
Bug: 18317407
Change-Id: I4eecb3c9d745e3dabfc46fa595aac7f94f6d93e3
2014-11-12 17:06:27 -08:00
Elliott Hughes
2655256570 am 452f08a0: Merge "Add razer usb vid for future use with adb"
* commit '452f08a0b78e65cbd7e4cddac133e59f94d5db4c':
  Add razer usb vid for future use with adb
2014-11-05 02:42:04 +00:00
Stuart Wells
3410d33dc4 Add razer usb vid for future use with adb
Change-Id: I6b76c297de900da050473b764517cfd15c64b838
Signed-off-by: Stuart Wells <stuart.wells@razerzone.com>
2014-11-03 09:32:30 -08:00
JP Abgrall
cb3739b545 am 7e38ab47: am 951c48c5: Merge "adb: Add USB vendor ID for TrekStor GmbH"
* commit '7e38ab476f808f84f0755ccbceb4cd7d8a1982a3':
  adb: Add USB vendor ID for TrekStor GmbH
2014-10-20 18:38:24 +00:00
Thorsten Koroscha
4fa99e542f adb: Add USB vendor ID for TrekStor GmbH
Change-Id: I1d7fc14e691b4ab504c5205b21c93939499cdff9
Signed-off-by: Thorsten Koroscha <t.koroscha@trekstor.de>
2014-10-20 10:26:20 +02:00
Stephen Hines
f17c42f68a am 2f431a8d: Fix windows-specific error without messing up Makefile flags.
* commit '2f431a8d5a1c2029af470a7336751a555131ee51':
  Fix windows-specific error without messing up Makefile flags.
2014-10-02 00:53:27 +00:00
Stephen Hines
2f431a8d5a Fix windows-specific error without messing up Makefile flags.
Bug: 14416410

The proper fix for the error/warning we encountered is to move winsock2.h
in front of windows.h.

Change-Id: I29504ba3a184a85c6636d06c2ad900828fdb5436
2014-10-01 17:37:06 -07:00
Stephen Hines
d2ee707586 am 3ea87c33: Fix build breakage for missing -Wcpp option on old GCC versions.
* commit '3ea87c33a1c6e940322f5436cf0dd70a0bdadd75':
  Fix build breakage for missing -Wcpp option on old GCC versions.
2014-10-02 00:31:50 +00:00
Stephen Hines
3ea87c33a1 Fix build breakage for missing -Wcpp option on old GCC versions.
Bug: 14416410
Change-Id: Ib30c3739d50d6122b3b4643051c72f2fa4985686
2014-10-01 17:16:37 -07:00
Stephen Hines
1e95e0b19c am 64f44b84: Merge "Remove obsolete reference to ddk; Fixes for -Werror" into lmp-dev
* commit '64f44b8444dabd69cf391d42e10d44e8e926a79d':
  Remove obsolete reference to ddk; Fixes for -Werror
2014-10-01 23:21:09 +00:00
Stephen Hines
64f44b8444 Merge "Remove obsolete reference to ddk; Fixes for -Werror" into lmp-dev 2014-10-01 22:53:51 +00:00
Vince Harron
43aecc5436 am c75dac39: Merge "fix for adbd pinning CPU" into lmp-dev
* commit 'c75dac394e3fcd9760841a820d8a0c93dd0c276e':
  fix for adbd pinning CPU
2014-09-30 14:56:25 +00:00
Andrew Hsieh
b75d6f1429 Remove obsolete reference to ddk; Fixes for -Werror
Bug: 14416410

1. The new mingw-w64 toolchain x86_64-w64-mingw32-4.8 has ddk
   in x86_64-w64-mingw32/include/ddk
2. Add -Wno-error=cpp to suppress a warning that turns into error
   thanks to -Werror:

      Please include winsock2.h before windows.h
3. Cast GetLastError() return type DWORD to "int"
4. Include direct.h for _mkdir
5. Include stdint.h for uint8_t on Windows

Change-Id: I4bec0587f6573692f08c760da6c98ae551b8b5eb
2014-09-30 02:24:07 -07:00
Alex Klyubin
1f88f8ef32 am 9005ec37: am e3d3016d: Merge "Switch from using base64 BIOs to encoding funcs."
* commit '9005ec378ecd281f52945b5baca87245543bbfbf':
  Switch from using base64 BIOs to encoding funcs.
2014-09-26 21:58:52 +00:00
Alex Klyubin
e3d3016d46 Merge "Switch from using base64 BIOs to encoding funcs." 2014-09-26 21:51:36 +00:00
Vince Harron
af436b1e10 fix for adbd pinning CPU
adbd was spinning between select & read (0 bytes) for an adb_auth
socket.  The read documentation states: "On success, the number of
bytes read is returned (zero indicates end of file)" so the code has
been modified to close the connection (like the read error case).

BUG=17419868

Change-Id: I1d8fb70c8e1876225ba8d47ea0a2b6265a7d182b
2014-09-25 21:51:15 -07:00
Dan Albert
736fd4a870 am 8e1e5415: am 5b4a1767: Merge "Revert "Switch adb to epoll(2).""
* commit '8e1e54154bc7a5e9dee206735474186c2276b111':
  Revert "Switch adb to epoll(2)."
2014-09-25 22:32:18 +00:00
Dan Albert
45741ae2ea Revert "Switch adb to epoll(2)."
This reverts commit 67de1557b0.
2014-09-25 15:10:34 -07:00
Elliott Hughes
0ab784d470 am 790e7c0a: am 3772545c: Merge "Switch adb to epoll(2)."
* commit '790e7c0ac46bca5ad511ba8764bbb0e9646c6f2a':
  Switch adb to epoll(2).
2014-09-23 18:57:33 +00:00
Elliott Hughes
67de1557b0 Switch adb to epoll(2).
Bug: 17588403
Change-Id: I2590f5e7dd4e178ff4f743609c5ef0155b1015a1
2014-09-23 10:40:51 -07:00
Doug Zongker
edda73d0c8 fix windows build
(cherry-picked from commit 4b39c6aca9)

Change-Id: Ia7b236f1a915630fe85d488072efb9784ba10dad
2014-09-16 10:59:49 -07:00
Kenny Root
d372c5c365 Merge changes I11e84a7b,I5adaedd8
* changes:
  adb: fix 64-bit build
  add sideload-host mode to adb
2014-09-16 17:36:13 +00:00
Colin Cross
52e0b61999 adb: fix 64-bit build
strlen returns a size_t, but the * modifier in printf expects an int.
On arm64 size_t != int.

(cherry-picked from commit 6d6a898b0c)

Change-Id: I11e84a7b62c935162abc0aba910d14e63d11efd3
2014-09-16 10:31:30 -07:00
Doug Zongker
8e49ae4bb8 add sideload-host mode to adb
The sideload-host mode turns the host into a server capable of sending
the device various pieces of the file on request, rather than
downloading it all in one transfer.  It's used to support sideloading
OTA packages to devices without the need for them to hold the whole
package in RAM.

If the connected device doesn't support sideload-host mode, we fall
back to the older sideload connection.

(cherry-picked from commit 71fe584a1a)

Change-Id: I5adaedd8243dc3b76414bba0149879ca2bbf35fa
2014-09-16 10:27:38 -07:00
Esteban de la Canal
a5ab96eb50 74602: Fixes adb not seeing connected devices on Mac.
Every alternate time an adb server was started already connected devices were
not being seen. This was caused by opened usb connections being "stalled".
See this thread for more information: http://lists.apple.com/archives/usb/2011/Jun/msg00050.html

Change-Id: Ic35b7a66c3f14a837b960066557f44e105609dcb
Fixes: https://code.google.com/p/android/issues/detail?id=74602
2014-09-15 15:46:13 -07:00
Esteban de la Canal
da5b2d67fa am 99bb69c1: am f41ee3d5: Merge "74602: Fixes adb not seeing connected devices on Mac."
* commit '99bb69c1cee678382bf5e48962aa444469b3310e':
  74602: Fixes adb not seeing connected devices on Mac.
2014-09-12 21:43:43 +00:00
Esteban de la Canal
f41ee3d5a1 Merge "74602: Fixes adb not seeing connected devices on Mac." 2014-09-12 21:11:14 +00:00
Esteban de la Canal
9dd83dc96e 74602: Fixes adb not seeing connected devices on Mac.
Every alternate time an adb server was started already connected devices were
not being seen. This was caused by opened usb connections being "stalled".
See this thread for more information: http://lists.apple.com/archives/usb/2011/Jun/msg00050.html

Change-Id: Ic35b7a66c3f14a837b960066557f44e105609dcb
Fixes: https://code.google.com/p/android/issues/detail?id=74602
2014-09-11 11:36:50 -07:00
Elliott Hughes
8fa75e44f1 am 6608a46c: am c4ff0389: Merge "adb: Add USB vendor ID for Alco Digital Devices Limited"
* commit '6608a46c59abd72bd42a5104937fb276b6b0ccbd':
  adb: Add USB vendor ID for Alco Digital Devices Limited
2014-09-10 18:26:35 +00:00
DanielMo
553630e423 adb: Add USB vendor ID for Alco Digital Devices Limited
Change-Id: I50d343d583e688e9f8a72d1c61618b384e310fe1
Signed-off-by: DanielMo <DanielMo@fih-foxconn.com>
2014-09-10 13:58:32 +08:00
Jeff Sharkey
84e533d7b0 am 228f8261: Merge "delete_file() should force removal." into lmp-dev
* commit '228f8261fd778e1c03184b5f79f979d1a25abf50':
  delete_file() should force removal.
2014-09-09 21:56:14 +00:00
Jeff Sharkey
41b3cfa296 delete_file() should force removal.
It's a shell command with a pty, but it's not really interactive,
so force the removal to avoid giving users dead-end prompts.

Bug: 17339227
Change-Id: Iaf5d95c49f032066aa741a711a2c45557d93c598
2014-09-09 12:38:30 -07:00
Christopher Ferris
fb849bd46e am fc8e16bf: am 2c805883: Merge "Add -Wno-deprecated-declarations to makefiles."
* commit 'fc8e16bfc59fcebaf554e266aae808eed5f2d078':
  Add -Wno-deprecated-declarations to makefiles.
2014-09-06 17:25:48 +00:00
Christopher Ferris
2c80588340 Merge "Add -Wno-deprecated-declarations to makefiles." 2014-09-06 16:56:46 +00:00
Chih-Hung Hsieh
6d94763b2f am 379ca94d: am 299a32c8: Merge "Include ADB_HOST only code in #if ADB_HOST."
* commit '379ca94d00cab91a77ad8991cc92e2b4d4236d56':
  Include ADB_HOST only code in #if ADB_HOST.
2014-09-05 23:58:09 +00:00
Chih-Hung Hsieh
299a32c803 Merge "Include ADB_HOST only code in #if ADB_HOST." 2014-09-05 23:38:07 +00:00
Chih-Hung Hsieh
f787b381b6 Include ADB_HOST only code in #if ADB_HOST.
BUG: 17409892
Change-Id: Ic1199dd745191aba718fdb18343e87c0ccbe530b
2014-09-05 16:34:02 -07:00
Elliott Hughes
709569febf am 0dcc3f65: am 9c814648: Merge "Add USB Vendor ID for Micromax Informatics Ltd."
* commit '0dcc3f65b1ff5fa771618436ee4bfdd44cd2f672':
  Add USB Vendor ID for Micromax Informatics Ltd.
2014-09-05 23:31:15 +00:00
Abhishek Karmakar
4d10523be8 Add USB Vendor ID for Micromax Informatics Ltd.
Signed-off-by: Abhishek Karmakar <abhishek.karmakar@micromaxinfo.com>
Change-Id: I63462eb15575cc953ac0246ee5d4c883d3678c08
2014-09-05 16:06:25 -07:00
Adam Langley
179d9d6587 Switch from using base64 BIOs to encoding funcs.
The OpenSSL base64 BIO is going away in BoringSSL. This change switches
to using the explicit base64 functions which are availible in both
OpenSSL and BoringSSL. The BoringSSL helper functions (i.e. for
calculating the size of the base64 encoding) are wrapped in #ifdefs so
that this change isn't coupled with the switch to BoringSSL. Once that
switch is complete, the #ifdefs can be removed.

Bug: 17409664
Change-Id: I42bac3bc93a1fb39feed39a8917d8e38d97629d3
Signed-off-by: Adam Langley <agl@google.com>
2014-09-05 15:54:30 -07:00
Christopher Ferris
51448eb39e Add -Wno-deprecated-declarations to makefiles.
This is in preparation for an update to the uapi v3.16.1
kernel headers that marks the structure usb_functionfs_descs_head
as deprecated.

Change-Id: I25d2f32ce8e95e038e6df201ce2f8126f5a8b6fa
2014-09-04 16:13:42 -07:00
Ying Wang
0c3d98b02b am 87ad7cdc: am e1ba39aa: Merge "Fix 64-bit host build."
* commit '87ad7cdc590aa4033f0b7ae23d83e2fbc119d07a':
  Fix 64-bit host build.
2014-08-14 23:20:06 +00:00
Ying Wang
42a809ba06 Fix 64-bit host build.
Bug: 13751317
Change-Id: Ibf62935b7d12a55ffc57242a26a2581b52796847
2014-08-14 15:52:54 -07:00
Elliott Hughes
e772705a59 am 771f6f29: am 29c5a78f: Merge "Fix build of adb with gcc-4.9."
* commit '771f6f299f16704b251d6adb8fb185c8fb517d07':
  Fix build of adb with gcc-4.9.
2014-08-06 18:06:33 +00:00
Alexander Ivchenko
678bd2e822 Fix build of adb with gcc-4.9.
Without this patch we get:

system/core/adb/commandline.c:1629:16: error: array subscript is above
array bounds [-Werror=array-bounds]

Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>

(cherry picked from commit 5372333885)

Change-Id: I920c1de933ce5ba0a0d57eb8a9b557325a767a2a
2014-08-06 10:59:53 -07:00
Brian Carlstrom
8a01917da1 am 46a8ffe8: Fix Windows adb build by avoiding "bool"
* commit '46a8ffe87f3cba070fb18a90e3c5c1f73468f99c':
  Fix Windows adb build by avoiding "bool"
2014-08-06 12:57:22 +00:00
Brian Carlstrom
46a8ffe87f Fix Windows adb build by avoiding "bool"
Change-Id: I9ca59e400c199d497a1a18d5e64c2cafe628097b
2014-08-05 22:51:18 -07:00
Jeff Sharkey
8c9b155ea1 am 43d65b69: Merge "Escape single quotes in arguments." into lmp-dev
* commit '43d65b6903249a409031b081bb6175b9ad3e5c2a':
  Escape single quotes in arguments.
2014-08-06 01:23:28 +00:00
Elliott Hughes
440df7b61f am 830a8641: am a8d0c4a2: Merge "Move host \'get-state\' service up so that it works."
* commit '830a8641bb960d208ad2a5b3bc3d9fb91bc31c2b':
  Move host 'get-state' service up so that it works.
2014-08-06 01:22:09 +00:00
Elliott Hughes
29c5a78fdc Merge "Fix build of adb with gcc-4.9." 2014-08-05 00:30:25 +00:00
Alexander Ivchenko
5372333885 Fix build of adb with gcc-4.9.
Without this patch we get:

system/core/adb/commandline.c:1629:16: error: array subscript is above
array bounds [-Werror=array-bounds]

Change-Id: I494eb8b4d0e8082f8ff57bdd33d8d46c8c481c6f
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
2014-08-06 16:07:17 +04:00
Elliott Hughes
a8d0c4a2b8 Merge "Move host 'get-state' service up so that it works." 2014-08-05 00:30:25 +00:00
Jeff Sharkey
0cc642c82d Partially revert argument escaping.
Commands chained with && need to be passed through literally instead
of always being quoted.

(cherry-pick of 7c460351f53cb683097fe4071b9ec1e4cd7cdf82.)

Bug: 15479704
Change-Id: I2998e40a92a3bfd092098cd526403b469c86c9a6
2014-08-05 22:55:39 +00:00
Jeff Sharkey
dcd2f0ef2f Uniformly escape shell arguments.
Arguments with embedded spaces need to be wrapped in quotes, which
changes the overall escaping strategy.  Instead of mixing the two
strategies, just always wrap arguments in quotes.

(cherry-pick of fd546e8c35341b518873eb4f883afbed92e947af.)

Bug: 15479704
Change-Id: I03eacfa1bd6c220d4ec6617b825ebb0c43c7221e
2014-08-05 22:54:35 +00:00
Jeff Sharkey
43d65b6903 Merge "Escape single quotes in arguments." into lmp-dev 2014-08-05 00:19:02 +00:00
Simon Ye
d9c4b14b44 Move host 'get-state' service up so that it works.
Due to previous bad merge, the get-state service was moved out of the
ADB_HOST #ifdef block.

(cherry picked from commit dc22c3c7a8)

Change-Id: I08465e7c666104a4c2d15eadef8a4d4be7f91456
2014-08-05 17:23:35 -07:00
Jeff Sharkey
d0eee747f6 Escape single quotes in arguments.
Verified that these use-cases continue working:

$ adb shell arg a a 'b b'
$ adb shell arg a a "b b"
|arg|a|a|b b|

$ adb shell arg "a a 'b b'"
|arg|a a 'b b'|

$ adb shell arg 'a a "b b"'
|arg|a a "b b"|

$ adb shell arg a\"b\'c
|arg|a"b'c|

$ adb shell "arg a && arg b"
|arg|a|
|arg|b|

$ adb shell "arg 'a' \"b\" c"
|arg|a|b|c|

Bug: 16139781
Change-Id: I3b010b6cdf57281695c11fda318c9bea0a7221cc
2014-08-05 16:53:25 -07:00
leozwang
05004026d9 am a361503e: Merge "Consolidate adb trace macro defines into its own header file." into lmp-dev
* commit 'a361503e3e68d1b26ce737547c4e1d53a03ec2d9':
  Consolidate adb trace macro defines into its own header file.
2014-07-30 16:44:52 +00:00
Elliott Hughes
43eb2ea5f8 am ec531e5c: am 47a12389: Merge "Fix adb "ptsname is not thread-safe; use ptsname_r instead" build break."
* commit 'ec531e5cdde5e0b120bd88aeb2c3d36d18cedfb4':
  Fix adb "ptsname is not thread-safe; use ptsname_r instead" build break.
2014-07-29 18:42:53 +00:00
Simon Ye
dc22c3c7a8 Move host 'get-state' service up so that it works.
Due to previous bad merge, the get-state service was moved out of the
ADB_HOST #ifdef block.

Change-Id: Id4b72a051ff04104659925e63a02eb340db2f807
2014-07-28 11:44:46 -07:00
Elliott Hughes
d235288553 Fix adb "ptsname is not thread-safe; use ptsname_r instead" build break.
Change-Id: I633dc4d6d421862473e7267cc0d2c1b0933392e0
2014-07-29 11:32:16 -07:00
leozwang
a361503e3e Merge "Consolidate adb trace macro defines into its own header file." into lmp-dev 2014-07-25 21:16:23 +00:00
leozwang
d3fc15f484 Consolidate adb trace macro defines into its own header file.
Most code is copied and pasted from adb.h.
Any file can just include it to enable tracing.
Removed some duplications.

Change-Id: Ie1ed9e9edbf92158aac84669fbcbf7dc85fe2cf0
2014-07-29 14:07:46 -07:00
Elliott Hughes
a6ff5c95a3 Fix adb "ptsname is not thread-safe; use ptsname_r instead" build break.
(cherry picked from commit d235288553)

Change-Id: I05f8160bc8c356cb8a57e2bc5677517750700456
2014-07-29 11:34:14 -07:00
Jeff Sharkey
555a904f7c am 74ff4fcf: Merge "Follow refactoring of install-abandon command." into lmp-dev
* commit '74ff4fcfc46e853ecd9fe34b5cedb47fc379f1af':
  Follow refactoring of install-abandon command.
2014-07-25 19:19:33 +00:00
leozwang
75619aabb3 am 5a255238: Merge "Redirect debug output to logcat." into lmp-dev
* commit '5a2552388e698fec4efda270d2d88bb18ed3f299':
  Redirect debug output to logcat.
2014-07-25 16:45:39 +00:00
Colin Cross
6cc961c7cb am edf41f98: am 8d9d362b: Merge "adb: Add USB vendor ID for SONIM TECHNOLOGIES, INC."
* commit 'edf41f981c47d857bd130e8ecc95cd7cf0a0fe0a':
  adb: Add USB vendor ID for SONIM TECHNOLOGIES, INC.
2014-07-25 03:39:11 +00:00
Tim Murray
2cc4fd73d1 am 6ebaf311: am 721f189a: Merge "fix adb build on Darwin"
* commit '6ebaf311a7af8d20979deba279f9d5096ed8f193':
  fix adb build on Darwin
2014-07-25 02:24:29 +00:00
DanielMo
43222b3f0a adb: Add USB vendor ID for SONIM TECHNOLOGIES, INC.
Change-Id: Id66997709fec55b1efd389abf2efa644b9a8ccf4
Signed-off-by: DanielMo <DanielMo@fih-foxconn.com>
2014-07-25 11:17:55 +08:00
leozwang
5a2552388e Merge "Redirect debug output to logcat." into lmp-dev 2014-07-24 22:43:15 +00:00
Tim Murray
1efcdeffe5 fix adb build on Darwin
bug 16172793

Change-Id: Ia34b7148afc4c909f29037df91c04d6fd29a731e
2014-07-24 18:33:12 -07:00
Jeff Sharkey
ac77e1f4e4 Follow refactoring of install-abandon command.
Bug: 16543552
Change-Id: I1f54254813fd7d7f4341b8815f816535a39de079
2014-07-25 10:09:18 -07:00
leozwang
48a904240b Redirect debug output to logcat.
If ADB_TRACE is enabled, debug output will be redirected to logcat.

Change-Id: I9c36ada7690a2b946ecd6a926d04e36a8313c36a
2014-07-23 22:45:02 -07:00
Nick Kralevich
9866a66d6d adb: set O_CLOEXEC on lots of file descriptors
Too many leaking FDs.

Fixes bug: https://code.google.com/p/android/issues/detail?id=65857
(and more)

(cherrypicked from commit fe8d7f4f2e)

Change-Id: I67d8683244e54288a8105f6f65ee40abe2378d7e
2014-07-21 19:34:31 -07:00
Greg Hackmann
7046773595 adb: replace utimes() with utime()
Fix the win_sdk host build by replacing utimes() with utime().  utime()
is functionally equivalent to utimes() when dealing with non-fractional
second timestamps, and is supported by the Windows CRT.

(The Windows CRT uses the nonstandard name _utime(), but mingw creates
aliases to the POSIX names.)

Change-Id: I513c6c5de05376c34cbb0894a94259acba8ae6f1
2014-07-21 17:10:34 -07:00
Nick Kralevich
ef16a17afb Merge "adb: set O_CLOEXEC on lots of file descriptors" into lmp-dev 2014-07-21 15:42:19 +00:00
Rom Lemarchand
1b3f2ff028 adb: use oom_score_adj instead of oom_adj
(cherry picked from commit 07ce7cab72)

Change-Id: I1730d1df34039a5502200002ac813ce96a3eaa1a
2014-07-18 21:55:38 -07:00
Jeff Sharkey
eb97987332 Add "exec" service: shell commands with no pty.
To facilitate device scripts that want to read/write binary data from
the host side, this change introduces a new "exec" service that
behaves like "shell" but without creating a pty, which would otherwise
mangle binary data.

After forking, it hooks up stdin/stdout of the child process to
the socket connected through to the host.  The adb transport doesn't
support shutdown(), so the host can't half-close the socket and wait
for device termination.  Instead, the host side now has two explicit
commands "exec-in" and "exec-out" for either sending or receiving
data.

Teach host side copy_to_file() to deal with stdin/stdout special
cases.  Switch device side backup/restore services to use the new
create_subproc_raw under the hood.

(cherry picked from commit 5d9d434efa)

Change-Id: I42c18cb5bb907449b458c94450ef6c584d84ecdb
2014-07-18 21:46:23 -07:00
Lajos Molnar
4b35c01e3e adb: added support for adb pull -a to preserve time stamps and mode
Added -a flag to adb pull that preserves time and mode.  Mode is
subjected to umask for security.  We only receive modification
time from adb server, so creation time will be set to the modification
time as well.

Signed-off-by: Lajos Molnar <lajos@google.com>

(cherry picked from commit de8ff4adca)

Change-Id: I03bb5cc14ce542299cf3b221a8be318a28ee8a8d
2014-07-18 21:46:18 -07:00
Nick Kralevich
fe8d7f4f2e adb: set O_CLOEXEC on lots of file descriptors
Too many leaking FDs.

Fixes bug: https://code.google.com/p/android/issues/detail?id=65857
(and more)

Change-Id: I67d8683244e54288a8105f6f65ee40abe2378d7e
2014-07-18 20:57:35 -07:00
Elliott Hughes
cbbb83b0eb Fix implicit declaration of function 'prctl' in adb.
(cherry picked from commit b4dd6ef223)

Change-Id: Ia64bec746ae8d2c45663f61afb46702838b1e5bf
2014-07-18 16:46:39 -07:00
Elliott Hughes
b4dd6ef223 Fix implicit declaration of function 'prctl' in adb.
Change-Id: I9f14cabbb36d658510c11833b3314565a2445e10
2014-07-18 16:44:58 -07:00
Christopher Tate
71bbc6789f Fix the build in clang
"fprintf(stderr, buf)" is a warning in some compilers, and we're
building with all warnings promoted to error.

Change-Id: Ie3c6ddcd74cf4dda40cf7b742df955dde1d1a5ff
2014-07-14 16:53:57 -07:00
Jeff Sharkey
c03064ea71 Fix 64-bit builds.
Change-Id: I1ff5c9c3dc8d870aef2885f8a1989c6c913ccb3d
2014-07-14 13:57:54 -07:00
Jeff Sharkey
960df97c23 Add install-multiple to adb.
The new install-multiple command automates creating an install
session, streaming multiple files into place, and then committing
or destroying the session.  This uses the recent "exec" feature to
stream APK contents over stdin directly into their final resting
place, requiring no extra copies.

Blindly pass through command line arguments to "pm" to make adding
new flags easier in future.

Remove support for verifying APK before sending across wire, since it
was reading the entire APK into memory (!) before sending.  Also
remove encrypted APKs, since they are no longer supported.  Drop
support for undocumented verification files.

Bug: 14975160
Change-Id: I0c538471873061798160e2e47cec4c0424c27361
2014-07-14 10:26:21 -07:00
Badhri Jagan Sridharan
77a2c22dcb Merge "adbd: adb root should terminate adbd only if it's debuggable" 2014-07-09 21:40:17 +00:00
Badhri Jagan Sridharan
bf9ef51969 am cb7be1e8: am 87c7a0d7: am 77a2c22d: Merge "adbd: adb root should terminate adbd only if it\'s debuggable"
* commit 'cb7be1e8cd4e4388d014a5c48df455a5715f2180':
  adbd: adb root should terminate adbd only if it's debuggable
2014-07-10 00:49:56 +00:00
Badhri Jagan Sridharan
cb7be1e8cd am 87c7a0d7: am 77a2c22d: Merge "adbd: adb root should terminate adbd only if it\'s debuggable"
* commit '87c7a0d74b9dadaedfe6805c57d221d9c445aaf6':
  adbd: adb root should terminate adbd only if it's debuggable
2014-07-10 00:16:15 +00:00
Doug Zongker
4b39c6aca9 fix windows build
Change-Id: Ia7b236f1a915630fe85d488072efb9784ba10dad
2014-07-07 15:28:58 -07:00
Colin Cross
6d6a898b0c adb: fix 64-bit build
strlen returns a size_t, but the * modifier in printf expects an int.
On arm64 size_t != int.

Change-Id: I11e84a7b62c935162abc0aba910d14e63d11efd3
2014-07-07 14:13:30 -07:00
Doug Zongker
7df14ef339 Merge "add sideload-host mode to adb" 2014-07-07 17:47:39 +00:00
Doug Zongker
71fe584a1a add sideload-host mode to adb
The sideload-host mode turns the host into a server capable of sending
the device various pieces of the file on request, rather than
downloading it all in one transfer.  It's used to support sideloading
OTA packages to devices without the need for them to hold the whole
package in RAM.

If the connected device doesn't support sideload-host mode, we fall
back to the older sideload connection.

Change-Id: I5adaedd8243dc3b76414bba0149879ca2bbf35fa
2014-07-07 07:51:58 -07:00
Daniel Rosenberg
686bce6390 Added support for vendor partition to adb
Remount will now remount the vendor partition as well, if it exists.
Sync will also allow you to sync vendor, and will include it by
default if it exists.

Change-Id: Iea1e8212f445e96233438a8d8a9d3266bf3d6557
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-07-02 20:00:49 +00:00
Elliott Hughes
ce10b191c5 am f6d86d75: am d08b80cc: am 20bda70f: Merge "Add Smartisan usb config"
* commit 'f6d86d75461ae3a246522932759e045dcc7a4952':
  Add Smartisan usb config
2014-06-24 19:38:50 +00:00
Elliott Hughes
f6d86d7546 am d08b80cc: am 20bda70f: Merge "Add Smartisan usb config"
* commit 'd08b80ccc6f7d106a8bfc410f89e466b798e2ebe':
  Add Smartisan usb config
2014-06-24 19:35:21 +00:00
Elliott Hughes
20bda70f9a Merge "Add Smartisan usb config" 2014-06-23 21:50:22 +00:00
Rom Lemarchand
07ce7cab72 adb: use oom_score_adj instead of oom_adj
Change-Id: I76c6ce83d7d400c8b84bfece5d30189640cb2505
2014-06-20 23:40:18 +00:00
Colin Cross
b10fb88e1e am d7d9b6fc: am f02fd9f0: am 5e504a4e: Merge "adb: Add USB vendor ID for Honeywell"
* commit 'd7d9b6fcaa415ea6251e45d84b95a95740ea807e':
  adb: Add USB vendor ID for Honeywell
2014-06-19 15:48:25 +00:00
Colin Cross
d7d9b6fcaa am f02fd9f0: am 5e504a4e: Merge "adb: Add USB vendor ID for Honeywell"
* commit 'f02fd9f0b061d29bb872664479ed4a5949d23ac9':
  adb: Add USB vendor ID for Honeywell
2014-06-19 15:44:14 +00:00
DanielMo
8c4c8e8988 adb: Add USB vendor ID for Honeywell
Change-Id: Ib92eca23a6c75ec9323bb1b0e7d7f8cd5f9ca207
Signed-off-by: DanielMo <DanielMo@fih-foxconn.com>
2014-06-19 16:02:14 +08:00
Nick Kralevich
4224edf51d am 89e4fad0: am 4e6aa6a2: Merge "adbd: unconditionally call setgroups"
* commit '89e4fad09e1ae765ab0be1580a468bc0837ef7e4':
  adbd: unconditionally call setgroups
2014-06-18 20:07:54 +00:00
Nick Kralevich
000a62f644 am 4224edf5: am 89e4fad0: am 4e6aa6a2: Merge "adbd: unconditionally call setgroups"
* commit '4224edf51dcddf9e014b198bb23fc40ef61a5834':
  adbd: unconditionally call setgroups
2014-06-18 21:40:27 +00:00
Nick Kralevich
e5cbf4e044 adbd: unconditionally call setgroups
We should ensure that the appropriate supplementary groups are
set, regardless of whether we're running UID=0 or UID=shell.

Change-Id: I3a1624a574102be08176a41f9c7eb5f82af2b3e5
2014-06-18 11:24:27 -07:00
Elliott Hughes
def14fc4ed am cd0d5935: am 6c65cd5d: am 60218f19: Merge "Add gionee USB vendor id."
* commit 'cd0d593569d7f2b8f8ec81ab3ef6dd942230e973':
  Add gionee USB vendor id.
2014-06-16 18:11:41 +00:00
Elliott Hughes
cd0d593569 am 6c65cd5d: am 60218f19: Merge "Add gionee USB vendor id."
* commit '6c65cd5db84361c66983903638ddb251762f9151':
  Add gionee USB vendor id.
2014-06-16 17:41:49 +00:00
xuefeng cai
4f8d3be3b2 Add gionee USB vendor id.
Change-Id: I3745f0e8462d0bffcd2eb4d926a9d2f9af8578f9
2014-06-16 17:29:42 +00:00
Jeff Sharkey
7c460351f5 Partially revert argument escaping.
Commands chained with && need to be passed through literally instead
of always being quoted.

Bug: 15479704
Change-Id: I2998e40a92a3bfd092098cd526403b469c86c9a6
2014-06-11 08:40:58 -07:00
Jeff Sharkey
fd546e8c35 Uniformly escape shell arguments.
Arguments with embedded spaces need to be wrapped in quotes, which
changes the overall escaping strategy.  Instead of mixing the two
strategies, just always wrap arguments in quotes.

Bug: 15479704
Change-Id: I03eacfa1bd6c220d4ec6617b825ebb0c43c7221e
2014-06-10 12:28:32 -07:00
Nick Kralevich
5c70f7e310 am f3af14e6: am ef47eb19: am 30136150: Merge "adb: avoid leaking file descriptors"
* commit 'f3af14e6df266f466e0bf7868d002cfe8104c128':
  adb: avoid leaking file descriptors
2014-06-07 00:19:51 +00:00
Nick Kralevich
f3af14e6df am ef47eb19: am 30136150: Merge "adb: avoid leaking file descriptors"
* commit 'ef47eb1948ba394866f53c41c459561fc372a3b5':
  adb: avoid leaking file descriptors
2014-06-07 00:16:32 +00:00
Nick Kralevich
8fcb631389 adb: avoid leaking file descriptors
If an adb shell connection comes in while taking a screenshot,
an open pipe file descriptor will be leaked to the shell process.
This causes SELinux denials of the form:

  avc: denied { read } for path="pipe:[21838]" dev="pipefs" ino=21838 scontext=u:r:shell:s0 tcontext=u:r:adbd:s0 tclass=fifo_file permissive=0
  avc: denied { write } for path="pipe:[21838]" dev="pipefs" ino=21838 scontext=u:r:shell:s0 tcontext=u:r:adbd:s0 tclass=fifo_file permissive=0

Set O_CLOEXEC on the pipe connections, to avoid leaking them
across an exec boundary.

Bug: 15437785
Change-Id: Id2304b316bd7082d8baac246dce1f0e0e26e9197
2014-06-05 20:26:25 -07:00
Narayan Kamath
8f4ac8e1d3 am 7cf8e1cb: am 4e26c95a: Merge "Skip the "--abi" flag on "adb install" if present."
* commit '7cf8e1cb88c44963ccb2128113d8a804d85645b9':
  Skip the "--abi" flag on "adb install" if present.
2014-06-03 13:58:44 +00:00
Narayan Kamath
7cf8e1cb88 am 4e26c95a: Merge "Skip the "--abi" flag on "adb install" if present."
* commit '4e26c95a6363da4885bb9178c9d42c273b357043':
  Skip the "--abi" flag on "adb install" if present.
2014-06-03 13:29:03 +00:00
Narayan Kamath
4e26c95a63 Merge "Skip the "--abi" flag on "adb install" if present." 2014-06-03 09:58:24 +00:00
Jeff Sharkey
b81708146f Merge "Add "exec" service: shell commands with no pty." 2014-06-02 16:54:23 +00:00
Jeff Sharkey
5d9d434efa Add "exec" service: shell commands with no pty.
To facilitate device scripts that want to read/write binary data from
the host side, this change introduces a new "exec" service that
behaves like "shell" but without creating a pty, which would otherwise
mangle binary data.

After forking, it hooks up stdin/stdout of the child process to
the socket connected through to the host.  The adb transport doesn't
support shutdown(), so the host can't half-close the socket and wait
for device termination.  Instead, the host side now has two explicit
commands "exec-in" and "exec-out" for either sending or receiving
data.

Teach host side copy_to_file() to deal with stdin/stdout special
cases.  Switch device side backup/restore services to use the new
create_subproc_raw under the hood.

Change-Id: I5993049803519d3959761f2363037b02c50920ee
2014-05-30 11:27:56 -07:00
Narayan Kamath
a284f8b214 Skip the "--abi" flag on "adb install" if present.
This flag needs to be passed through to the package manager.
Without this change, the argument to this flag is interpreted
as a filename.

NOTE: If we don't want to add special treatment for this flag,
we'll have to assume that all flags with a -- prefix have an
argument, and that isn't necessarily true.

Change-Id: I78c3fa842bc24148d83d7278e6dee395686240a0
2014-05-29 15:54:10 +01:00
Elliott Hughes
bccac026e9 am 8ed26bd6: am 769db021: am b24085d5: Merge "adb: Add USB vendor ID for Unowhy"
* commit '8ed26bd6531a8d52dcaff6c14b6fc59749791679':
  adb: Add USB vendor ID for Unowhy
2014-05-27 21:49:02 +00:00
Elliott Hughes
8ed26bd653 am 769db021: am b24085d5: Merge "adb: Add USB vendor ID for Unowhy"
* commit '769db021e6b61d10c13a7b17a72750f18ebdee16':
  adb: Add USB vendor ID for Unowhy
2014-05-27 21:32:01 +00:00
Elliott Hughes
769db021e6 am b24085d5: Merge "adb: Add USB vendor ID for Unowhy"
* commit 'b24085d55b082d802eba699243dba26fbc6ac712':
  adb: Add USB vendor ID for Unowhy
2014-05-27 21:29:15 +00:00
Wing Tseng
56266c75e2 adb: Add USB vendor ID for Unowhy
Change-Id: I8bab07734d5b6acb4d8ceaf45b0bab0723f5fe03
Signed-off-by: Wing Tseng <Wing_Tseng@pegatroncorp.com>
2014-05-27 14:23:11 -07:00
David 'Digit' Turner
7291ac6082 am 97267755: am c3358875: am 6e7343b8: Merge "adb: implement "adb reverse <local> <remote>""
* commit '972677557bd2c3a0678a945765783e85c7ec7b9c':
  adb: implement "adb reverse <local> <remote>"
2014-05-27 16:43:45 +00:00
David 'Digit' Turner
972677557b am c3358875: am 6e7343b8: Merge "adb: implement "adb reverse <local> <remote>""
* commit 'c3358875169b920847a72428f4e8b8f09f7bdf05':
  adb: implement "adb reverse <local> <remote>"
2014-05-27 16:36:30 +00:00
David 'Digit' Turner
c335887516 am 6e7343b8: Merge "adb: implement "adb reverse <local> <remote>""
* commit '6e7343b8993fecb2f0600a9e5cff91dd4480a877':
  adb: implement "adb reverse <local> <remote>"
2014-05-27 16:33:16 +00:00
David 'Digit' Turner
2525869419 adb: implement "adb reverse <local> <remote>"
This implements the logical opposite of 'adb forward', i.e.
the ability to reverse network connections from the device
to the host.

This feature is very useful for testing various programs
running on an Android device without root or poking at the
host's routing table.

Options and parameters are exactly the same as those for
'adb forward', except that the direction is reversed.

Examples:

  adb reverse tcp:5000 tcp:6000
    connections to localhost:5000 on the device will be
    forwarded to localhost:6000 on the host.

  adb reverse --no-rebind tcp:5000 tcp:6000
    same as above, but fails if the socket is already
    bound through a previous 'adb reverse tcp:5000 ...'
    command.

  adb reverse --list
    list all active reversed connections for the target
    device. Note: there is no command to list all
    reversed connections for all devices at once.

  adb reverse --remove tcp:5000
    remove any reversed connection on the device from
    localhost:5000

  adb reverse --remove-all
    remove all reversed connections form the current
    device.

Reversed connections are tied to a transport, in other
words, they disappear as soon as a device is disconnected.

Simple testing protocol:

  adb forward tcp:5000 tcp:6000
  adb reverse tcp:6000 tcp:7000
  nc -l localhost 7000

in another terminal:
  echo "Hello" | nc localhost 5000

Will print "Hello" on the first terminal.

Change-Id: I761af790cdb06829b68430afa4145a919fa0e6d5
2014-05-27 16:42:13 +02:00
Colin Cross
6fb1557fda am b696bec3: am 28c30518: am 1742b7d2: Merge "Modify VID for Compal"
* commit 'b696bec3541dc3091fb7c8764750f8ba21f64636':
  Modify VID for Compal
2014-05-21 20:49:01 +00:00
Colin Cross
b696bec354 am 28c30518: am 1742b7d2: Merge "Modify VID for Compal"
* commit '28c305183a6596eb3241771422d22351fbeaa9fb':
  Modify VID for Compal
2014-05-21 19:32:15 +00:00
Colin Cross
28c305183a am 1742b7d2: Merge "Modify VID for Compal"
* commit '1742b7d218706c596e6b40c89a6660f30bdba022':
  Modify VID for Compal
2014-05-21 19:28:43 +00:00
Colin Cross
1742b7d218 Merge "Modify VID for Compal" 2014-05-21 19:24:53 +00:00
Elliott Hughes
b65208d1a9 am f7a7e3c3: am 6dfb039b: am 4a343436: Merge "Fix win32 undefined reference to `_socket_network_client_timeout\'."
* commit 'f7a7e3c301fdf7d98d8bcabf6fefb0fcf5bbf90d':
  Fix win32 undefined reference to `_socket_network_client_timeout'.
2014-05-20 20:18:01 +00:00
Elliott Hughes
f7a7e3c301 am 6dfb039b: am 4a343436: Merge "Fix win32 undefined reference to `_socket_network_client_timeout\'."
* commit '6dfb039b0ba56576b4ed043e02ae43fb6afd42aa':
  Fix win32 undefined reference to `_socket_network_client_timeout'.
2014-05-20 19:24:31 +00:00
Elliott Hughes
6dfb039b0b am 4a343436: Merge "Fix win32 undefined reference to `_socket_network_client_timeout\'."
* commit '4a343436e01b07c21c043f8a903689f70000ca73':
  Fix win32 undefined reference to `_socket_network_client_timeout'.
2014-05-20 19:21:36 +00:00
Elliott Hughes
0bff5bd952 Fix win32 undefined reference to `_socket_network_client_timeout'.
Change-Id: I063213957b8452f4690da0f64872075f7c27b4cd
2014-05-20 12:13:29 -07:00
Elliott Hughes
fa59e0a487 am 9bcc5512: am 796b2015: am 51e27f95: Merge "Fix win32 implicit declaration of function socket_network_client_timeout."
* commit '9bcc55123ec814074417994db99730929a31fec8':
  Fix win32 implicit declaration of function socket_network_client_timeout.
2014-05-20 18:15:58 +00:00
Elliott Hughes
9bcc55123e am 796b2015: am 51e27f95: Merge "Fix win32 implicit declaration of function socket_network_client_timeout."
* commit '796b20157f75e46ad91b7d894796e0ba55a7766e':
  Fix win32 implicit declaration of function socket_network_client_timeout.
2014-05-20 16:00:25 +00:00
Elliott Hughes
796b20157f am 51e27f95: Merge "Fix win32 implicit declaration of function socket_network_client_timeout."
* commit '51e27f955b79846e36097532a725f4b7a3eefef8':
  Fix win32 implicit declaration of function socket_network_client_timeout.
2014-05-20 15:55:43 +00:00
Elliott Hughes
b911cf0af4 Fix win32 implicit declaration of function socket_network_client_timeout.
Change-Id: Ic6070855a21920384c555c9c82b9a2e4a776cbae
2014-05-20 08:51:15 -07:00
Elliott Hughes
3edc25271f am b42f1413: am 0e71e3ab: am 9cae50b3: Merge "Bound the ADB connect time with a non-blocking connect"
* commit 'b42f141315ae0929325335645d397db04a500c88':
  Bound the ADB connect time with a non-blocking connect
2014-05-20 00:23:08 +00:00
Elliott Hughes
b42f141315 am 0e71e3ab: am 9cae50b3: Merge "Bound the ADB connect time with a non-blocking connect"
* commit '0e71e3ab9cf66f41645ea286c7e62ed2b657ca38':
  Bound the ADB connect time with a non-blocking connect
2014-05-19 23:26:22 +00:00
Elliott Hughes
0e71e3ab9c am 9cae50b3: Merge "Bound the ADB connect time with a non-blocking connect"
* commit '9cae50b38d6a58efe0799ef3697f594cb4b100f9':
  Bound the ADB connect time with a non-blocking connect
2014-05-19 23:22:21 +00:00
Ken Lierman
aecc6a6657 Bound the ADB connect time with a non-blocking connect
After a disconnect, the initial blocking connect takes
a long time to return, while subsequent calls return
quicks.  Switch to a non-blocking connect to make the
re-connect time more consistent and faster overall.

Change-Id: I21d02b22a8eb9a457c2f1fa95eb17894d5612ccd
Signed-off-by: Ken Lierman <ken.lierman@windriver.com>
Reviewed-by: Gumbel, Matthew K <matthew.k.gumbel@intel.com>
Reviewed-by: Jovanovic, Radivoje <radivoje.jovanovic@intel.com>
Reviewed-by: Boie, Andrew P <andrew.p.boie@intel.com>
2014-05-19 16:16:42 -07:00
Ingo Rohloff
58b01e0187 ADB on linux: Handle USB SuperSpeed extra Descriptors
Under Linux, ADB manually parses USB Descriptors to check for
possible ADB USB Interfaces. USB Devices connected with SuperSpeed
will exhibit extra USB SuperSpeed Endpoint Companion Descriptors.
This patch handles these USB SuperSpeed specific USB Descriptors.

Change-Id: Icd1e5fdde0b324c7df4f933583499f2c52a922f3
Signed-off-by: Ingo Rohloff <lundril@gmx.de>
2014-05-16 22:25:45 +02:00
Bao Haojun
cdb1b1b84d Fix deadlocks.
1. Close pipe fds[1] as soon as possible. Otherwise it may block when
   reading from fds[0] even though the child process has exited early
   and closed its copy of fds[1].

2. Waitpid after pipe is closed. Otherwise the screencap child process
   may block while writing fds[1], because the fds[0] is not closed
   yet. If we close fds[0] first, then the screencap child process will
   die because of SIGPIPE, and waitpid will return correctly.

Change-Id: I433c95a5ba2eb3045727fc39a49fd9557fb1a1d1
Signed-off-by: Bao Haojun <baohaojun@gmail.com>
2014-05-14 21:45:11 +08:00
Kenny Root
910bca6850 am 57e53ed4: am c563c38d: am 905874ab: Merge "adb: avoid compilation errors for unused results"
* commit '57e53ed4189cc49844e6afcea2a5861fd8ca93f1':
  adb: avoid compilation errors for unused results
2014-05-13 16:31:54 +00:00
Kenny Root
57e53ed418 am c563c38d: am 905874ab: Merge "adb: avoid compilation errors for unused results"
* commit 'c563c38d06e3af61ab8cf1c26536106985fec073':
  adb: avoid compilation errors for unused results
2014-05-13 16:26:13 +00:00
Kenny Root
c563c38d06 am 905874ab: Merge "adb: avoid compilation errors for unused results"
* commit '905874abe45279d7c668e590d404880dd91b1869':
  adb: avoid compilation errors for unused results
2014-05-13 16:21:12 +00:00
Kenny Root
1bd41b1399 adb: avoid compilation errors for unused results
The BIO_CTRL_FLUSH function for files doesn't return anything useful
from the underlying fflush call, so it is safe to ignore this.

Change-Id: If33a7efbbaaf158e3da1cd72d0a56da1d3b82fd9
2014-05-13 09:12:54 -07:00
Mark Salyzyn
d2baee2f47 am e7597115: am 328746da: am 129e9dad: Merge changes Idfd1a114,If725a1cb,I61211165,If9a05ccb
* commit 'e75971157c46a0fc57194a75d4dde0920f60f427':
  adb: turn on -Werror
  netcfg: turn on -Werror
  mkbootimg: turn on -Werror
  gpttool: turn on -Werror
2014-05-08 18:24:02 +00:00
Ying Wang
da6a0aa0df am b18da571: am 1e6cd741: am 803fb62b: Merge "Remove unused LOCAL_LDLIBS."
* commit 'b18da571f90eebedd99fe5607a6b0d7ae4e91893':
  Remove unused LOCAL_LDLIBS.
2014-05-08 18:23:57 +00:00
Mark Salyzyn
e75971157c am 328746da: am 129e9dad: Merge changes Idfd1a114,If725a1cb,I61211165,If9a05ccb
* commit '328746da8090a549e432da2358585b101e30d753':
  adb: turn on -Werror
  netcfg: turn on -Werror
  mkbootimg: turn on -Werror
  gpttool: turn on -Werror
2014-05-07 23:15:40 +00:00
Mark Salyzyn
328746da80 am 129e9dad: Merge changes Idfd1a114,If725a1cb,I61211165,If9a05ccb
* commit '129e9dada707d66eb3242b666b6187a031dc410a':
  adb: turn on -Werror
  netcfg: turn on -Werror
  mkbootimg: turn on -Werror
  gpttool: turn on -Werror
2014-05-07 23:12:57 +00:00
Mark Salyzyn
129e9dada7 Merge changes Idfd1a114,If725a1cb,I61211165,If9a05ccb
* changes:
  adb: turn on -Werror
  netcfg: turn on -Werror
  mkbootimg: turn on -Werror
  gpttool: turn on -Werror
2014-05-07 23:10:40 +00:00
Ying Wang
b18da571f9 am 1e6cd741: am 803fb62b: Merge "Remove unused LOCAL_LDLIBS."
* commit '1e6cd741fd130e5916337eb75c9ceef2152035d2':
  Remove unused LOCAL_LDLIBS.
2014-05-07 23:01:12 +00:00
Ying Wang
1e6cd741fd am 803fb62b: Merge "Remove unused LOCAL_LDLIBS."
* commit '803fb62bb49b551afff546b4748d2d3e9ec54af1':
  Remove unused LOCAL_LDLIBS.
2014-05-07 22:54:26 +00:00
Ying Wang
9f437d7181 Remove unused LOCAL_LDLIBS.
Change-Id: I42aeb7668183e7a06207ee063f6eee4d37d66c6e
2014-05-07 15:36:05 -07:00
Greg Hackmann
7a5e2bd062 adb: replace utimes() with utime()
Fix the win_sdk host build by replacing utimes() with utime().  utime()
is functionally equivalent to utimes() when dealing with non-fractional
second timestamps, and is supported by the Windows CRT.

(The Windows CRT uses the nonstandard name _utime(), but mingw creates
aliases to the POSIX names.)

Change-Id: I513c6c5de05376c34cbb0894a94259acba8ae6f1
2014-05-06 08:48:18 -07:00
Mark Salyzyn
60299dfd6a adb: turn on -Werror
- Deal with some -Wunused issues

Change-Id: Idfd1a114e68ae637978b52fde5144d0dca0ec79f
2014-05-05 10:30:06 -07:00
jzhuan5
1297d22bc9 adbd: adb root should terminate adbd only if it's debuggable
adb root command will terminate adbd when closing the socket if current
user id is not root. This works for userdebug build, as adb root causes
re-enumeration.

But for user build, adb root command won't cause re-enumeration, and if
adbd is terminated and restarted, it will be in offline state, thus it
won't send any thing to host.

Change-Id: I81216a3b3da888cd9b236060cf745175f6d93c60
Author: jzhuan5 <jin.can.zhuang@intel.com>
Signed-off-by: Bo Huang <bo.b.huang@intel.com>
2014-05-05 17:20:00 +08:00
herman_lin
fd18127eb7 Modify VID for Compal
The original definition of VENDOR_ID_COMPAL is for Compal Communications, Inc.
But Compal Communications, Inc(CCI) had been merged into Compal Electronics, Inc(CEI) at April of 2014
So VENDOR_ID_COMPAL should be changed from 0x1219(CCI's VID) to 0x04B7(CEI's VID).
And add one new definition(VENDOR_ID_COMPALCOMM) for CCI to maintain old devices that use CCI's VID.
	modified:   adb/usb_vendors.c

Change-Id: I9e9a96f6cc81273ff2c9353a13e7ce3b0583396b
2014-05-05 03:43:20 +08:00