If ANDROID_SERIAL was not set, test_device.py was failing.
Use posixpath.join instead of os.path.join for make_random_device_files.
Change-Id: I24bfa43ba2a89a9a768f505fc0bba9d873082b2f
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
perfboot.py repeats the record of each event log during Android
boot specified times. By default, interval between measurements
is adjusted in such a way that CPUs are cooled down sufficiently
to avoid boot time slowdown caused by CPU thermal throttling.
This script also works around the issue of dropbox slowing down
boot time on userdebug build (http://b/20890386) by limiting
the number of files to be created by dropbox.
The result is output in a tab-separated value format.
BUG: 22207911
Change-Id: I0ddbac5d1c941efda87bc6db6388d8194d4bb3dd
adb forward --no-rebind (and the matching reverse command) seem to have
been broken by 424af02f36. I fixed-up the
string parsing and also fixed the error message not to include
strerror(errno) since that does not apply because it is an
application-level error that doesn't have anything to do with the
OS/libc.
Change-Id: Iba7286283bfcf1782076355edcd9c355c0a0edfd
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
Had messed this up while refactoring before I submitted and neglected
to add a test. Thanks to mazda@ for catching this.
Also disabled the root/unroot tests for user builds.
Change-Id: Icb819a820a2afa227d548d678ae471d5195f0b96
This causes build failures in google3 where they use GCC. glibc only
provides const-correct overloads for string functions for GCC >= 4.4,
but clang -- which is what we use -- pretends to be GCC 4.2.
Change-Id: I2a054823ea6201ebcea46d5e77b80a975eefc622
This is mostly just the AdbWrapper that we used in our tests, but I've
cleaned up the API to be a little more Pythonic (mostly in the sense
that commands are passed as lists rather than strings that are
shlex.split() by the shell command), and implemented the workaround
error checking for adb shell.
Move the tests up a directory. Having them buried a level down has
only been annoying.
There are now two files containing Python tests. test_device.py
contains tests specifically checking the AndroidDevice API, and
test_adb.py checks the ADB client program. To run both, use
python -m unittest discover [-v]
Change-Id: Ibd158c528d31126a5b048bd00bc93039dbc468bc
tsan complained that usb_bulk_write accesses usb_handle members outside
a lock. Fix that, but by moving everything over to C++11 locking.
Note that the old code was checking whether pthread_cond_timedwait returned
a negative value, which it will never do --- it will signal timeout (or
any other error) by returning a positive errno value. The rewrite does
what they appeared to intend to do (break out on timeout), rather than
what they actually did (keep trying forever).
Bug: http://b/22598587
Change-Id: Iab6869ffed4874143a7da97193d6b09e34cf2933
In 3d2904cdf2 we removed the code that broke
Linux USB reads into 4KiB chunks. This patch does the same for Windows. This
improves Windows "adb pull" speeds 6x in my VM. (There was no equivalent
problem with writes, so this change only affects pull speeds.)
Change-Id: If19013e5f51975f4824bf9147b7b76cebd305b96
The reason behing this change is to increase the adb push/pull speed
with reduceing the number of packets sent between the host and the
device because the communication is heavily bound by packet latency.
The change maintains two way compatibility in the communication
protocol with negotiating a packet size between the target and the
host with the CONNECT packets.
After this change the push/pull speeds improved significantly
(measured from Linux-x86_64 with 100MB of data):
| Old push | Old pull || New push | New pull |
-----------------------------------------------------------
Hammerhead | 4.6 MB/s | 3.9 MB/s || 13.1 MB/s | 16.5 MB/s |
-----------------------------------------------------------
Volantis | 6.0 MB/s | 6.2 MS/s || 25.9 MB/s | 29.0 MB/s |
-----------------------------------------------------------
Fugu | 6.0 MB/s | 5.1 MB/s || 27.9 MB/s | 33.2 MB/s |
-----------------------------------------------------------
Change-Id: Id9625de31266e43394289e325c7e7e473379c5d8
Add missing \n to uses of legacy D() macro. This should make the legacy
logging easier to read (and harder to miss important stuff).
On POSIX, use gettid() from libcutils instead of pthread_self() so that
the output shows a more reasonable number instead of a pointer value.
This should be ok since libbase's logging already uses gettid().
Win32:
Don't let the Win32 last error get overwritten by API calls after the
original error'ing API. When encountering an unknown error, log the
specific error code.
Change-Id: Ib8f72754efa7ba895d2f1cd914251fec2a1d894c
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
The code which triggers these events (via the SHELL_EXIT_NOTIFY_FD) are
only called from code which is already guarded by #if !ADB_HOST.
Change-Id: I184414f5e090c1f08ee117e4c8c434cd4a8b5221
One of my build aliases doesn't play nice with USE_MINGW=1, so my build lied to me. Will revert until I fix it up.
This reverts commit 459df8f3a1.
Change-Id: I7905c5ae5ee85fb2d228ce63d81c79f140998c18
Apparently there are two classes of this warning in clang.
-Wformat-security is only emitted for cases of
`func(nonliteral_fmt_string)` (no args), and -Wformat-nonliteral is
emitted for cases *with* arguments. For whatever reason, the latter
isn't included in -Wextra and must be manually enabled.
To make this more easily portable to Windows, move the existing
gnu_printf/__printf__ decision into base/macros.h as ATTRIBUTE_FORMAT.
Change-Id: I3b0990e1d1f0a2e9c13b32f5cd60478946cb5fc6
Prior to the documentation told users to pass 0 in as
the first argument to write messages, when they should
be outting in their local-id. It is now corrected.
Change-Id: Ia2c6c84f95383baa5ca471493a29a39e5173b604
Signed-off-by: Derrick Bonafilia <dbonafilia@google.com>
Now we'll say "no devices found" if you haven't set ANDROID_SERIAL and
there's no device connected to default to.
Also clean up the relevant code a little.
Change-Id: Id254929629ce0888628d5ba8e67cd996ffbf9c8a
Require authorization by default, and remove the ability to override
that in user builds. (userdebug and eng are still free to do whatever
they want.)
Bug: http://b/21862859
Change-Id: Ibf8af375be5bf1141c1ad481eee7a59fb10a7adb
d34e407aeb removed support for
running with SELinux completely disabled. SELinux must either be
in permissive or enforcing mode now.
Remove unnecessary calls to is_selinux_enabled(). It always returns
true now.
Change-Id: Ife3156b74b13b2e590afe4accf716fc7776567e5
One day we should slim this down. (Maybe implement the "help" versus
"help all" distinction that doesn't currently exist but was documented
before this change.)
Bug: https://code.google.com/p/android/issues/detail?id=158394
Change-Id: Ie24b588ffea00d262ce7ab0e5c328120ba8af240
I think this fixes a scary bug that could be on all host platforms.
When running 'adb unroot' with an emulator, the connection to the
emulator is dropped (as expected). I noticed that the adb.log showed:
_fh_from_int: 1168: 5280 | _fh_from_int: invalid fd 106 passed to adb_close
Background: Every transport has a socketpair (two bidirectional sockets
connected to each other to form one 'pipe') that are used as follows:
* When adb wants to write to a transport, it writes to
t->transport_socket (half of the socketpair). An input thread reads from
t->fd (the other half of the socketpair) and writes the data to the
underlying transport (TCP, USB).
* An output thread reads from the underlying transport (TCP, USB) and
writes the data to t->fd. The main thread runs fdevent_loop() which
reads from t->transport_socket and processes the packets (that really
came from the underlying transport).
So t->fd and t->transport_socket are just an intermediate pipe between
transport agnostic code in adb and the underlying transport (TCP, USB).
Here's what I think is going on:
1. When the TCP transport is closed (such as when running adb unroot),
adb server's output thread notices this (adb_read() returns zero), and
it writes a special packet to t->fd.
2. The main thread processes the special packet by writing the special
packet to the input thread.
3. input_thread() sees the special packet, so it breaks out of a read
loop and calls transport_unref() which calls transport_unref_locked().
4. transport_unref_locked() calls t->close() which is a function pointer
that points to transport_local.cpp: remote_close() which calls
adb_close(t->fd). <----- ****THIS IS THE BUG****
I think this is a (very old) typo and it should instead be
adb_close(t->sfd) (the transport’s actual TCP socket) because it does
not make sense for the particular transport mechanism (TCP, USB) to be
messing with a socket of the socketpair of the transport agnostic code
(t->fd).
5. transport_unref_locked() calls remove_transport() which writes an
action to another special socketpair.
6. The action is read and eventually transport_registration_func() is
called and it calls adb_close(t->fd). But t->fd was already
(erroneously) closed in #4 above!! Anyway, this causes the adb.log
output.
The fix is to fix the typo changing t->fd to t->sfd and adding some
resiliency around whether the socket has already been closed (probably
by remote_kick()).
I tested this by putting a new adbd on an emulator, a new adb on Linux
and Windows and running the adb unroot scenario and checking adb.log. I
also ran test_adb.py (which doesn't totally work without problems with
an emulator, but I'll leave that to another day.)
Change-Id: I188b6c74917a3d721c150fd17ed0f2b63a2178c3
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
adb exec-in and exec-out are designed to read/write binary data
according to the commit description at:
https://android.googlesource.com/platform/system/core/+/5d9d434%5E!/
On Windows, when adb_read and adb_write are used, they are always in
binary mode (because sysdeps_win32.cpp calls Windows APIs direct). But
unix_read, unix_write, fread, fwrite, read, write use the text
translation mode of the C Runtime file descriptor, which is by default
textmode.
adb exec-in and exec-out use copy_to_file() which uses unix_read() and
fwrite() when reading/writing stdin and stdout, thus, copy_to_file()
should switch to binary mode for those cases (it already uses binary
mode for file descriptors other than stdin and stdout).
copy_to_file() is also called by adb backup, adb restore, and adb
install-multiple, but those do not use stdin or stdout, so those
codepaths should not be affected by this change.
Change-Id: I3446d9b363d20a2c2f6be2b96e55b653d99df2f9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
The descriptors to enable USB 3.0 SuperSpeed support had previously
been added in commit d6ee9f26a5
but were removed when the v1/v2 descriptor handling was refactored
in commits ab3446dd34 and again in
c49f51c451. Now that the dust has
settled, add back the SS descriptors to re-enable USB 3.0.
Change-Id: I8de7c7e50d9216a7492ce7863e3aaf92ff805eff
Also use assertEqual for better errors. (I accidentally tested against
a non-AOSP build that doesn't have the \r fix.)
Change-Id: Ib032c01efa4e1efb14467ca776a14160fff4ad39
In the adb client, redirect stdin and stderr of the adb server to `nul',
so that when the adb server starts up, it avoids issues in the C Runtime
where it closes stderr, making it hard to properly reopen. There are
probably other ways to avoid this issue, but I think this is the
cleanest that will keep working over the years and will exercise the
most commonly used code-paths in the C Runtime.
Fix some adb_close() calls to be unix_close() (only really matters on
Windows).
Make stderr non-buffered on Windows, to match the (sensible) Linux
behavior.
Change-Id: I1b15c64240e50dbeb56788b0d0d901f4536ad788
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
We really need better infrastructure for parsing adb subcommands, but
in the meantime...
At least this cleans up a little more of the implementation too.
Bug: http://b/20736014
Change-Id: I76209847da3724906c71924017bcb69fa31e0b49
* Use posixpath instead of os.path, because os.path uses '\' instead of
'/' when running on Windows.
* tempfile.NamedTemporaryFile() does not work right on Windows because
it holds the file open, preventing other processes from accessing the
same file (https://bugs.python.org/issue14243). To work-around this, use
the mechanical transformation described at
http://stackoverflow.com/questions/15169101/how-to-create-a-temporary-file-that-can-be-read-by-a-subprocess
* Use pipes.quote() to quote path arguments, to prevent C:\foo\bar from
turning into C:foobar.
* Open files in binary mode with "b".
* Fix line-ending test to allow for \r\n on Windows, but to still test
for adbd incorrectly sending \r\n (which is then translated to \r\r\n).
Change-Id: Ib6ba94b919b747a878ba3ab54a4dea0801f76947
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
Document the differences between adb_*() and unix_*() in the function
prototypes in sysdeps.h. See the file for the details (CR/LF
translation, well-known file descriptors, etc.).
Fix adb_read(), adb_write(), and adb_close() calls that should really be
unix_read(), unix_write(), and unix_close(). Note that this should have
no impact on unix because on unix, unix_read/unix_write/unix_close are
macros that map to adb_read/adb_write/adb_close.
Improve sysdeps_win32.cpp file descriptor diagnostic logging to output
the name of the function that was passed a bad file descriptor.
Change-Id: I0a1d9c28772656c80bcc303ef8b61fccf4cd637c
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
Any output from the LOG family will now go to stderr and logcat on the
device. stderr is usually redirected to a log file, but that is now
inhibited for adbd if being run from a tty (useful when debugging with
the serial console).
This also fixes sending logs to the file on device for the trace mask
of "all". The "all" tag was specifically handled to return early from
the function, preventing the file initialization from happening.
Change-Id: Id253577bfd1500fbce92dbfba0f9be23dbfd5ee4
Using non-POD types in atransport means we'll need to start treating
it as a real class (specifically with regards to new/delete rather
than malloc/free).
I've also cleaned up the home grown linked lists for transport_list
and pending_list to just be std::lists. We might want to refactor that
again to be an std::unordered_map keyed on serial, since that seems to
be a common way to search it.
Change-Id: I7f5e23cdc47944a9278099723ca029585fe52105
Old code was a mess for splitting a string and then searching a list
when they really wanted a map.
To more closely match ANDROID_LOG_TAG, only use a space separated list
rather than space/colon/semi-colon/comma.
Change-Id: I915ff4968e42d5f8dec1b43b6eacc0c8d7b44d7b
Instead of defining and undefining NOGDI:
1. Always #include "base/logging.h" after #include <windows.h>.
Unfortunately, I could not find an easy way to give the user a
warning/error if they include in the wrong order.
2. base/logging.h does #undef ERROR to undefine the evil ERROR macro
that is from another era and probably a bad idea to begin with.
Change-Id: I995d89620611e849af9d7ec47eb55fc0512377f2
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
Unfortunately this lint check also fires when public/private are not
indented by a single space. The indentation format in adb does not
match google style, so that's not going to happen.
Change-Id: I35e5654a2359222bb274ac5fb2961aee6a3a280f
The main goal here is fixing the line ending translation from \n to
\r\n, but we probably don't want any translation to happen.
Bug: http://b/19735063
Change-Id: I1d6d6c6b57cc741b046c2432cd864b344ce1f28a
At runtime, vsnprintf (and android::base::StringPrintf which calls it)
call a mingw version of vsnprintf, not the vsnprintf from MSVCRT.DLL.
The mingw version properly understands %zd and PRIu64 (the latter,
provided that you #include <inttypes.h>).
The problem was that android::base::StringPrintf was causing
compile-time errors saying that %zd and PRIu64 were not recognized. It
seems that this was because the attribute on the function prototypes
specified `printf' instead of `gnu_printf'. Once that was fixed to match
vsnprintf's attribute, the warnings went away.
This uses similar preprocessor techniques as <android/log.h>.
Also restore a %zd usage to avoid a static_cast<>, and make
print_transfer_progress()'s format string compile-time checkable (and
tweak some types and %llu => PRIu64).
Change-Id: I80b31b9994858a28cb7c6847143b86108b8ab842
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
When multiple client try to connect to other hosts, it failed because
memory corruption. Allocate memory for each thread like other command did.
Change-Id: I79959ce3dbfd11c7553736cd3f5a899815873584
Signed-off-by: Alan Jeon <skyisle@gmail.com>
The daemon failed to startup because main.cpp was changed from calling
WriteFile() to android::base::WriteStringToFd(), the later which calls
write() in the C Runtime which by default has stdout in textmode which
does \n to \r\n translation.
The quick fix is to change stdout's mode from text to binary since right
after it is reopened to redirect to the daemon log file anyway.
Change-Id: I322fc9eae5d6abbf63f3d5917b0beb2171b5a15c
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
Many devices don't have an /oem partition, so find_mount should be
expected to fail, but shouldn't cause the overall remount to fail.
Also clean up all the error handling and reporting, and remove the
dead int* globals.
Bug: http://b/21024141
Change-Id: Ie31021b03c9cab8e972269d7d1ffe383cd30ee9e
The name "client" is somewhat misleading as it also contains the host
side adb server, but it's a part of the client binary.
Change-Id: I128b7bab213e330eb21b5010cd1fec5f7a62c8af
On a device without an oem partition, we now have an /oem directory
anyway. This causes find_mount to fail, and that was returning nullptr
from a std::string-returning function. Boom!
Also clean up the bits of code I had to trace through between "adb remount"
on the host to the crash on the device as I debugged this.
The only other meaningful change is the error checking in
adb_connect_command --- adb_connect can also return -2.
Bug: http://b/20916855
Change-Id: I4c3b7858e13f3a3a8bbc7d30b3c0ee470bead587
The issue is that adb uses fopen() with "e" (presumably to open the file
with O_CLOEXEC), but that flag causes MSVCRT.DLL to return an error. So
when adb_auth_host.cpp goes to read or write the adbkey files, it fails.
The quick fix is to not use the "e" option on adb host code since it
isn't necessary there, compared to adbd.
An alternative fix would be to have a fopen() wrapper on Windows that
filters out the "e" option.
Change-Id: I7d8ba2847dab0ed558ffe156e79093251eb253c9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
The adb emu command was never working because the socket connection to
the emulator was closed without reading all of the data that the
emulator sent. On Windows, this caused the emulator's recv() call to
error-out, so it never got the command that was sent.
Before settling on this fix, I also experimented changing the arguments
to the socket shutdown() call and that didn't seem to help. I also tried
removing the call to shutdown() and that didn't help. So that should
rule out shutdown() as the problem. One experiment that helped was
delaying before calling adb_close(), but that is of course fragile and
doesn't address the real issue, which is not closing the socket until
the commands have been read.
https://code.google.com/p/android/issues/detail?id=21021
Change-Id: I8fa4d740a2faa2c9922ec50792e16564a94f6eed
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
The USB spec explicitly says this is optional, so we shouldn't be
relying on it.
Bug: http://b/20883914
Change-Id: Icf38405b00275199bcf51a70c47d428ae7264f2b
The tests will need some massaging before they're ready to go for
Windows, so just disable them to unblock people trying to mm in adb.
Change-Id: I67f2cd3af1a2444dea9cbb61c0553989442ba44b
It isn't documented, it doesn't work, and it was only hacked into
"adb shell" anyway. (It's not a bad idea, though, but if we do it
we should do it properly.)
Change-Id: I930a5c6dd1d2850bfdf131f2e989ae04100f7db9
The first rule of ssh(1) escaping is that there is no escaping.
This doesn't undo any of my recent security fixes because they're all
calling escape_arg themselves.
This fixes "adb shell rm /data/dalvik-cache/arm/*".
Also remove do_cmd which caused concern during code review.
Bug: http://b/20564385
Change-Id: I4588fd949d51e2a50cff47ea171ed2d75f402d0d
This patch factors out a lot of the basic protocol code: sending OKAY,
sending FAIL, and sending a length-prefixed string.
ADB_TRACE has been non-optional for a long time, so let's just remove
the #ifs.
Also actually build the device tracker test tool (and remove its duplicate).
Bug: http://b/20666660
Change-Id: I6c7d59f18707bdc62ca69dea45547617f9f31fc6
Also remove an sprintf. Also fix various bits of code that were
reporting stale adb_error values when they meant strerror.
Bug: http://b/20666660
Change-Id: Ibeb48b7bc21bb0ec30ba47889d1d671ee480e1b7
Two bugs: we couldn't report the serial number correctly if it was long
enough, and it wasn't possible to connect to a device whose serial number
was long enough to overflow a different fixed-length buffer.
Bug: http://b/20317730
Change-Id: Ic9cf3c847066449ac78069bd1718184935098ac7
This doesn't fix the bug, but it does flatten the bug to the well-known
and long-standing "adb shell" doesn't return exit statuses, so when we
fix that, this one will fix itself.
Bug: http://b/20423886
Change-Id: I48351e46f05dd3f2f6e57f0df1d851333458d0ef
Until I fixed this, we would fail this example:
$ adb shell sh -c 'echo hello; echo world'
hello
/system/bin/sh: echo world: not found
Bug: http://b/19734868
Change-Id: I11a437cd0c0362303028f23fbaa103611b75707e
It looks like we can't use clang on Windows yet because libc++ isn't ready.
So move back to GCC for the Windows host clang. Work around the mingw
printf format string problems that made us want to switch to clang in the
first place, and #include "sysdeps.h" in adb_utils.cpp to work around the
absence of lstat(2) on Windows.
Change-Id: Icd0797a8c0c2d1d326bdd704ba6bcafcbaeb742f
The specific motivating case is "text;ls;1.apk", but rather than continue
adding individual characters to the list of characters to be escaped, let's
just switch to quote all arguments with ', which only leaves ' itself to be
escaped.
Bug: 20323053
Bug: 19734868
Change-Id: I8bd71db9373bc2d1169fc11e46c889da6638550a
This doesn't fix the injection vulnerability, but it makes "adb backup"
no worse than the other commands, and lets me fix them all at once.
Bug: 20323053
Change-Id: I39843c065d9d738b6b7943b2ffd660e4a031cc36
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
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
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>
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
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
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
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.
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>
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
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
* 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
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
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
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
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
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
* Check the current adb user to choose the order of root/unroot.
* Re-root the device when finished.
Change-Id: I47a14b89e2c405bd63722e4d2043fcc629fb5e58
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().
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
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
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
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
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
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
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