Commit graph

2947 commits

Author SHA1 Message Date
Josh Gao
d0fa13e5f7 adb: switch connect_to_remote to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: Icce121a4c62bf0fa636a35bcae31d057cdff8fd2
2018-12-26 11:48:14 -08:00
Josh Gao
bd76720955 adb: switch skip_host_serial to string_view.
Rename it to something more appropriate, while we're at it.

Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: I0f95d348eeacb45a810696d748c8340d2068f666
2018-12-26 11:48:14 -08:00
Josh Gao
3add0c4d42 adb: add stroll equivalent for string_view.
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: I1d89913474fcd1aa4a856b5e4583a3c1f076ddd4
2018-12-26 11:48:14 -08:00
Josh Gao
d19b77ac12 adb: finish switching service creation to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: If4ea92aee1c0264d946de72483f8d715d96fcfd8
2018-12-21 11:53:27 -08:00
Josh Gao
9dd1f5c0b7 adb: switch socket spec to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: I92c057215e041b98abb026628ea4acfba8a8132d
2018-12-21 11:53:27 -08:00
Josh Gao
e26154167c adb: switch daemon_service_to_fd to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: I298517b688650c9d94bf837284e0264ca0ac6702
2018-12-21 11:52:56 -08:00
Josh Gao
5021cfc135 adb: switch usb_linux helper to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: Iccbeb61905852b72fceec1bca498895b38a2e7d4
2018-12-21 01:43:34 -08:00
Josh Gao
0f29cbc750 adb: switch unix_open to string_view.
Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: Ieecc9b1b7f2111f4da45d4bbd1b7703535fe7d4d
2018-12-21 01:43:31 -08:00
Alex Buynytskyy
a9e79489dc Minor refactor to support strings with embedded zeros.
Test: manual
Change-Id: Iaece3003deb257cbcae65a23a4c4a1ccfd690d49
2018-12-20 10:11:15 -08:00
David Anderson
a5db1d72cf adbd: Automatically disable verity in adb remount.
Before overlayfs, we supported deduplicated filesystems by undoing
deduplication in recovery. This required an extra reboot cycle, so we
changed "adb remount" to disable verity and boot to recovery in one
command.

After overlayfs, adb remount is still trying to undo deduplication,
which leads to very confusing messages. This patch makes things a bit
clearer. "adb remount" will disable verity, which installs overlayfs.
"adb remount -R" will do the same except automatically reboot.

Bug: N/A
Test: adb remount on dynamic partitions device
Change-Id: Id72f6b9e2297c2f4d5722d5679f6264fe660e631
2018-12-17 13:15:05 -08:00
Treehugger Robot
17d41711c6 Merge "Change --fastdeploy behaviour" 2018-12-17 11:10:18 +00:00
Henry Daitx
ee01c80afe Change --fastdeploy behaviour
--fastdeploy does not require -r anymore, and reverts to a normal install
if the application is not already on the device.

Bug: 120828611

Test: mm -j72
Test: adb install --fastdeploy --force-agent --local-agent /mnt/raid/boat-attack-apk/boat-attack-swappy.apk
Change-Id: Ice2a71493a34ee7d0debabcce6a9aebb0af79e62
2018-12-14 15:25:15 +00:00
Josh Gao
78f94a39f2 Merge changes I042f25f8,I973f42c5,Icb4acea5
* changes:
  adbd: add source/sink services.
  adb: make `adb raw` bidirectional.
  adb: remove incorrect use of RTTI.
2018-12-13 01:26:49 +00:00
Josh Gao
6eb788298b adbd: add source/sink services.
Add some services that skip the service fd to see how much of a benefit
it'll be to eliminate it.

Test: adb raw source:$((300 * 1024 * 1024)) | pv > /dev/null
Test: dd if=/dev/zero bs=1M count=100 | pv | adb raw sink:$((100 * 1024 * 1024))
Change-Id: I042f25f85b16ae9869cb1f1e306d8671b024ed97
2018-12-12 12:54:28 -08:00
Josh Gao
e89a55dd41 adb: make adb raw bidirectional.
Test: adb raw shell:
Change-Id: I973f42c55c71ffd125e58f76d29100a2d5b0c308
2018-12-12 12:54:28 -08:00
Josh Gao
ce5ce87a66 adb: remove incorrect use of RTTI.
We were dynamic_casting to UsbConnection to check for USB connections,
but the actual type was a BlockingConnectionAdapter wrapping a
UsbConnection, with the result that unplugging an inaccessible (due to
permissions) device on Linux wouldn't make the device go away.

Test: manual
Change-Id: Icb4acea5fd3c3baa9691698686213e122e898e4a
2018-12-12 12:54:03 -08:00
Treehugger Robot
fe3becb56b Merge "Fix performance-for-range-copy warnings" 2018-12-12 17:46:46 +00:00
Tom Cherry
23319ebebf Start using new C++ Fstab class widely
Bug: 62292478
Test: boot
Test: adb-remount-test.sh

Change-Id: Id4715af4c1f03e2cfc67de92d3ea58e933685e51
2018-12-12 17:08:09 +00:00
Chih-Hung Hsieh
1b7b7979af Fix performance-for-range-copy warnings
Bug: 30413223
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,performance*
Change-Id: I3ad102f2b0f971266d57488a3bd57d312f7ee3e6
2018-12-11 10:51:13 -08:00
Treehugger Robot
bcc2d60826 Merge "Removes ASEC-related install flags" 2018-12-07 18:11:09 +00:00
Patrick Baumann
24439442a8 Removes ASEC-related install flags
Bug: 109941548
Test: install still works
Change-Id: Ibaf87e678217a1ce140b4024d16ceb8d27fadec0
2018-12-07 16:15:31 +00:00
Henry Daitx
f21edf3edd Fix adb not correctly reading return code from DeployAgent
Certain error conditions were getting lost because adb was wrongly
reading DeployAgent's return code as always 0.

Test: mm -j 72
Test: adb install -r --fastdeploy --force-agent --local-agent /mnt/raid/boat-attack-apk/boat-attack-swappy.apk

Bug: 120197330
Change-Id: If835fd6ca2051be8e5ff6c957e08b1e458053989
2018-12-06 15:46:38 +00:00
Treehugger Robot
46d19d34d1 Merge "adb: fix authentication when reconnecting." 2018-12-04 20:41:14 +00:00
Treehugger Robot
239245fe79 Merge "Enable the APEX support on the device side." 2018-12-04 12:29:06 +00:00
Josh Gao
4414e4c728 adb: fix authentication when reconnecting.
If we have multiple keys available for authentication (ADB_VENDOR_KEYS
+ the one in ~/.android), we will still have keys in our list of
avilable keys after we've successfully connected. A subsequent
reconnection will start authorizing using the list of keys after the
key that actually worked, resulting in that session being unauthorized
until another reconnection happens. Clear the key list before
reconnecting to fix this. (We could do this after successfully
connecting, but we need to do this before reconnecting anyway, because
our connection could have died during authorization.)

Bug: http://b/117267347
Test: `adb connect foo; adb -s foo reconnect device` with ADB_VENDOR_KEYS
Change-Id: Ieb7dcc28e333c89ae0d75f97e89bcd1b571cb299
2018-12-04 01:08:55 -08:00
Treehugger Robot
a7f54b1592 Merge "C++17 is the default now." 2018-12-04 07:53:24 +00:00
Jaewoong Jung
7174ec8fff Merge "Revert "Revert "Revert "adb: append the libwinpthread COPYING to adb's NOTICE."""" 2018-12-03 23:57:42 +00:00
Elliott Hughes
3c59cb8420 C++17 is the default now.
Test: builds
Change-Id: I6814455e9ad2cdcf99ad66de38a3ad0bfb440d80
2018-12-03 09:02:18 -08:00
Josh Gao
919b70cde1 Enable the APEX support on the device side.
Test: on device
Merged-In: Ic6e237556fa059e02cf9c55d1c034947b7dfb405
Change-Id: Ic6e237556fa059e02cf9c55d1c034947b7dfb405
2018-12-03 22:29:52 +09:00
Idries Hamadi
fafd21159c Merge "Fix fastdeploy issues when testing Boat Attack Unity3D demo" 2018-11-30 08:43:05 +00:00
Jaewoong Jung
0e55778f4e Revert "Revert "Revert "adb: append the libwinpthread COPYING to adb's NOTICE."""
This reverts commit 1272e7a592.

Reason for revert: All notice fix changes have been merged and running peacefully for a sustained period. Now this can be reverted for good.

Change-Id: I74e4e291a504fcb9a14ae50e916e494c7359db34
2018-11-29 23:14:02 +00:00
Idries Hamadi
49cdcfd3f3 Fix fastdeploy issues when testing Boat Attack Unity3D demo
The --fastdeploy switch caused errors when CRC collisions were present in the input apk and/or
an apk with a similar package name to the input apk was already installed on the device.

Test: mm -j 64
Test: adb install -r --fastdeploy --force-agent --local-agent /mnt/raid/boat-attack-apk/boat-attack-swappy.apk

Bug: 119934862
Change-Id: Ibfe0cec38bdbb7371803fc2f73b0ec1697cef624
2018-11-29 14:16:04 +00:00
Idries Hamadi
484f88bcef Add OWNERS file to fastdeploy so idries@ can approve changes
Test: None
Change-Id: If04c5cadd04b0b866b3e5b73e9e2d5d70db20881
2018-11-28 16:55:00 +00:00
Treehugger Robot
fa105049d8 Merge "adb: stop using adbkey.pub." 2018-11-27 21:35:44 +00:00
Dan Willemsen
3f439a7a88 Switch from dist-for-goals to dist in Android.bp
Removes a few more Android.mk files.

Test: check for adb, mkbootfs, and fastboot in the build artifacts
Change-Id: Ie4e50a363a734d0b9207f0d0098c54719f038e76
2018-11-19 23:06:12 -08:00
Yifan Hong
0e0f818c8a logical -> dynamic partitions.
Reflect a name change.
Test: boots
Bug: 119286600

Change-Id: I076071be18be521eeee4ebae10491b9f3e8ef857
2018-11-16 12:53:18 -08:00
Josh Gao
2dc4cabe06 adb: stop using adbkey.pub.
An adbkey/adbkey.pub pair that doesn't match up results in a
hard-to-diagnose scenario where "Always allow from this computer"
doesn't work. The private key contains all of the information that's
in the public key, so just extract the public key out of the private
key instead of storing them separately.

Bug: http://b/119634232
Test: rm ~/.android/adbkey.pub; adb kill-server; adb shell true
Test: rm ~/.android/adbkey*; adb kill-server; adb shell true
Change-Id: I0ae9033dbcd119c12cfb2b3977f1f1954ac800c1
2018-11-15 17:50:57 -08:00
Mark Salyzyn
9f1cf25332 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I4f7ad84743e974b4b4d1d7256088f6c8b749a237
2018-11-14 09:35:34 -08:00
Josh Gao
1289e1ec65 Revert "adb: make benchmarks build on the host."
This reverts commit 80dd70d285.

Breaks the darwin build.

Change-Id: If95266c6fc027cf2a706f3c83dce7e50b762b8aa
2018-11-13 11:28:29 -08:00
Josh Gao
bc4dbfafb1 adb: fix NonblockingFdConnection's behavior with large writes.
Large opportunistic writes would perform a write without updating
writable_ or waking up the polling thread, which resulted in the worker
thread never polling with POLLOUT.

Test: adb_benchmark
Change-Id: Ifed3b97a4b647b539dcd2df858572fa7da9a22d0
2018-11-12 20:54:39 -08:00
Josh Gao
10d079a37b adb: fix zero-initialization in Block.
Iccfe3bd4fe45a0319bd9f23b8cbff4c7070c9f4d changed Block from using
malloc to std::make_unique, which does the equivalent of
`new char[size]()`, which value initializes the array members to 0.
Switch to `reset(new char[size])` to avoid this costly initialization.

Test: adb_benchmark
Change-Id: I09aacb949a7bd4a946ce35a8ee65d1f451577b72
2018-11-12 20:54:39 -08:00
Josh Gao
80dd70d285 adb: make benchmarks build on the host.
Test: adb_benchmark
Change-Id: I9afedd7bdcf645652e514d98bb88036753718168
2018-11-12 20:54:30 -08:00
Josh Gao
68b5d0c3e3 adb: flush stderr after logging on Windows.
Test: set ADB_TRACE=1 & adb.exe server nodaemon
Change-Id: Ibb109618be7eaae49461a306e34ff79451ec330e
2018-11-12 14:08:40 -08:00
Josh Gao
cd85556151 adb: libusb: don't set interface alternate setting.
Match behavior with the legacy implementation.

Test: ADB_TRACE=1 adb server nodaemon
Change-Id: If1451871f252ef4499b3bb887e947169f8d2432f
2018-11-12 14:08:40 -08:00
Josh Gao
6a08b2c255 Merge "adb: pin USB interface versions on darwin." 2018-11-09 18:45:52 +00:00
Josh Gao
b35ee22887 adb: pin USB interface versions on darwin.
It's possible to build against an SDK that's newer than the OS that
we're actually running via Xcode update, and Apple increments the
unversioned IOKit interface IDs to the newest version on every release,
which leads to mysterious failures to acquire an interface.

Pin the interface versions to IOUSBFamily 5.0.0, which shipped on OS X
10.7.3.

Bug: http://b/119264733
Test: ./test_device.py
Change-Id: Id26760bc62c89a1f7ef67511b21f9d9252ab69f3
2018-11-08 16:49:46 -08:00
Josh Gao
9c27dde899 Merge "adb: switch version back to 40." 2018-11-08 21:31:54 +00:00
Spencer Low
14022c2266 adb: win32: improve console output on Windows 10
Use Windows 10's improved virtual terminal emulation to handle more
terminal sequences, to fix console resize artifacts, and to fix issues
with the last column.

`top' and `more' work well now.

Use a sensible default TERM value of xterm-256color.

Test: manual on Windows 10
Bug: https://issuetracker.google.com/issues/37081235

Change-Id: If6612f3bb7db1ecaaa4b7930c9e54075ba7abb3f
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-11-06 20:36:58 -08:00
Mark Salyzyn
beb4cb8e43 adb: overlayfs failed to remount /system
Regression introduced commit bb1efbd1c6

By not first checking if overlayfs mount on /system is in /proc/mounts
remount fails to discover the override and take the selected action.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: I1f0bae22caae1bca84fc1e33b508b54d98f4ed5c
2018-11-06 09:49:10 -08:00
David Anderson
15e1b3b85a Merge "adbd: Fix adb remount when switching roots during first-stage init." 2018-11-03 03:17:30 +00:00
Jaewoong Jung
c728550de7 Merge "Revert "Revert "adb: append the libwinpthread COPYING to adb's NOTICE.""" 2018-11-02 23:05:49 +00:00
Jaewoong Jung
1272e7a592 Revert "Revert "adb: append the libwinpthread COPYING to adb's NOTICE.""
This reverts commit 6374076ce4.

Reason for revert: The Soong side change broke darwin_mac build.

Change-Id: I8d3c1d4e075c333b4890cb620dd106d16800d7f4
2018-11-02 23:00:50 +00:00
Jaewoong Jung
d465c7e52d Merge "Revert "adb: append the libwinpthread COPYING to adb's NOTICE."" 2018-11-02 22:25:34 +00:00
Jaewoong Jung
6374076ce4 Revert "adb: append the libwinpthread COPYING to adb's NOTICE."
This reverts commit d3bf1a8d7e.

Reason for revert: Now Soong can handle NOTICE files for static libraries.

Bug: 36073965
Test: mma + visual check
Change-Id: I52ebd3518f4d15800f878a6401df2c3a2d6713eb
2018-11-01 22:33:21 +00:00
Josh Gao
4f911e3bf6 adb: switch version back to 40.
The version bump we did wasn't actually needed, since adbd doesn't
check for either feature flag we added. Revert the change and clarify
the comment suggesting the version bump when adding features.

Test: ./test_adb.py
Test: ./test_device.py
Change-Id: I92e7f392bcb36b3bf9a236f2d31ba5133de8d72a
2018-11-01 13:25:31 -07:00
bohu
09faa66006 adb: print emulator console output
It is very helpful to see the output of the following adb command:
adb emu <emulator commands...>

Change-Id: I7905370fb955de4d457a323a7e9e780aaca5d45e
2018-10-30 14:36:33 -07:00
Victor Hsieh
02ef4bb190 adb install-multiple to also accept .fsv_sig
.fsv_sig will be fs-verity signature in PKCS#7 format.

Test: adb install-multiple foo.apk foo.apk.fsv_sig
Bug: 112037636
Change-Id: I4a9b2203334d4974602c7f138222ade1aa319ccb
2018-10-29 16:55:06 -07:00
David Anderson
bb1efbd1c6 adbd: Fix adb remount when switching roots during first-stage init.
This patch addresses two issues with adb remount.

First, the blk_device field in fstab_rec will be incorrect if referring
to a device-mapper node (fs_mgr_update_logical_partition must be
called).

Second, devices that are not system-as-root now move their mount point
and chroot to "/" during first-stage init. However, the fstab entry will
have "/system" as its mount point. The new logic now reflects this.

Bug: N/A
Test: adb remount on hikey or device with dynamic partitions
Change-Id: I48b379db49d2def555ea49888c4994fbcf501672
2018-10-26 13:51:32 -07:00
Treehugger Robot
9b6da16849 Merge "adb: Use a default _SC_GETPW_R_SIZE_MAX size" 2018-10-25 00:24:56 +00:00
Robert Yang
88c997d4eb adb: Use a default _SC_GETPW_R_SIZE_MAX size
sysconf(_SC_GETPW_R_SIZE_MAX) may return −1 if there is no hard limit
on the the buffer size. Some libc implementations such as musl don't
define this limit and will return -1.

Use a default buffer size to handle this case.

Change-Id: I997b13a2c2dca00574e049a259135e61c8ed8e03
Signed-off-by: Robert Yang <decatf@gmail.com>
2018-10-24 15:23:55 -04:00
bohu
ea0c3cbc18 adb: correct tcpip help message
'adb tcpip <mode>' is meant to affect adbd, not
the host adb server.

BUG: 111434128
Change-Id: I78c958bfbede60b20fb7e0f2444e5b21ecb90f7a
2018-10-24 10:38:33 -07:00
Josh Gao
fb08510784 Add feature flag for b/110953234 fix.
Bug: http://b/110953234
Bug: http://b/117946501
Test: adb features
Test: test_device.py
Change-Id: I340a30544a6d0ab1b2545e5371c8f98d04158c56
2018-10-23 18:28:46 +00:00
Dario Freni
29814deaa7 Accept apex packages as argument.
Bug: 112669193
Test: Successfully reaches PackageManager. Doesn't break existing flows.
Change-Id: If4a173e290ebf0b70beb97111a6d75400da7ec8d
2018-10-23 11:07:16 +01:00
Treehugger Robot
33eb652783 Merge "adb: don't use <error.h>." 2018-10-23 03:53:50 +00:00
Elliott Hughes
d2aaede610 adb: don't use <error.h>.
This should fix the bloody Mac build, which doesn't have <error.h>. Since
we weren't entirely happy with error(3) anyway, switch to the toybox
style of error_exit and perror_exit, which are slightly briefer and quite
a bit more intention-revealing.

Bug: N/A
Test: builds
Change-Id: Ic8e411906c363af51657da5ce947b25a0b6bb1f3
2018-10-22 17:04:32 -07:00
Josh Gao
f5518d04f1 Merge "adb: set main thread in transport tests." 2018-10-22 20:01:44 +00:00
Josh Gao
95a3916ef9 Merge changes I9b77c105,I0b369d16,I59602c20,Iae4f3d55
* changes:
  adbd: implement a nonblocking USB Connection.
  adbd: rename daemon/usb.cpp to daemon/usb_legacy.cpp.
  adbd: open functionfs ep0 as O_RDWR.
  adbd: extract functionfs fd creation.
2018-10-22 19:45:33 +00:00
Josh Gao
c51726cbec adbd: implement a nonblocking USB Connection.
Implement a Connection that implements a nonblocking interface to
functionfs, to replace the existing implementation that uses two
threads that loop and call read and write respectively. The existing
implementation is vulnerable to a race condition that can occur when a
connection is terminated, where one thread can notice failure and
complete reinitialization of the USB endpoints before the other thread
noticed anything went wrong, resulting in either the first packet
coming from the other end disappearing in to the void, or the other end
getting a packet of garbage.

As a side benefit, this improves performance on walleye from:

    push 100MiB: 10 runs: median 49.48 MiB/s, mean 50.00 MiB/s, stddev: 2.77 MiB/s
    pull 100MiB: 10 runs: median 75.82 MiB/s, mean 76.18 MiB/s, stddev: 6.60 MiB/s

to:

    push 100MiB: 10 runs: median 73.90 MiB/s, mean 73.51 MiB/s, stddev: 5.26 MiB/s
    pull 100MiB: 10 runs: median 105.90 MiB/s, mean 107.19 MiB/s, stddev: 6.10 MiB/s

Test: python test_device.py
Change-Id: I9b77c1057965edfef739ed9736e5d76613adf60a
2018-10-19 17:53:18 -07:00
Josh Gao
7badb33233 adb: set main thread in transport tests.
Previously, we were relying on tests run previously to set the main
thread ID, which fails when the tests are sharded.

Test: for i in `seq 0 4`; do GTEST_SHARD_INDEX=$i GTEST_TOTAL_SHARDS=5 /data/nativetest64/adbd_test/adbd_test; done
Change-Id: I15ce70b4598b6ffcf3f5467d16c917f23f668daf
2018-10-19 15:38:10 -07:00
Elliott Hughes
4679a39610 adb: rationalize fatal/error logging.
Let's use LOG(FATAL)/PLOG(FATAL) for actual fatal stuff.

Add a Windows error(3) and move folks who didn't really mean "abort"
fatal over to it. Also get rid of syntax_error which wasn't adding a
lot of value, and most of the places it was adding "usage: " didn't seem
entirely appropriate anyway.

In particular, we seemed to have confused fastdeploy.cpp into aborting
in most user error cases, and none of the reviewers noticed. Clearly
we'd all lost track of far too many options.

(I've also cleaned up a few random instances of fprintf(3) + exit(2).)

Bug: N/A
Test: manual
Change-Id: I3e8440848a24e30d928de9eded505916bc324786
2018-10-19 14:04:24 -07:00
Josh Gao
61e9e39b7e adbd: rename daemon/usb.cpp to daemon/usb_legacy.cpp.
Change-Id: I0b369d1653220f7d9b542ad06998c5c2c3e129a2
Test: mma
2018-10-18 13:58:06 -07:00
Josh Gao
d506dac0a0 adbd: open functionfs ep0 as O_RDWR.
We need to read from ep0 to poll for events.

Test: test_device.py
Change-Id: I59602c20f5dfdb17bfbab13d3033e9333a51caf3
2018-10-18 13:58:06 -07:00
Josh Gao
613cbb42e6 adbd: extract functionfs fd creation.
Extract common functionality that will be useful for implementing a
nonblocking Connection for functionfs.

Test: mma
Change-Id: Iae4f3d55b2f56568d4a5138db9a2af5622eb83ad
2018-10-18 13:58:06 -07:00
Treehugger Robot
321a60f156 Merge changes Ic8d22016,I3e15296e,Ie275e22c
* changes:
  adb: improve benchmark script a bit.
  adb: extract helper for dumping a packet header.
  adbd: turn on -Wthread-safety.
2018-10-18 20:25:53 +00:00
Josh Gao
f2eaefe368 Merge "test_adb.py: silence ResourceWarning." 2018-10-17 21:10:45 +00:00
Josh Gao
42c86722fc test_adb.py: silence ResourceWarning.
Test: ./adb_test.py
Change-Id: If12558492e4edafd3568530a96eac2032526877d
2018-10-16 11:00:39 -07:00
Josh Gao
6c060cf180 adb: improve benchmark script a bit.
Test: none
Change-Id: Ic8d220163ee764fee5fb5887a495557c16703187
2018-10-12 18:03:50 -07:00
Josh Gao
99d3d705f0 adb: extract helper for dumping a packet header.
Test: mma
Change-Id: I3e15296eb917d9df11ca13591d26d3aa54d66412
2018-10-12 16:38:52 -07:00
Josh Gao
560a547db4 adbd: turn on -Wthread-safety.
not_windows doesn't include android...

Test: treehugger
Change-Id: Ie275e22c895b0c88ce9d9f677750d2bffeeebc42
2018-10-12 16:38:52 -07:00
Julien Desprez
618f0e11d6 Add adb_integration_test_device to general-tests
Run some more tests for adb.

Test: tradefed.sh run template/local_min --template:map test=atest --include-filter adb_integration_test_device --log-level VERBOSE --log-level-display verbose
Bug: 112104122
Change-Id: I44b5a2aed8d86ab2dca62081d5b3b05f6e01cabd
2018-10-12 13:48:14 -07:00
Josh Gao
58d5906be3 Merge "Revert "adb: don't close sockets before hitting EOF."" 2018-10-12 06:38:55 +00:00
Josh Gao
faf1328a64 Revert "adb: don't close sockets before hitting EOF."
This reverts commit ffc11d3cf3.

Reason for revert: DeviceIdleFreqCheckTest failing

Bug: http://b/117630047
Change-Id: Ia51a4a30e785bc5b2526695de3f442aac298198f
2018-10-12 05:08:45 +00:00
Treehugger Robot
11cbf7d711 Merge "adb: add reboot-fastboot command" 2018-10-12 03:38:05 +00:00
Mark Salyzyn
d8e94bd3f2 adb: add reboot-fastboot command
Alias reboot-fastboot to reboot fastboot

Test: manual
Bug: 117604012
Change-Id: I5f7842e420fbc0b1d9ae8e1231887fb8644b29e9
2018-10-11 13:21:16 -07:00
Pirama Arumuga Nainar
a2ccce870c Merge changes from topic "windows-libcxx"
* changes:
  Do not enable -Wold-style-cast for Windows
  Add sys/types.h in utf8.h
  Adapt to switch to libc++ for Windows
2018-10-11 17:00:53 +00:00
Idries Hamadi
86554e949b Merge "Reverted aapt dependency to be a dependency on libandroidfw" 2018-10-11 06:15:04 +00:00
Josh Gao
2185d8ceef Merge "adb: don't close sockets before hitting EOF." 2018-10-10 18:13:01 +00:00
Treehugger Robot
3614b39bb9 Merge "adb: identical symlink, do not update" 2018-10-08 19:52:20 +00:00
Josh Gao
f3186de123 Merge changes Ia4244757,Ibcdf69d9
* changes:
  adbd: clean up jdwp service a bit.
  Revert "Revert "adb: detect some spin loops and abort.""
2018-10-08 17:45:23 +00:00
Mark Salyzyn
376e3cbb50 adb: identical symlink, do not update
Inefficient to always update the symlinks to overlayfs, can
also lead to

    failed to copy 'xxx' to 'yyy': remote symlink failed: File exists

on older variants of overlayfs that do not effectively mark them
deleted.

Test: manual
Bug: 109821005
Change-Id: If1286d76f45ce14087cdb515fe8d2fed198fd9d8
2018-10-08 10:37:10 -07:00
Josh Gao
15dcc62c72 adbd: clean up jdwp service a bit.
Change-Id: Ia42447576b047dfa9ddc0b73b87adc8114e3f20f
Test: ./test_device.py
2018-10-05 17:23:44 -07:00
Josh Gao
39c1f4bca5 Revert "Revert "adb: detect some spin loops and abort.""
This reverts commit 04b9ca8c31.

The original incarnation of this patch was falsely triggering when our
poll would block with no activity happening for an extended amount of
time. When the poll returned, we would immediately flag that as a spin
loop. Solve this by tracking the last time we looped, to detect this.

While we're at it, switch from CLOCK_MONOTONIC to CLOCK_BOOTTIME, for
the same reason.

Change-Id: Ibcdf69d93f7b6012142cafd72066f39494c1f84b
Test: ./test_device.py
2018-10-05 17:23:44 -07:00
Idries Hamadi
269a4b422b Reverted aapt dependency to be a dependency on libandroidfw
Removed call to external aapt2 process
Replaced several layers of error handling with calls to fatal()
Changed output messages for failures to be more useful for diagnostics

Bug: 116753196
Test: mm
Test: adb install -r --fastdeploy --force-agent --local-agent ~/example_apks/example.apk
Test: adb install -r --fastdeploy --no-streaming --force-agent --local-agent ~/example_apks/example.apk

Change-Id: I6006d8aa584e789a086a31e79a41d1416e54402a
2018-10-05 17:55:05 +01:00
Chih-Hung Hsieh
747eb149d0 Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: I5a7461386946ca623ab509609092aa0ac8418b80
2018-10-05 16:43:47 +00:00
Josh Gao
ffc11d3cf3 adb: don't close sockets before hitting EOF.
The standard (RFC 1122 - 4.2.2.13) says that if we call close on a
socket while we have pending data, a TCP RST should be sent to the
other end to notify it that we didn't read all of its data. However,
this can result in data that we've succesfully written out to be dropped
on the other end. To avoid this, instead of immediately closing a
socket, call shutdown on it instead, and then read from the file
descriptor until we hit EOF or an error before closing.

Bug: http://b/74616284
Test: ./test_adb.py
Test: ./test_device.py
Change-Id: I36f72bd14965821dc23de82774b0806b2db24f13
2018-10-04 14:01:07 -07:00
Victor Hsieh
8e27656a9a Restore lost .dm support of adb install-multiple
Apparently some changes are lost in
https://android-review.googlesource.com/c/platform/system/core/+/600457.

Test: adb install-multiple foo.apk foo.dm
Bug: 117092647
Change-Id: I87a6e1509de809624254c77073d922617f222ed2
2018-10-04 10:46:56 -07:00
Tao Bao
546b539b47 Merge "Support > 2GiB seeks in adb_lseek." 2018-10-03 14:59:01 +00:00
Treehugger Robot
4eb864bf7d Merge "allow adb to remount symlink mount points" 2018-10-02 23:41:40 +00:00
Bowgo Tsai
41649b871a allow adb to remount symlink mount points
Currently `adb remount` won't remount symlink mount points.
In Android Generic System Image, there is a symlink
/product -> /system/product for devices with and without a physical
/product partition to work, respectively:

  - Mount product partition under /system/product via
    'mount /product' OR

  - Keep using /product -> /system/product symlink,
    when no product partition

Currently find_proc_mount() is seeking "/product" under /proc/mounts.
But the actual mount path is "/system/product" when GSI is used
on a device with product partition.

Bug: 111539442
Test: adb remount && touch /product/abc on both GSI and non-GSI

Change-Id: I8f15a67109d0a3f4ee18596ef7eb4280c5631b11
2018-09-28 12:47:27 +08:00
Elliott Hughes
cabfc3dc80 Support > 2GiB seeks in adb_lseek.
Also stop using size_t (which will be 32-bit on Win32) for offsets in
adb_sideload_host, and stop truncating large file sizes in our
"sideload-host" messages.

Bug: http://b/112003354
Test: builds
Change-Id: If5b7cc9d1fc7ff7ca6eaebd20418f7b061846203
2018-09-26 14:48:05 -07:00