When we fail to write to a local socket peer, we might still have data
queued up to send to the other side. Defer closing the socket until
we've failed to both read and write.
Bug: http://b/74616284
Test: python test_device.py
Change-Id: Ifc4b8fe95369b4872e475c2ae4ee611dd2d8b9d7
If we get a ton of fdevent_run_on_main_thread calls while running one
of the handlers, the socket might become full, which will result in a
deadlock in fdevent_run_on_main_thread when a write to the fd blocks
with the mutex taken. Resolve this by making the fd nonblocking, which
is safe because we always write after appending to the list, and read
before emptying the list, which guarantees that if the byte we write is
consumed, the std::function we appended will be run.
Bug: http://b/74616284
Test: adb_test
Test: python test_device.py
Change-Id: I29319bda2ad7b5a5cdcd91d1d0ddf39f7ab7d115
Add a test to hammer on `adb shell exit $n` for flakiness.
Bug: http://b/74616284
Test: python test_device.py
Change-Id: I6a842960f5b55ff739044698f5c9683992fc42f1
Make it so that the socket tests don't leak until your machine blows up
by switching an infinite loop into an assertion failure.
Bug: http://b/74616284
Test: adb_test
Change-Id: If618c26b224b660548454f542cab79bebe46f80e
Add an implementation of std::make_unique for Windows, where we're
currently stuck with C++11, and switch some uses of new over to it.
Test: treehugger
Change-Id: I99b85f07754adda7c525243480c3e0bce9a25ce7
All devices that previously used ENDPOINT_ALLOC
are on the new async io routines. None of the devices
using aio_compat have ENDPOINT_ALLOC so remove the
code to stop logging failures.
Fixes: 74213465
Test: adb works
Change-Id: I0c903eb76b006b6bcce48cec24f5353fa47cc128
(cherry picked from commit 9a1be3ad0e)
Add a currently failing test that's a reduced case of the 'concurrent
adb shell' flakiness reported in b/74616284.
Bug: http://b/74616284
Test: changed #if 0 to #if 1, test fails
Change-Id: Id170a185f7c5d2ff44f772f7849a73227f9df441
adb disable-verity will toggle a flag in /vbmeta and introduce AVB
verification error on next boot. If the device is LOCKED, it will make
the device unbootable because verification error isn't allowed when the
device is locked.
Also indicating 'adb root' when failed to get verity state.
Bug: 70969453
Test: adb disable-verity should pop-up warning if the device is locked.
Change-Id: I1ed705e34334ea2231c96b16ddb8d225067af2f0
By default, the build system only sets ro.adb.secure (to 1) when
building user builds.
Bug: http://b/73993211
Bug: http://b/74059119
Test: treehugger
Change-Id: I2a683257c1027394ded90c8d2634def6003e0525
adbd is copied into the recovery image without the accompanying
linker/libraries, so it must be a static executable.
Bug: http://b/74237641
Test: `file $ANDROID_PRODUCT_OUT/system/bin/adbd`
Change-Id: Ie8d0710f6002458519d3eea3d696e9016faafee8
* changes:
adb: remove meaningless const.
adb: convert Connection to a nonblocking interface.
adb: use soong version stamping.
adb: switch over to Android.bp.
Rename the existing Connection to BlockingConnection, add a nonblocking
Connection, and add an adapter between the two, to enable future work
to reduce the impedance mismatch from implementing a blocking interface
on top of nonblocking primitives.
While we're here, delete A_SYNC, and remove one layer of pipes when
sending a packet (replacing it with a condition variable when using
BlockingConnectionAdapter).
Test: python test_device.py, manually plugging/unplugging devices
Change-Id: Ieac2bf937471d9d494075575f07e53b589aba20a
Added by I7255d45335fa009dc9e5de99dff67af52bd70e06
Bug: None
Test: Ran the analyzer. Complaint is gone.
Change-Id: Id9b8debd8b9690210f5a8e19154ee3a5095b8fbd
Rearrange some files while we're doing this.
Bug: http://b/71721338
Test: manually ran adb on windows
Change-Id: Ie47bda82279e4b9521505ad0353bf9ef649fc7d7
Add a way to test LeakSanitizer with the server by adding an
environment variable that intentionally leaks.
Test: ASAN_OPTIONS=detect_leaks=1:leak_check_at_exit=1 ADB_LEAK=1 adb server nodaemon
Change-Id: I7255d45335fa009dc9e5de99dff67af52bd70e06
We don't actually need to use quick_exit to avoid calling static
destructors, since we have -Wexit-time-destructors to guarantee we
don't actually have any, and this precludes the use of asan's exit time
leak checking, so switch back to atexit/exit.
Test: ASAN_OPTIONS=detect_leaks=1:leak_check_at_exit=1 adb server nodaemon with a manually inserted leak
Change-Id: Id8178913f64cb02c820c5073351369a9e4d8c74d
Passing in MS_REMOUNT | MS_BIND tells the kernel to only remove the
MS_RDONLY flag and keep all the other flags the same. This is also the
only kind of remount that is allowed in Linux containers (to be more
precise, within user namespaces).
This change also attempts to always run the remount command when dealing
with /, since containers will almost always run a loop device, and since
the number of the device changes, it is not convenient to put it in the
fstab. Plus, the container won't have permission to modify it, but might
be able to perform the remount.
Bug: 72178046
Test: `adb remount` works in both sailfish and Chrome OS
Change-Id: I9e8ec8afcd57f67875a312824667768b3aa89faa
If create_service_thread fails, we'll leak `arg`.
This fixes a static analyzer complaint:
system/core/adb/services.cpp:298:13: warning: Potential leak of memory
pointed to by 'arg'
Bug: None
Test: Reran the static analyzer. No more complaints about this leak.
Change-Id: I5aec7fd78f2cc775b650501b02bdf0039d1647ca
asocket has a destructor now, so we have to delete it, or leak the
data pointed to by its std::string.
Bug: http://b/73257049
Test: manual testing with asan
Change-Id: Ia88199292cc74e10032a9a16226d3afc61c3e0be
Don't go through a pointless conversion to hex that reduces our maximum
pid to 64k.
Bug: http://b/17661822
Test: `adb jdwp`
Change-Id: Idd572eac827f3ed3825ac2cf55fc4db109e70854
When persist.adb.trace_mask is used to enable verbose logging, avoid
exponential logging when a user runs `adb logcat`. As a side-effect,
set the minimum logging level to include everything when ADB_TRACE is
used on the client (which is something we want anyway).
Bug: http://b/72971016
Test: `adb shell 'setprop persist.adb.trace_mask; killall adbd'; adb logcat`
Change-Id: Id4bca1f3933a920345499dbeaeb103c8a2e220cd
Switch asocket over to taking a std::string instead of apacket* for
data. This allows us to remove asocket specific fields from apacket*.
Test: python test_device.py with x86_64 emulator, walleye
Test: adb_test on host
Change-Id: I9d157ff331a75ba49a54fdd4194e3f6cdff722f4
These checks were moved to after the read of the payload, which is too
late. Add a check before each read to avoid a heap buffer overflow.
Test: python test_device.py with x86_64 emulator, walleye
Change-Id: I86bcfaaa9004951cc52ad89af74680cf748e717d
As step one of refactoring atransport to separate out protocol handling
from its underlying connection, extract atransport's existing
hand-rolled connection vtable out to its own abstract interface.
This should not change behavior except in one case: emulators are
now treated as TCP devices for the purposes of `adb disconnect`.
Test: python test_device.py, with walleye over USB + TCP
Test: manually connecting and disconnecting devices/emulators
Change-Id: I877b8027e567cc6a7461749432b49f6cb2c2f0d7
We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.
Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
Makes copy of the transport list and sorts it by type and serial before
printing.
Bug: 70748433
Test: adb devices displays all connected devices
Change-Id: I917728a102972f2f38f2e370a0c6011c1eb883c7