Commit Graph

1157 Commits

Author SHA1 Message Date
Siva Velusamy b3d3e24585 am ba7284ae: am 4d40c03b: Merge "adb: On Mac, clear both host and device endpoints at startup"
* commit 'ba7284aee2df23d80eda3a78e73d98eaed8e16a7':
  adb: On Mac, clear both host and device endpoints at startup
2015-08-13 22:06:28 +00:00
Siva Velusamy d8b48a6281 adb: On Mac, clear both host and device endpoints at startup
This CL clears both the host and device endpoints right at the
beginning when the bulk endpoints are identified. This is in general
a "good idea", but more specifically for us, it fixes the issue
that sometimes when adb quits, it clears the endpoint on the host,
but not on the device which resulted in a subsequent invocation of
adb was seeing a stall.

Bug: https://code.google.com/p/android/issues/detail?id=182151

Change-Id: I331fa6805c40d1f50c153c010ceecd2f6a4045eb
2015-08-13 14:32:50 -07:00
Elliott Hughes f36aa8ec5d am 5563b77a: am 57532b2a: Merge "adb: improve network error info"
* commit '5563b77a138faa622d1ba164599bf6be88997f84':
  adb: improve network error info
2015-08-13 18:00:45 +00:00
Elliott Hughes 57532b2a06 Merge "adb: improve network error info" 2015-08-13 17:49:21 +00:00
Elliott Hughes 5e60d25d66 am 1685b099: am 8836031b: Merge "adb: win32: fix shutdown deadlock"
* commit '1685b09921ae2057acbd9655778660a2e81ec6b3':
  adb: win32: fix shutdown deadlock
2015-08-13 17:15:02 +00:00
Elliott Hughes 8836031b27 Merge "adb: win32: fix shutdown deadlock" 2015-08-13 17:02:16 +00:00
Elliott Hughes 56d11898aa am 80e83972: am 9537ca80: Merge "adb: start-server and kill-server error output"
* commit '80e83972d0bce74d218f72b76339e6761ad6b03b':
  adb: start-server and kill-server error output
2015-08-13 16:46:46 +00:00
Spencer Low f18fc0879b adb: start-server and kill-server error output
- handle_host_request
  - When the host:kill command comes in, shutdown the socket before
    calling exit(). If we don't do this, the client will output error info
    even though everything is working ok.

- adb_connect()
  - If we can't parse the version string, explain this in error output
    and don't goto error which would try to close an fd we already closed.
  - If host:kill doesn't work, output error info. Don't try to close
    already closed fd.

- adb_main()
  - If writing the ACK somehow has an error, output error info (I doubt
    this will ever get hit).

- adb_commandline()
  - Fix typo about max port number.
  - Make 'adb kill-server' and 'adb start-server' output any detailed
    error info.

Change-Id: Id1a309cc1bf516f7f49bd332b34d30f148b406da
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-12 20:14:55 -07:00
Spencer Low 87e97ee305 adb: win32: fix shutdown deadlock
adb can hang at shutdown due to a deadlock relating to WSACleanup().
This works around the issue by not calling WSACleanup() which shouldn't
be done anyway since threads aren't done using Winsock at shutdown.

A quick way to reproduce the original problem is to run many instances
of adb, many of which will call exit() soon:

  for /l %i in (1,1,20) do @start adb nodaemon server

You may have to boost the 20 to 200, or set ADB_TRACE=1 or use Windows
10 instead of Windows 7, to affect the timing, but eventually there
should be hung adb processes with that repro.

A more complete fix to prevent problems like this from occuring in the
future, would be to additionally do the following:

- Investigate all static destructors that are called when exit() is
  called.

- If they don't do anything important, switch all calls to exit() to
  instead call _exit() and then ban exit() from being called.

Change-Id: Id1be3bf0053809a45f2eca4461e4c35b5ef9388d
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-12 18:19:16 -07:00
David Pursell 6eef56fb7a am 697869c4: am 6fefa36c: Merge "adb: Fix PTY logic for non-interactive shells."
* commit '697869c4fde93a23cda3a0d789c1f101f82eb157':
  adb: Fix PTY logic for non-interactive shells.
2015-08-12 22:29:00 +00:00
David Pursell d4093f191b adb: Fix PTY logic for non-interactive shells.
Change `adb shell` so that interactive sessions use a PTY but
non-interactive do not. This matches `ssh` functionality better
and also enables future work to split stdout/stderr for
non-interactive sessions.

A test to verify this behavior is added to test_device.py with
supporting modifications in device.py.

Bug: http://b/21215503
Change-Id: Ib4ba40df85f82ddef4e0dd557952271c859d1c7b
2015-08-12 14:16:22 -07:00
Yabin Cui 63a29199f3 am 87f73de9: am 317acfb8: Merge "Remove confusing variable HOST."
* commit '87f73de9e9b0a74e4b963e8b49d90bbe81a38bb0':
  Remove confusing variable HOST.
2015-08-12 21:09:13 +00:00
Yabin Cui 317acfb880 Merge "Remove confusing variable HOST." 2015-08-12 20:55:59 +00:00
Elliott Hughes efc8077246 am c01231b3: am 2fb00423: Merge "Always include the adb version in the log."
* commit 'c01231b399c38f00afe0872b3a51837518b713dc':
  Always include the adb version in the log.
2015-08-12 17:45:41 +00:00
Elliott Hughes 42ae2604f4 Always include the adb version in the log.
"Are you running the right version?" seems to be a common cause of debugging
confusion.

Change-Id: I4a4ba95e876dafc05e515058ca059ea370273f78
2015-08-12 08:32:10 -07:00
Elliott Hughes f000f7b250 am 70af6e0b: am 9508dcb9: Merge "adb: make stdin/stdout/stderr redirection errors fatal"
* commit '70af6e0bad17c5d90084738950e72243f0ce3806':
  adb: make stdin/stdout/stderr redirection errors fatal
2015-08-12 15:29:39 +00:00
Spencer Low 155159c545 adb: make stdin/stdout/stderr redirection errors fatal
Make these fatal errors:

- Win32 GetTempPathW() failures.

- Errors opening /dev/null (and don't use LOG(FATAL) for this error
  since that will do a crash-dump on Windows which isn't appropriate for a
  transient runtime error).

- Errors with dup2.

- Errors opening adb.log.

Change-Id: Ided76a5436d8c6f059d8f6799c49ba04c87181ae
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-11 23:36:55 -07:00
Elliott Hughes 9cb4af39af am 8bb6b3e1: am b62f6c2a: Merge "adb: call android::base::InitLogging even when adb tracing is disabled"
* commit '8bb6b3e1ffc44336f89eb30cc39a1e96498c7c23':
  adb: call android::base::InitLogging even when adb tracing is disabled
2015-08-12 03:31:19 +00:00
Elliott Hughes b62f6c2a1c Merge "adb: call android::base::InitLogging even when adb tracing is disabled" 2015-08-12 03:20:04 +00:00
Dan Albert 97a8cd957f am e78292f2: am cef3508b: Merge "Add missing includes."
* commit 'e78292f2c5a1cffd9fdcb76e5be29f6d14445b93':
  Add missing includes.
2015-08-12 02:10:16 +00:00
Dan Albert cef3508bb6 Merge "Add missing includes." 2015-08-12 01:50:15 +00:00
Spencer Low bf7c605d87 adb: improve network error info
- handle_forward_request
  - Because we have detailed info about which syscall failed (at least
    on Win32), use a more generic prefix of "cannot bind listener" followed
    by the detailed info.

- install_listener
  - Return string errors for a few errors even though I don't think any
    callers actually output the string for those errors.

  - Remove the printf since the callers print the message themselves.

- adb_main
  - LOG(FATAL) calls abort() which on Windows calls the Windows Error
    Reporting service which pops up a dialog asking if you want a
    crashdump to be uploaded to Microsoft. So really, abort() is
    designed for app bugs. Windows isn't the only one doing this, Chromium
    also makes LOG(FATAL) crashdump-ready. Since an error here is not
    necessarily an app-bug, use a 'normal' error output API like fatal()
    which prints an error and just uses exit().

- sysdeps_win32.cpp
  - When Winsock APIs fail, make the string clarify which API failed.
    Use terse unix-style descriptions (like what you'd get from
    cp/mv/dd/etc.).

  - Don't trace WSAEWOULDBLOCK from recv() which is a normal occurrence.

  - Add a comment about WSAEWOULDBLOCK => EAGAIN.

Change-Id: I58e47f49fa2f6c1b4b92a36d0c4bfe369b456f2a
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-11 16:45:32 -07:00
Dan Albert af9ba4dc6c Add missing includes.
Leaky header cleanup in libc++ means we don't get unistd.h
transitively any more.

Change-Id: I596c24eff418302b19afab6ad3caa55f52241e7c
2015-08-11 16:39:57 -07:00
Spencer Low 7430916098 adb: call android::base::InitLogging even when adb tracing is disabled
This is a follow-up to https://android-review.googlesource.com/153623
which prevented android::base::InitLogging() from being called when
tracing was disabled.

It is ok to call InitLogging() on a device or host because calling it
does not imply that a logging file is used, which was the reason for
not calling it on a device.

So this change should preserve the device behavior of not using a
logging file when tracing is disabled, plus it will call InitLogging()
all the time in case logging APIs are called.

Change-Id: I3fd6ba2c567f67a2f111a85f174893fbf866ec57
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-11 15:48:15 -07:00
Elliott Hughes e6b72a4ef6 am 06a9f560: am 7989a7c8: Merge "adb: win32: fix USB device hang when resuming from sleep/hibernation"
* commit '06a9f560d2f19026c398b2ce66cd1ab76b2a4ae7':
  adb: win32: fix USB device hang when resuming from sleep/hibernation
2015-08-11 21:55:47 +00:00
Elliott Hughes 7989a7c8d3 Merge "adb: win32: fix USB device hang when resuming from sleep/hibernation" 2015-08-11 21:43:32 +00:00
Yabin Cui 661327e8e4 Remove confusing variable HOST.
First, HOST is always 0 in adbd, which matches ADB_HOST=0.
Second, HOST is always 1 when adb_main is called, which matches ADB_HOST=1.
For adb client that doesn't call adb_main, it never touches local_init(),
init_transport_registration() and fdevent_loop(). So the changes in adb.cpp,
services.cpp and transport_local.cpp do nothing with it.
As a conclusion, I think we can remove HOST and use ADB_HOST instead.

Change-Id: Ide0e0eca7468b6c3c130f6b50974406280678b2e
2015-08-11 14:00:15 -07:00
Elliott Hughes 6396f64fd7 am 61ff977b: am 1f36ae49: Merge "adb: win32: write ACK to separate pipe instead of stdout"
* commit '61ff977ba49f43d87fed86eb5b2e2bfc279f902b':
  adb: win32: write ACK to separate pipe instead of stdout
2015-08-11 01:50:26 +00:00
Spencer Low 5c398d2ce9 adb: win32: write ACK to separate pipe instead of stdout
The win32 version of 9f2d1a9cfc. The big
technique is to fit a Win32 HANDLE value in an int because it only uses
32-bits. This allows most of the other adb code to stay the same.

Also, fix a regression in the 'adb server nodaemon' command that was
erroneously returning an error when --reply-fd was not used, which
should not be necessary for this particular command.

Change-Id: I37e9c609014b813af93bf0d6c12f665b59c93c41
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-08 15:07:07 -07:00
Elliott Hughes 184585c417 am af60acef: am 98714882: Merge "adb start-server: Use a separate fd for sending initial OK"
* commit 'af60acef8231f03f7c736ed8ce86bd59979f9f6c':
  adb start-server: Use a separate fd for sending initial OK
2015-08-07 21:17:00 +00:00
Elliott Hughes a4a902432e am c1b6378d: am e1101677: Merge "adb: fix killing of old version of adb process"
* commit 'c1b6378d96dda18f1a6b9d9cf33f9ed4eb6f6603':
  adb: fix killing of old version of adb process
2015-08-07 20:21:02 +00:00
Elliott Hughes 08fe47e3bd am c6195530: am db3492cf: Merge "win32: adb_test/libbase_test fixes"
* commit 'c61955305e4e6b222801e694af9d578b39485ac5':
  win32: adb_test/libbase_test fixes
2015-08-07 20:20:59 +00:00
Siva Velusamy 9f2d1a9cfc adb start-server: Use a separate fd for sending initial OK
When "adb start-server" is issued, and a server needs to be launched,
adb client forks itself and the child process runs the server routine.
Once the server initializes its various components, it sends an "OK\n"
back to the client via its stderror (or stdout on Windows).

This sequence breaks down if before sending the "OK\n", the server
happens to log something on its stderr. In order to avoid this, the
client now expects the ack to come on a different fd rather than one
of the standard streams.

Bug: https://code.google.com/p/android/issues/detail?id=182150

Change-Id: I9d58a08068d71eb3b77e8a7377e934631c016466
2015-08-07 11:31:07 -07:00
Elliott Hughes e1101677ea Merge "adb: fix killing of old version of adb process" 2015-08-07 03:04:30 +00:00
Elliott Hughes db3492cf17 Merge "win32: adb_test/libbase_test fixes" 2015-08-07 01:36:03 +00:00
Spencer Low cbf26b76c7 win32: adb_test/libbase_test fixes
- My recent change with -DUNICODE=1 required changing
   GetProfilesDirectory() to GetProfilesDirectoryA() for the ANSI version
   of the API.

 - enh's edit to my previous change deleted a test that used
   /proc/version, but I think another test was missed. Merge that test into
   another.

Change-Id: Ic748549848e7be922bcbf218d5b0c3fca2a90704
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-06 18:09:32 -07:00
Elliott Hughes 0e3b339bbb am 2fbae482: am c672cb07: Merge "Include the error code if GetPipeProperties fails."
* commit '2fbae4829b07c97e82c24e6bf54e58f7de477fe6':
  Include the error code if GetPipeProperties fails.
2015-08-06 18:09:59 +00:00
Elliott Hughes c672cb0743 Merge "Include the error code if GetPipeProperties fails." 2015-08-06 17:49:41 +00:00
Elliott Hughes 6e02c24cfc Include the error code if GetPipeProperties fails.
Bug: http://b/22829602
Change-Id: I90a89e70518053a4581e1862a7dbd5d09e06dadc
2015-08-06 10:48:19 -07:00
Yasuhiro Matsuda a25e258d65 am b84e1f54: am 50de8224: Merge "Enable perfboot.py to install APKs before measurement."
* commit 'b84e1f540379c6af9ccfc22e779b67f67b8c210a':
  Enable perfboot.py to install APKs before measurement.
2015-08-06 12:40:24 +00:00
Spencer Low 71635bb966 adb: fix killing of old version of adb process
The original code was:

  if (strcmp(__adb_error, "unknown host service") != 0)

But that was changed by 078f0fcf4c to:

  if (*error == "unknown host service") {

I think the comparison should be != so that "unknown host service"
falls-through and kills the server, and so if it is some other error,
that the other error is returned immediately.

Change-Id: Ia490a4a870d1d123a3c5ab258dd5fa0930e8032d
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-05 19:26:50 -07:00
Yasuhiro Matsuda c0822e83ad Enable perfboot.py to install APKs before measurement.
This CL adds --apk-dir option, which specifies the directory
that contains APK files to be installed before measuring
boot time.

BUG: 22207911
Change-Id: Ifeacf34c779248686443a9ef02485272c140a456
2015-08-06 11:02:17 +09:00
Elliott Hughes b5c4bc3833 am f7af90c9: am 3cf2a8e0: Merge "Fix a comment typo."
* commit 'f7af90c9df6e863c15b39da811f194435aa5da94':
  Fix a comment typo.
2015-08-04 01:07:09 +00:00
Elliott Hughes 7ace565f6b am 1da90f0c: am feacf20d: Merge "adb: win32: file descriptor reliability improvements"
* commit '1da90f0c14d315b10d8cc8cd2cfaacd794758ec3':
  adb: win32: file descriptor reliability improvements
2015-08-04 01:07:08 +00:00
Elliott Hughes 3cf2a8e0ee Merge "Fix a comment typo." 2015-08-04 00:51:38 +00:00
Elliott Hughes feacf20d1e Merge "adb: win32: file descriptor reliability improvements" 2015-08-04 00:50:43 +00:00
Elliott Hughes bfa7c7d9e2 Fix a comment typo.
Change-Id: Ifacb19b9c31ac81fbf02c8382eb0324ea79075b9
2015-08-03 16:26:13 -07:00
Elliott Hughes fb1dbac143 am eee501ec: am 6b940e13: Merge "adb: win32: define UNICODE/_UNICODE, Unicode error messages, misc"
* commit 'eee501ece6d3d0add9f67ce2c71cef6620cf6bf5':
  adb: win32: define UNICODE/_UNICODE, Unicode error messages, misc
2015-08-03 21:37:39 +00:00
Elliott Hughes b7c0bfbc5e am 14c08745: am 6355f2c1: Merge "adb: win32: call SystemErrorCodeToString() from more places"
* commit '14c08745ac3ff46330b545354664ffd3c8f60844':
  adb: win32: call SystemErrorCodeToString() from more places
2015-08-03 21:17:27 +00:00
Elliott Hughes e043761c7a am c783e1a3: am 0fac7fd1: Merge "Leave the evidence lying around if an adb test fails."
* commit 'c783e1a3f35675169b5ca85d3dc0f6a8c22ce901':
  Leave the evidence lying around if an adb test fails.
2015-08-03 21:17:26 +00:00