summaryrefslogtreecommitdiffstats
path: root/adb/services.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix adb "ptsname is not thread-safe; use ptsname_r instead" build break.Elliott Hughes2014-07-291-3/+2
| | | | Change-Id: I633dc4d6d421862473e7267cc0d2c1b0933392e0
* adb: set O_CLOEXEC on lots of file descriptorsNick Kralevich2014-07-211-5/+4
| | | | | | | | | | | Too many leaking FDs. Fixes bug: https://code.google.com/p/android/issues/detail?id=65857 (and more) (cherrypicked from commit fe8d7f4f2e775d46d61f7c2d29a4e852434984da) Change-Id: I67d8683244e54288a8105f6f65ee40abe2378d7e
* adb: use oom_score_adj instead of oom_adjRom Lemarchand2014-07-181-3/+3
| | | | | | (cherry picked from commit 07ce7cab72d9b3e5c701491daf8fd457d035eec8) Change-Id: I1730d1df34039a5502200002ac813ce96a3eaa1a
* Add "exec" service: shell commands with no pty.Jeff Sharkey2014-07-181-44/+108
| | | | | | | | | | | | | | | | | | | | | | To facilitate device scripts that want to read/write binary data from the host side, this change introduces a new "exec" service that behaves like "shell" but without creating a pty, which would otherwise mangle binary data. After forking, it hooks up stdin/stdout of the child process to the socket connected through to the host. The adb transport doesn't support shutdown(), so the host can't half-close the socket and wait for device termination. Instead, the host side now has two explicit commands "exec-in" and "exec-out" for either sending or receiving data. Teach host side copy_to_file() to deal with stdin/stdout special cases. Switch device side backup/restore services to use the new create_subproc_raw under the hood. (cherry picked from commit 5d9d434efadf1c535c7fea634d5306e18c68ef1f) Change-Id: I42c18cb5bb907449b458c94450ef6c584d84ecdb
* am 6e7343b8: Merge "adb: implement "adb reverse <local> <remote>""David 'Digit' Turner2014-05-271-0/+21
|\ | | | | | | | | * commit '6e7343b8993fecb2f0600a9e5cff91dd4480a877': adb: implement "adb reverse <local> <remote>"
| * adb: implement "adb reverse <local> <remote>"David 'Digit' Turner2014-05-271-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the logical opposite of 'adb forward', i.e. the ability to reverse network connections from the device to the host. This feature is very useful for testing various programs running on an Android device without root or poking at the host's routing table. Options and parameters are exactly the same as those for 'adb forward', except that the direction is reversed. Examples: adb reverse tcp:5000 tcp:6000 connections to localhost:5000 on the device will be forwarded to localhost:6000 on the host. adb reverse --no-rebind tcp:5000 tcp:6000 same as above, but fails if the socket is already bound through a previous 'adb reverse tcp:5000 ...' command. adb reverse --list list all active reversed connections for the target device. Note: there is no command to list all reversed connections for all devices at once. adb reverse --remove tcp:5000 remove any reversed connection on the device from localhost:5000 adb reverse --remove-all remove all reversed connections form the current device. Reversed connections are tied to a transport, in other words, they disappear as soon as a device is disconnected. Simple testing protocol: adb forward tcp:5000 tcp:6000 adb reverse tcp:6000 tcp:7000 nc -l localhost 7000 in another terminal: echo "Hello" | nc localhost 5000 Will print "Hello" on the first terminal. Change-Id: I761af790cdb06829b68430afa4145a919fa0e6d5
* | am 9cae50b3: Merge "Bound the ADB connect time with a non-blocking connect"Elliott Hughes2014-05-191-1/+1
|\ \ | |/ | | | | | | * commit '9cae50b38d6a58efe0799ef3697f594cb4b100f9': Bound the ADB connect time with a non-blocking connect
| * Bound the ADB connect time with a non-blocking connectKen Lierman2014-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | After a disconnect, the initial blocking connect takes a long time to return, while subsequent calls return quicks. Switch to a non-blocking connect to make the re-connect time more consistent and faster overall. Change-Id: I21d02b22a8eb9a457c2f1fa95eb17894d5612ccd Signed-off-by: Ken Lierman <ken.lierman@windriver.com> Reviewed-by: Gumbel, Matthew K <matthew.k.gumbel@intel.com> Reviewed-by: Jovanovic, Radivoje <radivoje.jovanovic@intel.com> Reviewed-by: Boie, Andrew P <andrew.p.boie@intel.com>
* | am 02916aa2: Remove obsolete vdc call.Nick Kralevich2014-03-041-14/+1
|\ \ | |/ |/| | | | | * commit '02916aa20e3ffbe4b738bb12dc1607a7ec6a8c37': Remove obsolete vdc call.
| * Remove obsolete vdc call.Nick Kralevich2014-03-041-14/+1
| | | | | | | | | | | | | | | | | | | | Since ca8e66a8b0f843812014a28d49208f9f6f64ecbc, init has been handling reboots and filesystem unmounts. Remove obsolete call to vdc. Bug: 12504045 Change-Id: If8704ca042cb3a68857743b9973e48c52e7eb881 (cherry picked from commit 225459a5da21e9397ca49b0d9af7d5fe3462706b)
* | adb: deprecate legacy log service interfaceMark Salyzyn2014-01-271-2/+0
| | | | | | | | | | | | (cherry picked form commit c66a7537df987715acc77eed952111cc56b7e72b) Change-Id: If96019cc13b3d7a4dcd7785c7137e0cbcc622981
* | system/core 64-bit cleanup.Elliott Hughes2014-01-161-4/+4
|/ | | | | | | | | This cleans up most of the size-related problems in system/core. There are still a few changes needed for a clean 64-bit build, but they look like they might require changes to things like the fastboot protocol. Change-Id: I1560425a289fa158e13e2e3173cc3e71976f92c0
* Don't return immediately from reboot commands.Nick Kralevich2013-10-241-0/+4
| | | | | | | | | The reboot commands return too fast, interfering with testing. Add a pause(), which will allow the device time to complete the reboot. Change-Id: Ie9cc6eea67b7ff662ec71ea2329cbb94f8d55404 Bug: 11369303
* adb: Only use properties on device buildsNick Kralevich2013-05-231-0/+1
| | | | | | | | When building for the host, don't make reference to property_get / property_set. I'm in the process of removing host side support for properties. Change-Id: I691c5872b5fd538e78bc38a3fe72574cdc7f43c3
* adb: Handle adb connect in a threadBenoit Goby2013-04-251-0/+123
| | | | | | | | | adb connect calls connect() in the event loop. If you pass a wrong ip address or the server is slow to respond, this will block the event loop and you can't even kill the adb server with adb kill-server. Handle connect requests in a service thread instead. Change-Id: I2ee732869a3dc22a6d3b87cf8ac80acaa7790037
* adb: Cleanup dead codeBenoit Goby2013-04-241-101/+2
| | | | | | | dns_service is unused and recover_service has been replaced by adb sideload Change-Id: Ie90000d7f672e8299ee1622a9690c7371b214dc1
* Make init handle rebootsNick Kralevich2013-04-231-2/+11
| | | | | | | | | | | | | | | | | | | | | Move the responsibility for rebooting the system from the reboot command to init. Init is in a better position to take actions to bring the system down cleanly, including making sure filesystems are mounted read-only. The only UIDs which can perform an init triggered reboot are root, system, and shell. Modify the reboot command so that it calls into init to perform the reboot. The reboot command no longer requires CAP_SYS_BOOT. Remove the -n reboot option and code which supports it. Anyone needing to do an unclean shutdown can just do a 'echo c > /proc/sysrq-trigger'. Modify adb so that it calls into init to perform a shutdown. Bug: 8646621 Change-Id: I84c0513acb549720cb0e8c9fcbda0050f5c396f5
* Make adb robust against EINTRKenny Root2012-10-121-1/+1
| | | | Change-Id: I39a8d9007ce2d5662a33a50e4d7e2e7f8f9fad63
* adb: Don't synchronize with transport using sleepBenoit Goby2012-03-161-13/+0
| | | | | | | | | | | | | | Services that cause adbd to reboot are currently implemented this way: write(fd, response) close(fd) sleep(1) exit(1) sleep(1) is necessary to leave time for the transport to transmit the response before the daemon exits. This is slow and unreliable. Instead, add a flag to the asocket to make it exit the daemon only after the socket is closed. Change-Id: I9df45ea6221f0d9b828703b9b2316a5d4fe59352
* Revert "Reimplement the "adb root" command to more closely match its ↵Benoit Goby2012-03-161-2/+4
| | | | | | previous behavior" This reverts commit 535164e9d9649a83d4d63829f3389f2bea339fe1.
* Reimplement the "adb root" command to more closely match its previous behaviorMike Lockwood2011-06-221-4/+2
| | | | | | | | | | | | | | | | | | The adb gadget driver used to reset the USB bus when the adbd daemon exited, and the host side adb relied on this behavior to force it to reconnect with the new adbd instance after init relaunches it. The new gadget drivers no longer automatically reset the USB bus when adbd is restarted which caused adb to hang since it was no longer forced to reconnect with the device. We attempted to work around this on the host side adb, but that work around has not been reliable. This change adds a property trigger on the service.adb.root system property which will reset the USB bus and restart the adbd daemon when adbd sets the property to 1. This should be much closer to the previous behavior and will hopefully fix some problems with automated testing. Change-Id: I177c37400009a3d83f21a5f9431f94fd1cc19b9b Signed-off-by: Mike Lockwood <lockwood@android.com>
* Add 'adb restore' to parallel 'adb backup'Christopher Tate2011-05-171-1/+3
| | | | | | | | | It won't actually do anything until the 'bu' tool and framework are updated to respond properly, but this is the adb side of the necessary infrastructure: we copy the tarfile into the socket pointed at the device, using the existing mechanisms. Change-Id: Ic3b5779ade256bd1ad989a94b0685f7b1a7d59d2
* Add 'adb backup' for pulling a full backup tarfile to the hostChristopher Tate2011-04-271-0/+4
| | | | | | | The direct command interfaces with the 'bu' binary in /system/bin on the device. Change-Id: I4cd69eedfe5144c47277573c5626c6ad8755d70b
* adb: fix subprocess exit handling, oom adjust fixes, extra debugging.JP Abgrall2011-03-281-22/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add support for correctly handling subprocess termination in shell service (b/3400254 b/3482112 b/2249397) - have a waitpid() track the subprocess, then notify the fdevent via a socket - force an eof on the pty master in fdevent's new subproc handler. - modify fdevent to force-read the pty after an exit. * Migrate the "shell:blabla" handling to "#if !ADB_HOST" sections, where it belongs. * Fix the race around OOM adjusting. - Do it in the child before exec() instead of the in the parent as the child could already have started or not (no /proc/pid/... yet). * Allow for multi-threaded D() invocations to not clobber each other. - Allow locks across object files. - Add lock within D() - Make sure sysdesp init (mutex init also) is called early. * Add some missing close(fd) calls - Match similar existing practices near dup2() * Add extra D() invocations related to FD handling. * Warn about using debugging as stderr/stdout is used for protocol. * Fix some errno handling and make D() correctly handle it. * Add new adb trace_mask: services. * Make fdevent_loop's handle BADFDs more gracefully (could occur some subproc closed its pts explicitely). * Remove obsolete commandline args reported in help. (b/3509092) Change-Id: I928287fdf4f1a86777e22ce105f9581685f46e35
* Try to unmount writable filesystems when rebootingKen Sumrall2011-03-101-3/+2
| | | | | | | | | | | | | | | Ext4 filesystems like to be unmounted before rebooting. The Android system doesn't have a traditional Linux init setup, and shutting down the system was not much more than calling sync(2) and reboot(2). This adds a new function to libcutils called android_reboot(). By default, it calls sync() and then remounts all writable filesystems as read-only and marks them clean. There is a flag parameter in which the caller can ask for sync() not to be called, or to not remount the filesystems as read-only. Then it will call reboot(2) as directed by the other parameters. This change also updates adb, init and toolbox to call the new android_reboot() function. Fixes bugs 3350709 and 3495575. Change-Id: I16d71ffce3134310d7a260f61ec6f4dd204124a7
* Revert "Fix adb hang when subprocess dies early."JP Abgrall2011-02-231-87/+19
| | | | | | | | This is for http://b/3482112 "adb interactions with device causing test harness failures". This reverts commit 69c5c4c45bd4f1575ae8bdba13795297be7deb8c. Change-Id: I630bf2e04d2ecf0223bd2af4e87136754ff880d3
* Fix adb hang when subprocess dies early.JP Abgrall2011-02-181-19/+87
| | | | | | | | | | | | | | | | | | | | | | | | * Handling of the subprocess and its FD. This fixes http://b/3400254 "Many bugreports getting hung at the end in monkey" - Start up a service thread that waits on the subprocess to terminate, then closes the FD associated with it. - Have the event handler select() with a timeout so that it can detect the closed FD. Select() with no timeout does not return when an FD is closed. - Have the event handler force a read on the closed FD to trigger the close sequence. - Migrate the "shell:blabla" handling to "#if !ADB_HOST" sections. * Fix the race around OOM adjusting. - Do it in the child before exec() instead of the in the parent as the child could already have started or not (no /proc/pid/... yet). * Allow for multi-threaded D() invocations to not clobber each other. - Allow locks across object files. - Add lock within D() * Add some missing close(fd) calls - Match similar existing practices near dup2() * Add extra D() invocations related to FD handling. * Warn about using debugging as stderr/stdout is used for protocol. Change-Id: Ie5c4a5e6bfbe3f22201adf5f9a205d32e069bf9d Signed-off-by: JP Abgrall <jpa@google.com>
* Fix adb leaking file descriptors to forked processesBenoit Goby2011-02-021-0/+1
| | | | | | | | | | accept() creates a new file descriptor that should be closed on exec so that forked processes don't keep a fd opened on the socket. This also fixes b/3297070 where adb hangs after running adb on the target. Change-Id: I8df511289e5549ae49b4824c9dfb71a3bf85eae8
* adb: Attempt to unmount the SD card before rebooting.Mike Lockwood2010-02-241-1/+15
| | | | | Change-Id: Idd4d96b4704f4e1bd324e72bca87611a23e30801 Signed-off-by: Mike Lockwood <lockwood@android.com>
* adb: Clean up argument passing for create_service_thread()Mike Lockwood2009-09-191-4/+5
| | | | | Change-Id: Id68b312e76215e8e217b42ca0301713dbddfee9e Signed-off-by: Mike Lockwood <lockwood@android.com>
* Revert "adb: Another attempted workaround for the adb disconnect problem."Joe Onorato2009-09-031-81/+12
| | | | | | This reverts commit cc1de48dcdf06c76ee14abbe2a237aa51b5b3bad. lockwood says to take this out.
* Revert "adb: "adb bugreport" now runs dumpstate via init rather than execing ↵Mike Lockwood2009-09-031-39/+0
| | | | | | | | it in the shell." This reverts commit be0045aafdbc2ec2ee448be86952082361f5d672. This change broke compatibility with previous versions of adbd, so I will be implementing this by modifying the bugreport command on the device instead.
* adb: "adb bugreport" now runs dumpstate via init rather than execing it in ↵Mike Lockwood2009-09-031-0/+39
| | | | | | | | | the shell. This allows dumpstate to run as root even if adbd is not. Change-Id: I04bda1ee0c8de91677149a2a9eda713c85067aa4 Signed-off-by: Mike Lockwood <lockwood@android.com>
* adb: Improved support for running adb over TCP/IPMike Lockwood2009-08-241-4/+52
| | | | | | | | | | Added new commands: adb connect <host>:<port> (to connect to a device via TCP/IP) adb tcpip <port> (to restart adbd on the device to listen on TCP/IP) adb usb (to restart adbd on the device to listen USB) Signed-off-by: Mike Lockwood <lockwood@android.com>
* adb: add "adb reboot" command.Mike Lockwood2009-08-051-0/+20
| | | | | | | | This will allow rebooting the device via adb on any build, including user builds. An optional argument can be provided (for example, "adb reboot bootloader" or adb reboot recovery") Signed-off-by: Mike Lockwood <lockwood@android.com>
* adb: Another attempted workaround for the adb disconnect problem.Mike Lockwood2009-07-301-11/+81
| | | | | | | | For adb shell commands (as well as shell based commands like logcat and bugreport) we now batch USB writes into 4K chunks instead of sending small packets of data as they come in. A timeout prevents us from blocking for more than 100ms when our 4K buffer is partially full. Signed-off-by: Mike Lockwood <lockwood@android.com>
* Revert "adb: Workaround for adb disconnect problem."Mike Lockwood2009-06-111-55/+3
| | | | | | | | | This reverts commit e38a31e305b0944c0cd1ae782e47e3145d731f0f. This change had the unfortunate side effect of breaking ctrl-C when executing "adb shell <command>" Signed-off-by: Mike Lockwood <lockwood@android.com>
* adb: Workaround for adb disconnect problem.Mike Lockwood2009-06-021-3/+55
| | | | | | | | For non-interactive adb shell commands, batch USB writes into 4K chunks instead of sending small packets of data as they come in. Add a timeout so we do not block for more than 200ms when our 4K buffer is partially full. Signed-off-by: Mike Lockwood <lockwood@android.com>
* adb: adbd no longer disables OOM and now sets children's OOM adjustment to zeroMike Lockwood2009-05-201-0/+12
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* auto import from //branches/cupcake_rel/...@138607The Android Open Source Project2009-03-131-0/+30
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-0/+367
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-367/+0
|
* auto import from //branches/cupcake/...@125939The Android Open Source Project2009-01-091-4/+1
|
* Initial ContributionThe Android Open Source Project2008-10-211-0/+370