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
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
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>
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>
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
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>
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
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
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
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
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>
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
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
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>
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
This reverts commit 152d2d4234.
Fixed build error, and also fixed memory leak spotted from warning.
(cherry-pick of bbb36319119edde9377fb80015235893c30d2bc9.)
Bug: 17691572
Change-Id: I23b5ba537f7b557432041d4338b38b9be434e981
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>
On mac require a case.
Also, this code is not portable, will fix it in long run.
(cherry-pick of 0f1fda9ee80ba086e4c8960a7d153798e3cf3285.)
Change-Id: I76194b62cea29bd3d21c7ba6c3da4d549bea4738
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
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
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
Change-Id: I5a350bfa5641365d7a0939d89c6f477c335e948a
Signed-off-by: Zhuang Jin Can <jin.can.zhuang@intel.com>
Signed-off-by: Robert Chiras <robert.chiras@intel.com>
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
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
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
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
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
Bug: 14416410
The proper fix for the error/warning we encountered is to move winsock2.h
in front of windows.h.
Change-Id: I29504ba3a184a85c6636d06c2ad900828fdb5436
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
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
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
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
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
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>
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
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
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>
Commands chained with && need to be passed through literally instead
of always being quoted.
(cherry-pick of 7c460351f53cb683097fe4071b9ec1e4cd7cdf82.)
Bug: 15479704
Change-Id: I2998e40a92a3bfd092098cd526403b469c86c9a6
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
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
Most code is copied and pasted from adb.h.
Any file can just include it to enable tracing.
Removed some duplications.
Change-Id: Ie1ed9e9edbf92158aac84669fbcbf7dc85fe2cf0
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
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
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
"fprintf(stderr, buf)" is a warning in some compilers, and we're
building with all warnings promoted to error.
Change-Id: Ie3c6ddcd74cf4dda40cf7b742df955dde1d1a5ff
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
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
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>
We should ensure that the appropriate supplementary groups are
set, regardless of whether we're running UID=0 or UID=shell.
Change-Id: I3a1624a574102be08176a41f9c7eb5f82af2b3e5
Commands chained with && need to be passed through literally instead
of always being quoted.
Bug: 15479704
Change-Id: I2998e40a92a3bfd092098cd526403b469c86c9a6
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
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
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
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
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
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>
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>
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>
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
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
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>
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