aboutsummaryrefslogtreecommitdiff
path: root/adb.h
AgeCommit message (Collapse)Author
2021-12-02adb --one-device feature.Vince Harron
Added support for a new server option, --one-device. When a server is started with that option, it will only communicate with the USB device serial number or device address specified. This allows multiple adb servers to run in parallel on a single host, each communicating only with a single USB device. example usage: $ adb --one-device usb:2-4 -P 1138 start-server $ adb --one-device usb:2-6 -P 1139 start-server $ adb -P 1138 devices -l List of devices attached 97221FFBA00016 device usb:2-4 transport_id:1 $ adb -P 1139 devices -l List of devices attached 13031FDEE0000C device usb:2-6 transport_id:1 Test: Manually tested as shown above with & without libusb, Linux & macOS. Change-Id: Ibc4e3df7ecdefce737291185fa6a84071bff5340
2021-07-02Add test for ConnectionState to_string.Josh Gao
Test: treehugger Change-Id: I0d9fa8195075b8586348622ce6a68a71d024193e
2021-06-21Add attach/detach support to libusb backend.Josh Gao
Bug: http://b/186595076 Test: treehugger Change-Id: I93f3c3e3bd28e9cd0c08e89d6c9454d36d8206f8
2020-04-06adb: add option to disable kill-server.Josh Gao
In the post-apocalypse, it's increasingly common for people to use ssh port forwarding to use an adb client with a remote adb server. This results in `adb kill-server` being catastrophic, because the client has no way of restarting the server on the other end. Android Studio in particular has an unforunate habit of trying to manage adb's life cycle such that starting or exiting Studio will result in a kill-server. Add the ADB_REJECT_KILL_SERVER environment variable which ignores kill-server, to make this scenario a bit better. Bug: http://b/152251952 Test: ADB_REJECT_KILL_SERVER=1 adb start-server; adb kill-server Change-Id: I5533a6dcbdb9220526a6fcf9ca31d9fcef1cec17
2020-03-30Move adbd's legacy USB implementation to fastboot.Josh Gao
This code path is effectively dead in adbd, and fastboot's dependency on libadbd makes it hard to refactor adbd's dependencies. Bug: http://b/150317254 Test: built and flashed aosp_walleye-eng Change-Id: I5118136d32fdcbbd011559ed0a4a71e1dc7bf064
2020-03-06"track-app" service showing debuggable/profileable appsShukang Zhou
Add a "track-app" service in adbd. For every debuggable or profileable-from-shell process, ART sends related info to adbd and adbd surfaces the info through the "track-app" service. The output format of "track-app" is a line summarizing the number of reported processes, followed by a protobuf message in human readable form. For example, Process count: 2 process { pid: 3307 profileable: true architecture: "arm64" } process { pid: 3341 debuggable: true profileable: true architecture: "arm64" } Bug: 149050485 Test: manually unplugged/replugged, "adb track-app", "adb track-jdwp" Change-Id: Id1f1a920e1afc148c7e4d2add790baab796178e1
2020-02-21[adbwifi] Add A_STLS command.Joshua Duong
This command will be sent by adbd to notify the client that the connection will be over TLS. When client connects, it will send the CNXN packet, as usual. If the server connection has TLS enabled, it will send the A_STLS packet (regardless of whether auth is required). At this point, the client's only valid response is to send a A_STLS packet. Once both sides have exchanged the A_STLS packet, both will start the TLS handshake. If auth is required, then the client will receive a CertificateRequest with a list of known public keys (SHA256 hash) that it can use in its certificate. Otherwise, the list will be empty and the client can assume that either any key will work, or none will work. If the handshake was successful, the server will send the CNXN packet and the usual adb protocol is resumed over TLS. If the handshake failed, both sides will disconnect, as there's no point to retry because the server's known keys have already been communicated. Bug: 111434128 Test: WIP; will add to adb_test.py/adb_device.py. Enable wireless debugging in the Settings, then 'adb connect <ip>:<port>'. Connection should succeed if key is in keystore. Used wireshark to check for packet encryption. Change-Id: I3d60647491c6c6b92297e4f628707a6457fa9420
2020-01-13Remove leftover support for target-as-hostKevin Brodsky
Support for target-as-host was removed by a30c38b3aa7c ("Fix win_sdk build."), so ADB_HOST_ON_TARGET is never defined. Test: build Change-Id: I5ab27e68208677266e2e4272bc2bae7d6a097c5d
2019-12-04Enable "localfilesystem" UNIX domain socket for ADB.Jason Jeremy Iman
This patch introduce "service.adb.listen_addrs", a new string type property, while keeping the old properties. The new property added in this patch is used to listen on UNIX domain socket "localfilesystem". "service.adb.listen_addrs" can be used to listen on multiple addresses, such as tcp:5555 and tcp:5556. It is separated by ',' (comma) character. In the process of introducing the new socket type, the method tcp_connect is removed and combined into socket_spec_connect. Without specifying using the new property, adb will try to listen on both tcp and vsock (following the previous implementation). Some examples of the new property value are: - "tcp:5555" - "vsock:5555" - "localfilesystem:/tmp/test" - "tcp:5555,vsock:5555" Bug: 133378083 Test: On master-arc-dev: adb root; setprop service.adb.listen_addrs localfilesystem: <path_to_socket>; adb connect localfilesystem:<path_to_socket>; adb -s localfilesystem:<path_to_socket> shell; inside Chrome OS. Test: On aosp_bluefin: setprop service.adb.listen_addr tcp:5555; adb connect <IP>:5555; adb shell; Test: On aosp_bluefin: setprop service.adb.tcp.port 5555; adb connect <IP>:5555; adb shell; Test: On aosp_bluefin: setprop service.adb.listen_addrs tcp:5555,tcp:6666; adb connect <IP>:5555; adb shell; adb connect <IP>:6666; adb shell; Test: On aosp_bluefin: ./adb_test; Test: On cuttlefish: launch_cvd; adb -s 127.0.0.1:6520 shell; Test: Ran host tests: ./adb_test; ./adb_integration_test_adb; ./adb_integration_test_device; Change-Id: I8289bf0ab3305cf23ce5695ffba46845d58ef6bb
2019-07-09adb: move fdevent to its own folder.Josh Gao
am: b51193a16a Change-Id: I1f9e0da9a94c8889c378e8ca9dd9b37a48dca58b
2019-07-08adb: move fdevent to its own folder.Josh Gao
Preparatory refactoring for platform-specific implementations. Test: mma Change-Id: I0f600122ac89241788c5f3300f362fd9ef02ddcd
2019-05-09Notify the framework when an adb key is authorizedMichael Groover
Bug: 124076524 Test: atest AdbDebuggingManagerTest Change-Id: If73b81ca73ba4d64763cf49c1bbe42de81fa1cb6
2019-04-26adb: Recognize rescue mode.Tao Bao
This CL adds client support to recognize the rescue mode (which will be served by recovery image). It also allows waiting for a device to enter rescue mode. The support for the actual rescue commands will be added in follow-up CLs. Bug: 128415917 Test: `adb devices` recognizes devices under rescue mode. Test: `adb wait-for-rescue` waits for device to be in rescue mode. Change-Id: I367d7339fe68006aba09a1e3db6370d472296676 Merged-In: I367d7339fe68006aba09a1e3db6370d472296676 (cherry picked from commit 55d407ec4a0b23f1e20db298b4989068a820087f)
2019-04-17adb: Recognize rescue mode.Tao Bao
This CL adds client support to recognize the rescue mode (which will be served by recovery image). It also allows waiting for a device to enter rescue mode. The support for the actual rescue commands will be added in follow-up CLs. Bug: 128415917 Test: `adb devices` recognizes devices under rescue mode. Test: `adb wait-for-rescue` waits for device to be in rescue mode. Change-Id: I367d7339fe68006aba09a1e3db6370d472296676
2019-02-25adb: increment server version.Josh Gao
Increment the server version for adb_connect with transport id, and wait-for-disconnect. Bug: http://b/124244488 Test: none Change-Id: Ib50d289b68fce4befbf1f5d9507d7e6f9cc1f4f5
2019-02-25adb: tell the client what transport it received.Josh Gao
Prerequisite for making `adb root` wait for the device that it told to restart to disappear: the client needs to know which transport to wait on. Bug: http://b/124244488 Test: manual Change-Id: I474559838ad7c0e961e9d2a98c902bca3b60d6c8
2019-02-25adb: switch host_service_to_socket to string_view.Josh Gao
Test: manual Change-Id: I09b83cc82edb10c1a51ecc5ebb8d9fe5294222c3
2019-02-25adb: switch handle_host_request to string_view.Josh Gao
Test: test_adb.py Test: test_device.py Change-Id: Ideae5262a6dff2e27c50f666144d48f874837290
2019-02-23Adding EXEC version of calling ABB.Alex Buynytskyy
This is corresponding to exec: command of adb and allows for simplifed calls to binder without shell protocol. Bug: 111621042 Test: manual Change-Id: Id6935cd53e351388ecf6d2d15f3a204cb871536a
2019-01-23adb: convert more stuff to unique_fd.Josh Gao
Test: adb_test Test: adbd_test Test: test_device.py Change-Id: Ie75f0b811d2c75d508e6ecffb40579308f5789d0
2019-01-07Adding Android Binder Bridge (abb) utility launched from adbd.Alex Buynytskyy
Once launched, abb will listen for incoming Binder cli requests. Executing in-process provides 6x latency improvement (125ms vs 25ms on PixelXL) for commands like 'package path' Intended usage by Android Studio for fast deployment and patching of APKs. Test: manual BUG: 111621042 Change-Id: Ica84eb2ec9628efa441ecd627b119f3361feaf9f
2018-12-21adb: finish switching service creation to string_view.Josh Gao
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-21adb: switch daemon_service_to_fd to string_view.Josh Gao
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-12adbd: add source/sink services.Josh Gao
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-11-01adb: switch version back to 40.Josh Gao
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-10-23Accept apex packages as argument.Dario Freni
Bug: 112669193 Test: Successfully reaches PackageManager. Doesn't break existing flows. Change-Id: If4a173e290ebf0b70beb97111a6d75400da7ec8d
2018-10-19adb: rationalize fatal/error logging.Elliott Hughes
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-08-07adb: clean up handle_host_request.Josh Gao
Previously, we were returning the result of SendOkay/SendFail in a few places after handling a host request, which is incorrect for two reasons. First, the return type of SendOkay/SendFail is bool, and handle_host_request was expected to return 0 on success. Second, we don't care if the SendOkay fails; if we got to that point, we're done with the request, regardless of whether we succeeded to report our result. The result of this was a spurious failure result reported after the initial result, which was ignored by the adb client. Test: manually straced adb server Test: python test_adb.py Test: python test_device.py Change-Id: I7d45ba527e1faccbbae5b15e7a0d1557b0a84858
2018-07-31adb: move list-forward, kill-forward back into handle_forward_request.Josh Gao
The daemon-side reverse functions depended on handle_forward_request: move them back instead of duplicating the logic we had in handle_host_request. Accomplish what we originally wanted to do in this change by changing the transport argument of handle_forward_request to a std::function that acquires a transport, either via acquire_one_transport or immediately returning a value that we already have. As a side effect, fix a bug where we would emit spurious errors for host service requests. Bug: http://b/112009742 Test: echo "001chost:connect:127.0.0.1:5555" | nc localhost 5037 Test: python test_device.py Test: python test_adb.py Change-Id: Iccc555575df6dbd7de10382854c4ea2c6f4beeaa
2018-07-25adb: split daemon services out of service_to_fd.Josh Gao
Let minadbd override daemon services by pulling out the daemon services into a separate translation unit, that isn't compiled into libadbd. Bug: http://b/111831478 Test: mma Change-Id: Iecfebea371e03864108eca9a4d2e9cfd5db34749
2018-07-25adb: fix register_socket_transport related double-closes.Josh Gao
Multiple codepaths were closing the fd they passed into register_socket_transport on failure, which would close the fd itself. Switch things over to unique_fd to make it clear that we don't actually have to close on failure. Test: mma Change-Id: I2d9bdcb1142c24931d970f99ebdf9a8051daf05c
2018-07-18adb: Modernize the service creationLuis Hector Chavez
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
2018-06-26Simplify __attribute__((__printf__)) use.Elliott Hughes
We don't need this now everyone's using clang... Bug: http://b/69933068 Test: ran tests Change-Id: I88f0cf03981ade47e210387fd6f3a2706dfeb9b8
2018-05-04adb: add authorizing, connecting states to transport.Josh Gao
Add two states: connecting and authorizing, to disambiguate the offline and unauthorized states, respectively. Previously, devices would transition as follows: offline -> unauthorized -> offline -> online offline -> unauthorized (when actually unauthorized) With this patch: connecting -> authorizing -> online connecting -> authorizing -> unauthorized (when actually unauthorized) This allows test automation and the like to distinguish between offline devices, unauthorized devices, and working devices without having to do retry loops with arbitrary sleeps on their end. Bug: http://b/79257434 Test: adb_test Test: adbd_test Test: manually plugging in a device with `while true; do adb shell echo foo; done` Change-Id: I036d9b593b51a27a59ac3fc57da966fd52658567
2018-04-13adb: fix `adb reverse` when adbd has multiple transports.Josh Gao
Plumb the transport that we received the adb reverse request on through to reverse_service, instead of trying to get a unique transport on devices that have multiple active transports (e.g. a device with USB (even unplugged) connected via TCP). Bug: http://b/37066218 Bug: http://b/71898863 Test: `echo foo | nc -l 12345 & adb reverse tcp:12345 tcp:12345; adb shell nc localhost 12345` on a device connected via TCP Change-Id: Iae199ae787f2e344126bbcacca8544cfc9844a4c
2018-04-11adb: switch apacket payload to a type that doesn't initialize its contents.Josh Gao
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
2018-03-21adb: delete vestigial SHELL_EXIT_NOTIFY_FD.Josh Gao
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-02-21adb: switch apacket over to a std::string payload.Josh Gao
Test: python test_device.py with walleye/x86_64 emulator Change-Id: I0a18941af1cb2279e5019a24ace25741def1202f
2018-02-06adb: switch asocket::enqueue to std::string.Josh Gao
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
2018-01-30adb: extract atransport's connection interface.Josh Gao
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
2017-12-14adb: disable checksum on new versionsTim Murray
The checksum is unnecessary. Improves adb performance by 40% on USB2. Test: new adb works with new + old adbd, old adb works with new adbd bug 67327728 Change-Id: I761d8a5a62deaea9bbb092ea9926b2d6d312f00d
2017-10-13adb: clang-format for adb.h and client/usb_windows.cppMark Salyzyn
Future adjustments triggered cleanup and transition of adb/adb.h and adb/client/usb_windows.cpp to be moved to Android coding standard. Test: build Bug: 63736262 Bug: 38446744 Bug: 66912053 Change-Id: I6eb3f0665b9670b9b3d5f5397f271605b48f4ff0
2017-10-02adb: remove SendConnectOnHost.Josh Gao
This logic appears to be racy, and it shouldn't actually be needed, if our devices follow the USB spec. Use libusb_set_interface_alt_setting on device initialization as well, to add one more thing that should reset the data toggles. Bug: http://b/32952319 Test: python test_device.py Change-Id: I392198af3d72c524b893e5056afa2b4617cea49c
2017-08-29Merge "adb: Use kernel aio for functionfs."Treehugger Robot
2017-08-21adb: allow selection of a specific transport.Josh Gao
Extend device selection to allow selecting a specific transport via monotonically increasing identifier (visible in devices -l). This is useful when using multiple devices (like hikey960...) that have identical bogus serial numbers like 0123456789ABCDEF. Bug: http://b/37043226 Test: adb -t {1, 2, 9999999} {get-serialno, shell, features} Change-Id: I55e5dc5a406a4eeee0012e39b52e8cd232e608a6
2017-08-10adb: Use kernel aio for functionfs.Jerry Zhang
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
2017-05-04adb: wait for devices to come up instead of sleeping for 3s.Josh Gao
Replace a hard-coded 3 second sleep with logic to wait until we've scanned USB devices once and they've all come online. Before: adb shell true 0.00s user 0.00s system 0% cpu 3.047 total After: adb shell true 0.00s user 0.00s system 9% cpu 0.041 total Bug: http://b/37869663 Test: `time adb shell true` after adb kill-server Change-Id: I251d42afb885908ed9d03167287594ea16650d3f
2017-04-20adb: fix two device offline problems.Yabin Cui
When device goes offline, user usually has to manually replug the usb device. This patch tries to solve two offline situations, all because when adb on host is killed, the adbd on device is not notified. 1. When adb server is killed while pushing a large file to device, the device is still reading the unfinished large message. So the device thinks of the CNXN message as part of the previous unfinished message, so it doesn't reply and the device is in offline state. The solution is to add a write_msg_lock in atransport struct. And it kicks the transport only after sending a whole message. By kicking all transports before exit, we ensure that we don't write part of a message to any device. So next time we start adb server, the device should be waiting for a new message. 2. When adb server is killed while pulling a large file from device, the device is still trying to send the unfinished large message. So adb on host usually reads data with EOVERFLOW error. This is because adb on host is reading less than one packet sent from device. The solution is to use buffered read on host. The max packet size of bulk transactions in USB 3.0 is 1024 bytes. By preparing an at least 1024 bytes buffer when reading, EOVERFLOW no longer occurs. And teach adb host to ignore wrong messages. To be safe, this patch doesn't change any logic on device. Bug: http://b/32952319 Test: run python -m unittest -q test_device.DeviceOfflineTest Test: on linux/mac/windows with bullhead, ryu. Change-Id: Ib149d30028a62a6f03857b8a95ab5a1d6e9b9c4e
2017-02-22adb: add `adb host-features`, report libusb status.Josh Gao
Add a 'host-features' command to get the features of the currently running host adb server. Abuse it to report libusb status. Bug: http://b/34983123 Test: adb host-features; adb kill-server; ADB_LIBUSB=1 adb start-server; adb host-features Change-Id: I0e8d503a2dbdff9002ebb6ce8a298498a9421422
2017-02-13adb: Set max socket sizes to larger values.Jerry Zhang
This improves performance of push/pull. Test: adb push/pull multi GB files. Bug: 31722483 Change-Id: Ia01574c3db6a740d7a7e64ba1f5bc1fc279fb3f6