Commit Graph

2610 Commits

Author SHA1 Message Date
Josh Gao 09f051ff16 Merge "adbd: spawn login shell when run without a command." am: 31ed2a5c04
am: a7a66f40fd

Change-Id: I7389663e6408154dfc4ca0c81349fe6dc9cefd0e
2018-03-29 20:52:34 +00:00
Josh Gao 1702852f60 Merge "adbd: increase oom_score_adj for `adb shell`" am: db9671090d
am: 1919289d12

Change-Id: If584fabf576841b41a52df2c0c9538a6d4262dd3
2018-03-29 20:51:50 +00:00
Josh Gao 26cc303ba0 Merge "adb: restore adb/adb.exe in the list of artifacts." am: 8043633922
am: b0d408f2f3

Change-Id: Ieeb35e8ade7ed7fb0a9e022ad6e799f990849080
2018-03-29 20:51:19 +00:00
Josh Gao 31ed2a5c04 Merge "adbd: spawn login shell when run without a command." 2018-03-29 20:19:27 +00:00
Josh Gao db9671090d Merge "adbd: increase oom_score_adj for `adb shell`" 2018-03-29 20:19:03 +00:00
Josh Gao 8043633922 Merge "adb: restore adb/adb.exe in the list of artifacts." 2018-03-29 20:18:58 +00:00
Josh Gao d8ff614f69 Merge changes Iea2a3055,I6582cfc6 am: 45562bfb63
am: 54b603ee56

Change-Id: I7fd99aa08ac1911eba06255a77e693d76b3d06ee
2018-03-29 00:29:35 +00:00
Josh Gao 2de2ade387 adbd: increase oom_score_adj for `adb shell`
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
2018-03-28 15:01:23 -07:00
Treehugger Robot 45562bfb63 Merge changes Iea2a3055,I6582cfc6
* changes:
  adb: start building windows test again.
  adb: fix windows test build.
2018-03-28 21:59:33 +00:00
Josh Gao 541a8656c4 adb: restore adb/adb.exe in the list of artifacts.
Test: m dist
Change-Id: Iba44a03e79af9242bfe36efb736496f8db720ebf
2018-03-28 12:57:48 -07:00
Luis Hector Chavez 006cf308f8 Merge "adb: Open FunctionFS files with more restrictive access modes" am: f78ff013d0
am: e74b0f224c

Change-Id: I0d11be7750f0a05838ecb9b9accd02e6a0b0fb2f
2018-03-26 19:03:48 +00:00
Treehugger Robot f78ff013d0 Merge "adb: Open FunctionFS files with more restrictive access modes" 2018-03-26 18:48:25 +00:00
Josh Gao f8a97c1f14 adb: start building windows test again.
Test: mma
Change-Id: Iea2a3055cc3642905a1bbdd18550a9fc12702da8
2018-03-23 15:37:20 -07:00
Josh Gao 2e1e789e2a adb: fix windows test build.
The switch over to soong unintentionally turned off building the
Windows tests (and there's a bug preventing them from being turned on).
Preemptively fix the build breakages that'll happen when we turn them
back on.

Test: mma with Android.bp 's/cc_test_host/cc_binary_host' hacks
Change-Id: I6582cfc61b96052537d50d8ba90533dbb66e3e1d
2018-03-23 13:03:28 -07:00
Jerry Zhang d3d2461662 adb: Retry io in case of interrupt
am: 6e9a327504

Change-Id: Icd93e7cd983924c3b8b85af2987d1e36b385030b
2018-03-23 05:12:41 +00:00
Jerry Zhang 6e9a327504 adb: Retry io in case of interrupt
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
2018-03-23 00:11:05 +00:00
Josh Gao 5651db553a Merge changes I5fe02059,Iea8bf298,I0630c302,Ifc4b8fe9,I29319bda am: d888e343b7
am: 32e239f139

Change-Id: I49fa0688d55b5e02637990f05cfd7f19cbb3d327
2018-03-22 04:07:46 +00:00
Josh Gao 8f7ff94762 adbd: spawn login shell when run without a command.
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
2018-03-21 18:23:09 -07:00
Josh Gao bf243a6128 adb: bump the local socket backlog to the maximum.
The listen backlog seems to be more meaningful on Darwin than on Linux,
resulting in connections failing with ECONNRESET. Bump it up to the
maximum supported value to make this less likely. 128 pending
connections ought to be enough for anybody.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: I5fe0205924188cf18ca1fc1204f923ab5523eeb2
2018-03-21 15:13:07 -07:00
Josh Gao 2c621ae741 adb: fix unicode file path test.
This test is failing due to:

     UnicodeWarning: Unicode equal comparison failed to convert both
     arguments to Unicode - interpreting them as being unequal'

Both arguments are already unicode, so stop encoding one side.

Test: python -m unittest test_device.FileOperationsTest.test_unicode_paths
Change-Id: Iea8bf29845ab3008ccf4c7dbd6969196e57ea25d
2018-03-21 15:13:07 -07:00
Josh Gao dcc055af64 adb: delete vestigial SHELL_EXIT_NOTIFY_FD.
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
2018-03-21 15:13:07 -07:00
Josh Gao 184f480547 adb: don't immediately close a socket when write fails.
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
2018-03-21 15:13:07 -07:00
Josh Gao 1222abc75b adb: make fdevent_run_on_main_thread's fd nonblocking.
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
2018-03-20 13:23:06 -07:00
Josh Gao 371cfe44ad Merge changes I6a842960,If618c26b am: 7920502065
am: c08a536a32

Change-Id: I29c44864fb1a955d3f2e07deb8bc970ee6c3faaf
2018-03-20 07:34:52 +00:00
Josh Gao fb2f969286 Merge "adb: skip IPv6 test if IPv6 isn't available." am: 46e59af921
am: c4072ed605

Change-Id: I5e66a4c56247e7f588feece0d1d8f6dee2dda278
2018-03-20 07:34:18 +00:00
Josh Gao 7920502065 Merge changes I6a842960,If618c26b
* changes:
  adb: add `adb shell exit 42` stress test.
  adb: improve socket tests.
2018-03-20 07:19:01 +00:00
Josh Gao 4abb5074be adb: skip IPv6 test if IPv6 isn't available.
Bug: http://b/69813298
Test: none
Change-Id: I0793e793bd52c5f1c639faedf09a513df263db78
2018-03-19 18:19:47 -07:00
Josh Gao c970aefada adb: add `adb shell exit 42` stress test.
Add a test to hammer on `adb shell exit $n` for flakiness.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: I6a842960f5b55ff739044698f5c9683992fc42f1
2018-03-19 16:14:53 -07:00
Josh Gao ecb96ac04d adb: improve socket tests.
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
2018-03-19 16:14:53 -07:00
Josh Gao 48aa138ac6 Merge changes I99b85f07,If28f6c8d am: 6156420fb7
am: 0204f8c2f2

Change-Id: I20b80d869279af82393c382ea837197633e4757c
2018-03-19 20:36:53 +00:00
Treehugger Robot 6156420fb7 Merge changes I99b85f07,If28f6c8d
* changes:
  adb: implement std::make_unique, start using it.
  base: export GetThreadId.
2018-03-19 20:14:33 +00:00
Josh Gao dede0946e2 Merge "adb: add test for flushing socket data after a write failure." am: 32caa9870f
am: aef43182dc

Change-Id: Ibeae383dd6a926beeb1d453aa42d22d3837c6f95
2018-03-17 00:07:09 +00:00
Josh Gao 31b5be69f4 adb: implement std::make_unique, start using it.
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
2018-03-16 15:35:52 -07:00
Josh Gao 5791e21697 base: export GetThreadId.
and stop using the incorrect (on Mac) version in adb..

Test: mma
Change-Id: If28f6c8d73b03db863be13ed88df81422c3aef87
2018-03-16 15:35:52 -07:00
Jerry Zhang 99499f1740 adb: Remove usages of ENDPOINT_ALLOC
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)
2018-03-16 15:33:26 -07:00
Josh Gao 32caa9870f Merge "adb: add test for flushing socket data after a write failure." 2018-03-16 22:18:43 +00:00
Bowgo Tsai 45a00fdcce adb: checks device state when using adb disable-verity for AVB
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
Merged-In: I1ed705e34334ea2231c96b16ddb8d225067af2f0
(cherry picked from commit 8cc9c3835a)
2018-03-16 15:06:23 +08:00
Bowgo Tsai 9c076a7889 Merge "adb: checks device state when using adb disable-verity for AVB" am: d5fc6bdd36
am: 8c91e2bfbb

Change-Id: I37f2a4134ba6cae182093856a7d669464c457712
2018-03-16 02:12:25 +00:00
Josh Gao df3bae9f06 adb: add test for flushing socket data after a write failure.
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
2018-03-15 15:33:01 -07:00
Bowgo Tsai 8cc9c3835a adb: checks device state when using adb disable-verity for AVB
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
2018-03-15 18:34:42 +08:00
Jerry Zhang 1fe8aa418b adb: Remove usages of ENDPOINT_ALLOC
am: 9a1be3ad0e

Change-Id: I2fc82dd02bc5d6f04a24dd299d0dfd99fd1a936e
2018-03-15 04:34:28 +00:00
Jerry Zhang 9a1be3ad0e adb: Remove usages of ENDPOINT_ALLOC
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
2018-03-14 22:11:59 +00:00
Luis Hector Chavez 3a3df404b4 adb: Open FunctionFS files with more restrictive access modes
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
2018-03-09 11:11:24 -08:00
Josh Gao 8020d1d8f5 Merge "adbd: don't require authentication for userdebug/eng builds." am: bf62136be4
am: 0360ada8f5

Change-Id: I386ebf095d083a1f34d0ba9d313e73f6aefdcac6
2018-03-07 21:48:47 +00:00
Josh Gao f01cf8dec5 Merge "adbd: make static." am: b41b33581e
am: 51c06da6ca

Change-Id: I9170ca4973d9ee066c1c9ad7d8cb4f90d92837b5
2018-03-06 23:32:15 +00:00
Josh Gao 6eda1840cb adbd: don't require authentication for userdebug/eng builds.
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
2018-03-06 13:37:45 -08:00
Josh Gao 8db99f810d adbd: make static.
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
2018-03-06 13:01:34 -08:00
Jerry Zhang 4d1ee695c5 Merge "Make libasyncio headers usable from C" am: 5180d5b4dc
am: e661d52573

Change-Id: I31c4f488ffb7523c1b2980246be400d388ac0a25
2018-03-06 20:47:25 +00:00
Jerry Zhang 5180d5b4dc Merge "Make libasyncio headers usable from C" 2018-03-06 19:35:21 +00:00
Josh Gao 360cf3703b Merge changes from topic "adb_bp" am: 9ee373ac2c
am: ca6ec5c48b

Change-Id: I1a9a4bc92bf48d1d0af6bf74f6f84d20d43d10c9
2018-03-06 01:36:57 +00:00