Commit graph

873 commits

Author SHA1 Message Date
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