summaryrefslogtreecommitdiffstats
path: root/adb/adb.c
Commit message (Collapse)AuthorAgeFilesLines
* Allow adb to listen both on usb and tcp.Mike J. Chen2012-08-091-11/+15
| | | | | | | | | | | (cherry picked from commit ae868a40459a6bcb89d8a4426503fea0c8002b25 in master) Change-Id: I980c7c5e8affbc8627d17b1d9303b002adcdb29a Signed-off-by: Mike J. Chen <mjchen@google.com> Conflicts: adb/adb.c
* Merge "FunctionFS: initial implementation"Benoit Goby2012-06-061-1/+2
|\
| * FunctionFS: initial implementationAndrzej Pietrasiewicz2012-05-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the second version of a patch which demonstrates the possibility of using adbd (Android Debug Bridge daemon) with a generic FunctionFS gadget instead of a custom adb usb gadget in the Linux kernel. It contains changes introduced after Benoit's review - thank you Benoit. The patch adds a new usb access layer to adbd using FunctionFS. The former usb access method is still available. The method is chosen at runtime depending if /dev/usb-ffs/adb/ep0 or /dev/android_adb is accessible. How to use on the target device: $ insmod g_ffs.ko idVendor=<vendor ID> iSerialNumber=<some string> $ mount -t functionfs adb /dev/usb-ffs/adb -o uid=2000,gid=2000 $ ./adbd This patch requires a patch to bionic which adds <linux/usb_functionfs.h> which is an exact copy of the relevant file in the linux kernel. Change-Id: I4b42eb267ffa50fca7a5fba46f388a2f083e8b2d Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> [benoit@android.com: detect at runtime if functionfs is mounted or fallback using f_adb] Signed-off-by: Benoit Goby <benoit@android.com>
* | am 1b7a7e81: adb: Use bionic\'s strtok_r() for WindowsScott Anderson2012-06-051-2/+2
|\ \ | | | | | | | | | | | | * commit '1b7a7e81195ff06a7482f81cb92b094bb3481cb1': adb: Use bionic's strtok_r() for Windows
| * | adb: Use bionic's strtok_r() for WindowsScott Anderson2012-06-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A recent change use strtok_r which broke the Windows build. Clear this potential landmine by adding adb_strtok_r to sysdeps.h in the typical fashion. For Windows, the actual implementation in sysdeps_win32.c was copied from bionic/libc/string/strtok.c. Change-Id: Ibb71555bc429f7058c07c3d39e0b62859c79635c Signed-off-by: Scott Anderson <saa@android.com>
* | | am 2ca3e6b3: adb: Generalizing -s to take qualifiers.Scott Anderson2012-06-051-4/+3
|\ \ \ | |/ / | | | | | | | | | * commit '2ca3e6b35f79136418ebc32fef57580698dbd045': adb: Generalizing -s to take qualifiers.
| * | adb: Generalizing -s to take qualifiers.Scott Anderson2012-06-051-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, -s could take either a serial number or a device path (e.g. "-s 01498B1F02015015" or "-s usb:1-4.2"). This change extends -s to also allow product, model or device names (e.g. "-s product:mysid"). These new qualifiers will only be available on devices that are running an adb daemon that provides properties in the connect message per Change-Id: I09200decde4facb8fc9b4056fdae910155f2bcb9 The product, model and device are derived from the ro.product.name, ro.product.model and ro.product.device properties respectively. They are prefixed with "product:", "model:" or "device:" as appropriate. In addition, any non-alphanumerics in the model are changed to underscores. If the -s parameter matches multiple devices, the result will be the same as when multiple devices are connected but no -d, -e or -s option is specified. In general, this means the user will get "error: more than one device". However for get-state, get-devpath and get-serialno, they will get "unknown". The format of "devices -l" was changed to list all of the qualifiers that are available. The following example output (with the last digits of the serial numbers replaced with X's) is with a Galaxy Prime with an older adb daemon and another Galaxy Prime and Galaxy S both with the enhanced adb daemons: List of devices attached 016B75D60A0060XX device usb:2-5 product:mysid model:Galaxy_Nexus device:toro 3731B535FAC200XX device usb:1-4.2 product:soju model:Nexus_S device:crespo 01498B1F020150XX device usb:1-4.1 Note that the serial number and state are now column oriented instead of tab delimited. After the serial number and state, all qualifiers are listed with each preceded by a space. The output of the original devices command (without -l) is unchanged. Change-Id: Iceeb2789874effc25a630d514a375d6f1889dc56 Signed-off-by: Scott Anderson <saa@android.com>
* | | am e82c2db0: adb: Transmit key properties in banner of connect messageScott Anderson2012-06-051-21/+82
|\ \ \ | |/ / | | | | | | | | | * commit 'e82c2db05cae70a0490a1f84b7211ef42c329671': adb: Transmit key properties in banner of connect message
| * | adb: Transmit key properties in banner of connect messageScott Anderson2012-06-051-21/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | protocol.txt says that the connect message should have three fields: <systemtype>:<serialno>:<banner> In reality, what is transmitted is simply: <systemtype>:: The serialno is obtained via other means so doesn't really need to be a part of the connect message. This change puts the ro.product.name, ro.product.model and ro.product.device properties in the <banner> for devices. Each property is terminated by a semicolon (;) with the key and value separated by an equals sign (=). Example message: device::ro.product.name=<prd>;ro.product.model=<mdl>;ro.product.device=<dev>; Making this change will enable the device list to provide more information to the user and to give the potential for being able to select which device to talk to with the -s option. Change-Id: I09200decde4facb8fc9b4056fdae910155f2bcb9 Signed-off-by: Scott Anderson <saa@android.com>
* | | am c7993af6: adb: Fix compiler warningScott Anderson2012-06-011-1/+2
|\ \ \ | |/ / | | / | |/ |/| * commit 'c7993af64baec271a238646bc20aaa846866c4a9': adb: Fix compiler warning
| * adb: Fix compiler warningScott Anderson2012-05-311-1/+2
| | | | | | | | | | | | | | | | system/core/adb/adb.c: In function 'connect_device': system/core/adb/adb.c:1001: warning: comparison between signed and unsigned integer expressions Change-Id: I206f85395e1d7ad8d6ef130a26c95dcf0f498696 Signed-off-by: Scott Anderson <saa@android.com>
* | am 9526a788: Merge "adb: Add ability to specify device path" into ics-aahScott Anderson2012-05-011-9/+22
|\ \ | |/ | | | | | | * commit '9526a788a6bd528e14622404e8750bdcc147d15a': adb: Add ability to specify device path
| * adb: Add ability to specify device pathScott Anderson2012-04-201-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For manufacturing and testing, there is a need to talk to whatever device is connected to a given port on the host. This change modifies adb's "-s" option to take either a serial number or a device path. The device paths of the connected devices can be listed using "adb devices -l" whose output will resemble: List of devices attached 016B75D60A00600D usb:2-5 device 3031D0B2E71D00EC usb:1-4.3 device The second column lists the device paths. If the -l option is not given, the output from "adb devices" will be the same as it used to be (i.e. the paths will not be printed). The device path can also be obtained with the get-devpath command: $adb -s 3031D0B2E71D00EC get-devpath usb:1-4.3 Note that the format of the device paths are platform dependent. The example above is from Linux. On OS-X, the paths will be "usb:" followed by hex digits. For other platforms, the device paths will be printed as "????????????" and the -s option will not be able to select a device until someone implements the underlying functionality. Change-Id: I057d5d9f8c5bb72eddf5b8088aae110763f809d7 Signed-off-by: Scott Anderson <saa@android.com>
| * Allow adb to listen both on usb and tcp.Joe Onorato2011-12-071-10/+15
| | | | | | | | Change-Id: I98db594241631fa17e39686727392afc8b3124bc
* | adb: set umask to 000Nick Kralevich2012-04-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | Init is going to be modified to set the umask to 077. This will impact adb, as "adb install" and "adb sync" assume that files will be world-readable / writable. Keep adb's umask at 000 for now. Bug: 3272072 Change-Id: I75978e8dd7bbdf4dbe7c9a691ef516235f207da2
* | Add AID_SDCARD_R.Dianne Hackborn2012-03-081-2/+3
| | | | | | | | Change-Id: I47f650e415e06c0b69790ffefea7f208c910ebd7
* | Enables ADBD tracing in the emulator.Vladimir Chtchetkine2012-02-271-0/+55
| | | | | | | | | | | | | | | | | | | | When running inside the emulator, guest's adbd can connect to 'adb-debug' qemud service that can display adb trace messages on condition that emulator has been started with '-debug adb' option. This CL enables that functionality in ADB code. Change-Id: I59b4a76d3c887ad28b8aa8e2a01dfa814e75faa1
* | Don't allow adb to run as root in user builds.Nick Kralevich2012-01-191-0/+4
| | | | | | | | Change-Id: I4fbd7beb7f76c68fead1a89b745f0dfb931b4597
* | Move permission checking code to it's own function.Nick Kralevich2012-01-191-23/+31
| | | | | | | | Change-Id: Ibe46ca3043791f3b3815080f9e23ac307b1f5900
* | add "adb sideload" and sideload connection stateDoug Zongker2012-01-101-0/+7
|/ | | | | | | | | | Recovery will soon support a minimal implementation of adbd which will do nothing but accept downloads from the "adb sideload" command and install them. This is the client side command (mostly resurrected out of the old circa-2007 "adb recover" command) and the new connection state. Change-Id: I4f67b63f1b3b38d28c285d1278d46782679762a2
* adb: grant it AID_NET_BW_STATS for full /proc/net/xt_qtaguid/statsJP Abgrall2011-11-091-1/+3
| | | | | | | | | Normally only bandwidth stats for the uid reading .../stats is returned. With the extra group, adb shell will be able to read stats from all UIDs. This is to be used to offer data usage profiling to developers. Change-Id: If3d2941ce5aa4dbb1a23947b97b893149ba224f7
* Merge "Default to secure mode"Kenny Root2011-08-051-1/+1
|\
| * Default to secure modeKenny Root2011-07-311-1/+1
| | | | | | | | | | | | If ro.secure is not set for some reason, default to secure mode. Change-Id: Id0ce3ea5507a3f9690332fb5a2daef7d3303481d
* | am 189de0c1: am adabe566: am 810cf41b: Merge "Fixed memory leak when using ↵Nick Kralevich2011-07-291-1/+1
|\ \ | |/ |/| | | | | | | | | transport:serial." * commit '189de0c1f4339abd7b938b4905775163d2a94bbe': Fixed memory leak when using transport:serial.
| * Fixed memory leak when using transport:serial.Tom Marlin2011-07-291-1/+1
| | | | | | | | | | | | | | | | | | Fixed memory leak when using transport:serial. Code was previously using strdup() to make a copy of the serial number which was not necessary. Instead, just set serial=service. Change-Id: Ifa8fe7999c6fb88955d2c6bdfcd3cd724ec1f020 Signed-off-by: Tom Marlin <tomm@bsquare.com>
| * Fix adb leaking file descriptors to forked processesBenoit Goby2011-02-031-0/+2
| | | | | | | | | | | | | | | | | | | | 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: improve debug traces readability.David 'Digit' Turner2011-02-031-2/+2
| | | | | | | | | | | | | | This patch makes the traces easier to read. For example transports are displayed by name/serial instead of their hex address. Change-Id: I7e8df44ddbec19754d63d989bd56485998b4627b
* | adb: fix subprocess exit handling, oom adjust fixes, extra debugging.JP Abgrall2011-03-281-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | Revert "Fix adb hang when subprocess dies early."JP Abgrall2011-02-231-13/+9
| | | | | | | | | | | | | | | | 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-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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/+2
| | | | | | | | | | | | | | | | | | | | 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: improve debug traces readability.David 'Digit' Turner2011-01-061-2/+2
|/ | | | | | | This patch makes the traces easier to read. For example transports are displayed by name/serial instead of their hex address. Change-Id: I7e8df44ddbec19754d63d989bd56485998b4627b
* am 44db990d: Fix bug 2950316. Check return values.Nick Kralevich2010-08-271-4/+12
|\ | | | | | | | | | | | | Merge commit '44db990d3a4ce0edbdd16fa7ac20693ef601b723' into gingerbread-plus-aosp * commit '44db990d3a4ce0edbdd16fa7ac20693ef601b723': Fix bug 2950316. Check return values.
| * Fix bug 2950316. Check return values.Nick Kralevich2010-08-271-4/+12
| | | | | | | | Change-Id: I687bb5fb8195d4c1fc863e32a5e233a8b9e74196
* | print msg.command in human-readable formatViral Mehta2010-07-191-2/+4
|/ | | | | | | to print msg.command as some odd decimal number is just not helping in debugging; instead print msg.command as a string Change-Id: Id1ec770c20c86b8bdae40a0262bf4b63c0213b0a
* merge from open-source masterThe Android Open Source Project2010-06-031-21/+38
|\ | | | | | | Change-Id: I9b051ebd6e785e4d68e148a005a0485e79aa55ea
| * adb connect and disconnect improvements:Mike Lockwood2010-06-021-21/+38
| | | | | | | | | | | | | | | | Port number is now optional. Will use default port 5555 if not specified. "adb disconnect" with no additional arguments will disconnect all TCP devices. Change-Id: I7fc26528ed85e66a73b8f6254cea7bf83d98109f Signed-off-by: Mike Lockwood <lockwood@android.com>
* | merge from open-source masterThe Android Open Source Project2010-06-021-33/+99
|\ \ | |/ | | | | Change-Id: I44bd527e51d102a56a1efe40cb6e634859b09461
| * Let "adb connect" connect to emulators tooStefan Hilzinger2010-05-241-33/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - adb can now connect to an emulator configured with an arbitrary pair of <console port, adb port>. These two ports do not have to be adjacent. This can be done from the commandline at any time using adb connect emu:<console_port>,<adb_port> - Emulators running on ports outside the normal range (5554/5555-5584/5585) register themselves on startup if they follow the convention "console port+1==abd port". - Emulators outside the normal port range will not be auto-detected on adb startup as these ports are not probed. - The index into local_transports[] array in transport_local.c does no longer indicate the port number of the local transport. Use the altered atransport struct to get the port number. - I have chosen not to document the adb connect emu:console_port,adb_port syntax on adb's help screen as this might be confusing to most readers and useful to very few. - I don't expect this to introduce any (backwards) compatibility issues. Change-Id: Iad3eccb2dcdde174b24ef0644d705ecfbff6e59d Signed-off-by: Mike Lockwood <lockwood@android.com>
* | merge from open-source masterThe Android Open Source Project2010-04-281-15/+23
|\ \ | |/ | | | | Change-Id: Id824d3427cb4808a8768f14e7b46c0eaf5e02e73
| * Make adb's daemon-port on the host machine configurable.Stefan Hilzinger2010-04-281-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | This is the first CL of a somewhat larger effort which, among other things, will involve changing the emulator and ddms to talk to adb running on a configurable port. The port can be configured using environment variable ANDROID_ADB_SERVER_PORT. Further CLs will also address the set of ports used for the local transport. Change-Id: Ib2f431801f0adcd9f2dd290a28005644a36a780a
| * adb: remove obsolete adb.connected system property.Mike Lockwood2010-04-281-6/+0
| | | | | | | | | | | | | | | | This was used for adb networking, which no longer exists. This code also failed when adb was not running as root. Change-Id: Ied86fb1930094d5ae5009684d25e15385fd31d03 Signed-off-by: Mike Lockwood <lockwood@android.com>
* | merge from open-source masterThe Android Open Source Project2010-04-211-3/+6
|\ \ | |/ | | | | Change-Id: I686f28fcfcff1cca7cf254de9e4334cc4ea2fef7
| * adb: Add persistent system property for running adb in TCPIP modeMike Lockwood2010-04-201-3/+6
| | | | | | | | | | | | | | | | | | In addition to service.adb.tcp.port, you can now set persist.adb.tcp.port to specify the port number for adb to listen to instead of USB. This allows the adb TCP configuration to persist across reboots. Change-Id: I897ffcb019e8dd1785996d2f3c571cfc2f8ded38 Signed-off-by: Mike Lockwood <lockwood@android.com>
* | adb: Attempt to unmount the SD card before rebooting.Mike Lockwood2010-02-241-1/+2
|/ | | | | Change-Id: Idd4d96b4704f4e1bd324e72bca87611a23e30801 Signed-off-by: Mike Lockwood <lockwood@android.com>
* Make get_my_path() saferAlexey Tarasov2009-10-221-1/+1
| | | | | Adds maxLen parameter to get_my_path(). Some small cosmetic fixes.
* adb: Add "adb disconnect" command for disconnecting TCP/IP devices.Mike Lockwood2009-10-131-5/+28
| | | | | | | Also check that device is not already connected in "adb connect" Change-Id: I5f84b56b63d8c6932f23791cac319fd6bc39d36c Signed-off-by: Mike Lockwood <lockwood@android.com>
* adb: Fix emulator support.Mike Lockwood2009-08-261-6/+8
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* adb: Improved support for running adb over TCP/IPMike Lockwood2009-08-261-5/+46
| | | | | | | | | | 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-261-0/+14
| | | | | | | | 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>