This change removes the void* argument passing and instead uses C++11
features to avoid having to handle memory manually.
Bug: None
Test: python ./system/core/adb/test_device.py
Change-Id: I6380245b2ca583591810e3e363c67c993a107621
This change preserves any additional flags mount flags (e.g. MS_NODEV)
that any of the mounts would have. This avoids unnecessarily opening up
permissions, and also allows kernels that have additional restrictions
about what mount flags can be used to be happy with the remounts.
Bug: 111618714
Test: `adb remount` works in Chrome OS
Test: `adb remount` works in sailfish_aosp
Change-Id: I20d9f2feaf3a47b93bfcdfb4164ee61546ec0b68
Fastboot protocol doesn't include zero packets,
so make it possible to configure that.
Allow fastbootd to see how many bytes the handle
can read/write at once.
Test: adb works
Bug: 78793464
Change-Id: I31e444f384d9d0cdf1ea936439b2028f8151c3b8
Previously, read and write would return 0
on success. Now it will return the number
of bytes read/write. This is more consistent
with other usb handles and is needed in order
to handle partial packets (for fastbootd).
Update usb_write in other usb handles
to return amount written.
Change transport_usb accordingly.
Test: adb works
Bug: 78793464
Change-Id: If07ff05fbc8120343f20661475d34f4e5ff805de
Fastbootd will reuses adb's functionfs transport
implementation.
Move it to daemon/include as well so it can be accessed
with "adbd/usb.h". Otherwise usb.h will conflict with
other imports.
Test: adb builds and works
Bug: 78793464
Change-Id: If3ba190d5c74b5f3633411f0484195e5a2a34d44
When pushing to a path, we first try to ensure the directory path
exists and has the permissions expected by fs_config. Due to a change
that changed the fs_config check from a blacklist to a whitelist, we
started doing this for /data (which doesn't begin with /data/), and the
UID/GID for that path was accidentally being reused for following path
segments that didn't exist, leading to a failed attempt to chown
/data/local/tmp/foo to be owned by system.
Bug: http://b/110953234
Test: python test_device.py
Change-Id: Ie798eec48bcf54aea40f6d90cc03bb2170280ee8
adbd has been built as a static executable since the same binary was
copied to the recovery partition where shared library is not supported.
However, since we now support shared library in the recovery partition,
adbd is built as a dynamic executable.
In addition, the dependency from adbd to libdebuggerd_handler is removed
as debuggerd is handled by the dynamic linker.
A few more modules in /system/core are marked as recovery_available:
true as they are transitive dependencies of the dynamic linker.
This change also includes ld.config.recovery.txt which is the linker
config file for the recovery mode. It is installed to /etc/ld.config.txt
and contains linker namespace config for the dynamic binaries under
/sbin.
Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: Select 'mount /system' in the recovery mode, then `adb shell`.
$ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from
the /lib directory.
Change-Id: I363d5a787863f1677ee40afb5d5841321ddaae77
When using "adb remount" on a deduplicated filesystem, the current
response is a warning that the remount will not work. This patch
allows the user to specify an -R option. This option will reboot to recovery,
run e2fsck to undo deduplication, and then reboot the device where "adb
remount" will then succeed.
In addition, if verity needs to be disabled to remount, it will be disabled in
the same reboot cycle to minimize reboots.
Bug: 64109868
Test: adb remount -R on a deduplicated filesystem
Change-Id: I812407499b2df6f4d2509e8d51878117108a6849
Remove fdevent_install and fdevent_remove in favor of using
fdevent_create and fdevent_destroy, so that we can put RAII types (i.e.
unique_fd) into fdevent without worrying about -Wexit-time-destructors
or structs that are freed instead of deleted.
Bug: http://b/79786774
Test: python test_device.py
Change-Id: I8471cc00574ed492fe1b196944976cdaae8b7cff
Remove some redundancy by moving io_setup
into aio_block_init. The io_contexts will
now live till the end of the program, similar
to the rest of usb_handle
Test: adb works
Bug: 78793464
Change-Id: I910a39d4395645f1ff231f265c285a72893a0ac6
io_submit sleeps waiting for the gadget
to be enabled. Currently if that sleep
is interrupted it will shut down adb,
causing it to have to start back up again.
Rather than return EINTR if interrupted,
io_submit actually completes and the EINTR
is found later when looking through events.
Since an io that is interrupted will be
small anyway, add a loop to retry small ios.
Also upgrade aio logs in accordance with
their importance.
Fixes: 75981904
Test: adb works, logs show successful interrupt handling
Change-Id: I35973fce130ee849ce59fef80d15b65afb816ba4
(cherry picked from commit 6e9a327504)
A deduplicated filesystem might not have enough free space to undo its
block sharing. In this case "adb remount" should give a more precise
error message.
Bug: 64109868
Test: adb remount on deduplicated filesystem with no free space
Change-Id: I2beb67aa3dfc807cb8493b9c622e7b14174dc9c6
If BOARD_EXT4_SHARE_DUP_BLOCKS is true, "adb remount" will error saying
the filesystem is read-only. Instead, it will now list affected
partitions and explain why they can't be remounted.
Bug: 64109868
Test: adb remount with deduplicated system image
Change-Id: Ida737a6be8e9fe9ea26300897d82b1a149e72f6d
Switch from using std::string as the type we use to hold our payload in
apacket to a custom reimplementation that doesn't zero initialize. This
improves bulk transfer throughput in the adb_benchmark microbenchmark
on walleye by ~20%.
Test: adb shell taskset f0 /data/benchmarktest64/adb_benchmark/adb_benchmark
Change-Id: Ibad797701eb1460c9321b0400c5b167b89b2b4d0
This change splits the capability-dropping step of adbd into two. This
is more robust when ambient capabilities are being used, since minijail
cannot currently handle that case.
Bug: 77146512
Test: grep Cap /proc/`pidof adbd`/status
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 00000000000000c0
CapAmb: 0000000000000000
Change-Id: I0476a8d80f7a2497600196932542045f3bc87537
Profiling of adb_benchmark revealed that something like half of the CPU
time was being spent in malloc and free, which was odd because the
benchmark repeatedly mallocs and frees allocations of the same size. It
turns out that our default configuration of jemalloc will purge after
every free. Configure jemalloc to not do this, for gains of over 100%
on adb_benchmark, and up to 25% (on walleye USB3) in real-life.
Test: adb_benchmark
Change-Id: I602dd1645c3d21709c7f6a78903511ce4d576558
Previously, processes started via `adb shell` have an oom_score_adj of
-1000, making them invisible to the oom killer. This makes running a
process that consumes all memory (e.g. by leaking in a loop) lead to
the entire rest of the system (including adbd, because of bad
heuristics in the kernel) being oom killed before getting to it.
Bug: http://b/63143027
Test: `adb shell cat /proc/self/oom_score_adj` with adb root
Change-Id: I59111134e36dc271adf4c1dd4bd4400d4fe6aee0
Match openssh's behavior with regards to login shells.
Bug: http://b/76116378
Test: `adb shell -T set -o` vs `ssh localhost -T set -o`
Test: `adb shell -tt set -o` vs `ssh localhost -tt set -o`
Test: `echo set -o | adb shell -T` vs `echo set -o | ssh localhost -T`
Test: `echo set -o | adb shell -tt` vs `echo set -o | ssh localhost -tt`
Change-Id: I6ed69b43e2ac79c947c242948b5617ece08a713e
There exists no path through which a value other than -1 can be written
to the SHELL_EXIT_NOTIFY_FD.
Test: adb_test
Test: adbd_test
Test: python test_device.py
Change-Id: I0630c302ba06bc76917f0445aea75d2dbe1dc865
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)
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
This change opens the control, bulk-in, and bulk-out FunctionFS
endpoints with O_RDONLY or O_WRONLY.
Bug: 70349025
Test: Android on Chrome OS can still use ADB
Test: aosp_sailfish-userdebug can still use ADB
Change-Id: I3895b626cf7cec8437c36bdc6c6e6055aaf3777c
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
Rearrange some files while we're doing this.
Bug: http://b/71721338
Test: manually ran adb on windows
Change-Id: Ie47bda82279e4b9521505ad0353bf9ef649fc7d7
We want repeatable builds for minimal OTAs.
(cherrypick of 2e93eda69cf20d9c04d56ea6bf1e2ea62ad62eb4.)
Bug: http://b/64634017
Bug: 64709603 (presubmit balking at the line above)
Test: repeated builds after `touch daemon/main.cpp` keep same md5sum
Change-Id: Iedeb44377ea45bbf20e2212760802198a57dc14a
This method works around the downsides of
ENDPOINT_ALLOC, namely that it is not affected
by memory fragmentation and it uses an upstream
interface.
Also add libasyncio to provide the necessary syscalls
to both adb and mtp.
Add some small optimizations to file_sync.
Bug: 37916658
Test: run adb push/pull
Change-Id: If3b3be02b5e2d4f9cffec1b8ddc02a5768a51a1f
ALLOW_ADBD_ROOT ('adb root') and ALLOW_ADBD_NO_AUTH (ro.adb.secure = 0)
are false in user build. This prevents a non-A/B device from running
Treble VTS because it requires 'adb root'. Without ALLOW_ADBD_NO_AUTH,
adb still can work if ro.adb.secure = 1. However, allowing it to be 0
is better for test automation.
The image combination in VTS is:
- system.img (userdebug): provided by Googlg
- boot.img (user): provided by the OEM <-- adbd is here
- vendor.img (user): provided by the OEM
This change allows 'adb root' and 'ro.adb.secure = 0' when the device is
unlocked in user build. No changes for userdebug/eng builds.
Note that the device must be unlocked when running VTS. Otherwise,
verified boot will prevent it from booting the system.img provided by
Google (no verity metadata).
Bug: 63313955
Bug: 63381692
Test: use the above image combination, check 'adb root' and
'ro.adb.secure = 0' can work
Change-Id: I109d96c950e54c4fb0ac0c98b989a20593681e52
This CL is in support of another CL c/2048848, topic
'Refactor hid command in /frameworks/base/cmds' in
internal master. Adding the permissions for
shell here to access uhid_node as part of the
new 'uhid' group.
Bug: 34052337
Test: Tested on angler, bluetooth mouse works OK.
Change-Id: If9e100aa1262d689fb8adc5c0ce93f157c96399e