Commit Graph

1493 Commits

Author SHA1 Message Date
Spencer Low ebf770fd73 fix adb_test Windows build
adb/Android.mk: adb_test should build on Windows (and Darwin), so add to
the whitelist.

Change-Id: I778f6a7dff4caec92c48e0957591abf32f86ab1b
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-11 15:47:20 -07:00
David Pursell 90ba84b286 am 31139af0: Merge "adb: create shell protocol class (take 2)."
* commit '31139af04f97c843db2a98c7fafc1d58d7f7c8ac':
  adb: create shell protocol class (take 2).
2015-09-11 22:14:17 +00:00
David Pursell 606835ae5c adb: add client side shell protocol and enable.
Adds the shell protocol functionality to the client side and enables it
if the transport supports the feature.

Bug:http://b/23031026
Change-Id: I9abe1c8b1d39f8dd09666321b1c761ad708a8854
2015-09-11 13:02:17 -07:00
David Pursell 0955c66b22 adb: implement shell protocol.
Adds functionality for handling stdin/stdout/stderr streams and exit
codes using the shell protocol.

This CL just contains implementation for adbd which will not yet be
enabled. Once we have the ability to query transport features from the
adb client, another CL will add the implementation for the client side
and update the feature list to turn this on.

Note: this CL must be submitted together with a minadbd CL to update
the service_to_fd() function signature.

Bug: http://b/23030641

Change-Id: Ibed55e9c1946d8a35190696163ff63e8fb880238
2015-09-11 11:27:50 -07:00
David Pursell 31139af04f Merge "adb: create shell protocol class (take 2)." 2015-09-11 18:17:55 +00:00
Dan Willemsen 2f6d1e5486 am a376c046: am aaf4fcf4: Merge "Remove HOST_OS==windows check"
* commit 'a376c046bf7f5f86b53190d1f8dab309dd80a58b':
  Remove HOST_OS==windows check
2015-09-09 18:31:10 +00:00
Dan Willemsen a376c046bf am aaf4fcf4: Merge "Remove HOST_OS==windows check"
* commit 'aaf4fcf482d427459c70e10a22fef5ea9c7bca1a':
  Remove HOST_OS==windows check
2015-09-09 18:19:15 +00:00
Dan Willemsen aaf4fcf482 Merge "Remove HOST_OS==windows check" 2015-09-09 18:13:22 +00:00
Yabin Cui 4a53f6ec43 am b73eb268: am 4ddb6a32: Merge "adb: remove unnecessary dependencies of liblog."
* commit 'b73eb268ffdf61257342bdb256f6dd372666ffaf':
  adb: remove unnecessary dependencies of liblog.
2015-09-09 18:03:27 +00:00
Yabin Cui 824a51eae4 am bd9305ee: am 0df24ea2: Merge "adb: refactor _is_valid_ack_reply_fd"
* commit 'bd9305eeb7152058ba8255f0c2601d512c906f98':
  adb: refactor _is_valid_ack_reply_fd
2015-09-09 18:03:25 +00:00
Yabin Cui b73eb268ff am 4ddb6a32: Merge "adb: remove unnecessary dependencies of liblog."
* commit '4ddb6a3289d7cc1d1f60e3ae0af231da55f937ac':
  adb: remove unnecessary dependencies of liblog.
2015-09-09 17:57:36 +00:00
Yabin Cui bd9305eeb7 am 0df24ea2: Merge "adb: refactor _is_valid_ack_reply_fd"
* commit '0df24ea234fcfb9ac57ed94701868426a41d8642':
  adb: refactor _is_valid_ack_reply_fd
2015-09-09 17:57:34 +00:00
Yabin Cui 4ddb6a3289 Merge "adb: remove unnecessary dependencies of liblog." 2015-09-09 17:38:31 +00:00
Yabin Cui cb992d9a21 adb: remove unnecessary dependencies of liblog.
Change-Id: I1aaa9e6c1b47a70f8daf91745f6aec13c92b789f
2015-09-08 18:27:10 -07:00
David Pursell b9e2e84e7e adb: create shell protocol class (take 2).
Adds a new class ShellProtocol to help read and write data with
`adb shell`. This will allow splitting streams and sending out-of-band
data such as exit codes.

Nothing uses the new class yet except the unit tests.

This is the second attempt at this CL, the first is at
http://r.android.com/169600. The problems was using sighandler_t
which is not available on mac. sig_t is used instead which is available
due to _GNU_SOURCE being defined in Android.mk, which causes
_BSD_SOURCE -> __USE_BSD -> sig_t to be defined. Nothing else has been
changed from the original CL.

Bug: http://b/23030641
Change-Id: I7bd7f5a82ad811fbca7a3eee1236d2c55ae57c48
2015-09-08 10:04:10 -07:00
Spencer Low a13df3070f adb: refactor _is_valid_ack_reply_fd
Visual Studio's 'jump to reference' feature couldn't parse
adb_commandline() because I used an #ifdef in the middle of an if
statement, so this refactors the code into a separate helper function. I
just copied the code and inverted the comparisons.

No need for sysdeps since this is pretty minor.

Change-Id: Ifd5c62b0b505080ada6db5cc19739c6f07b94de9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-07 16:20:13 -07:00
David Pursell beb81f48d8 am 9432e753: am da0b0116: Merge "Revert "adb: create shell protocol class.""
* commit '9432e7538ac5ce57a0701bfe274b3eab8589544e':
  Revert "adb: create shell protocol class."
2015-09-06 02:41:35 +00:00
David Pursell 9432e7538a am da0b0116: Merge "Revert "adb: create shell protocol class.""
* commit 'da0b0116ba676203328906608a78dd240e0fea48':
  Revert "adb: create shell protocol class."
2015-09-06 02:38:35 +00:00
David Pursell da0b0116ba Merge "Revert "adb: create shell protocol class."" 2015-09-06 02:34:02 +00:00
David Pursell d9b74192b8 Revert "adb: create shell protocol class."
This CL broke the mac build. I'll revert for now and take a look at how to get it working next week.

This reverts commit 73096f2e1d.

Change-Id: Icb3e015250bcbbc69a45675a1358699ebe01e77b
2015-09-06 01:18:47 +00:00
David Pursell 04aa49346a am 74b6e8ec: am e4c1bb53: Merge "adb: `features` passes transport features."
* commit '74b6e8ecfdb4e7f46d53f174e8ba21ce74f90482':
  adb: `features` passes transport features.
2015-09-05 00:16:00 +00:00
David Pursell 897baffb75 am 3f742914: am 21541531: Merge changes from topic \'adb_shell_prework\'
* commit '3f742914b1dd66bdf172059fc7c4bf421e3a87a6':
  adb: create shell protocol class.
  adb: refactor subprocess code.
  adb: move shell service to a separate file.
2015-09-05 00:08:33 +00:00
David Pursell 74b6e8ecfd am e4c1bb53: Merge "adb: `features` passes transport features."
* commit 'e4c1bb53068db184ee4cb19513ffe7764a09722f':
  adb: `features` passes transport features.
2015-09-05 00:07:54 +00:00
David Pursell e4c1bb5306 Merge "adb: `features` passes transport features." 2015-09-05 00:01:27 +00:00
David Pursell 3f742914b1 am 21541531: Merge changes from topic \'adb_shell_prework\'
* commit '215415318d8483d648955b72bb3b083e131cb62e':
  adb: create shell protocol class.
  adb: refactor subprocess code.
  adb: move shell service to a separate file.
2015-09-05 00:01:02 +00:00
David Pursell 215415318d Merge changes from topic 'adb_shell_prework'
* changes:
  adb: create shell protocol class.
  adb: refactor subprocess code.
  adb: move shell service to a separate file.
2015-09-04 23:54:19 +00:00
David Pursell 880be434a9 adb: `features` passes transport features.
`adb features` previously returned a list of host features which was
not terribly useful. This CL changes functionality to return the
transport features instead using the standard targeting args:
  $ adb features  # default target.
  $ adb -e features
  $ adb -s 123456 features

Also adds a "check-feature" service which is currently unused but will
allow the adb client to easily check for a specific feature.

Bug: http://b/23824036
Change-Id: Ibc0c420c75f73d363f3bba7705af616ba2059348
2015-09-04 16:47:21 -07:00
Dan Willemsen 66680c506a Remove HOST_OS==windows check
With the HOST_CROSS_OS build system change, LOCAL_MULTILIB := first now
behaves the same way.

Change-Id: I03294403e5a106a53d4a0d48b176434221284901
2015-09-04 14:05:19 -07:00
David Pursell 73096f2e1d adb: create shell protocol class.
Adds a new class ShellProtocol to help read and write data with
`adb shell`. This will allow splitting streams and sending out-of-band
data such as exit codes.

Nothing uses the new class yet except the unit tests.

Bug: http://b/23030641

Change-Id: Ieb02e127095c6dda25b7cb188a2e599173fd97e6
2015-09-04 11:30:11 -07:00
David Pursell a932058504 adb: refactor subprocess code.
Refactor shell_service.cpp to remove dependencies on service.cpp and
combine some common logic between PTY and raw subprocesses.

This will make it easier to add additional common code paths for
the upcoming shell protocol.

Change-Id: I497d30dd388de61b6e68d9086dce38f33dd92876
2015-09-04 11:18:51 -07:00
Tom Cherry c74403b4c9 am b00a8a06: am e8b0fcec: Merge "combine adbd.rc with init.usb.rc"
* commit 'b00a8a066f5b6ae5b8d0c03ee7f680389b38a260':
  combine adbd.rc with init.usb.rc
2015-09-04 18:02:32 +00:00
Tom Cherry b00a8a066f am e8b0fcec: Merge "combine adbd.rc with init.usb.rc"
* commit 'e8b0fcecf4a17cf37b5fefbcceef0920788f776e':
  combine adbd.rc with init.usb.rc
2015-09-04 17:56:25 +00:00
David Pursell 80f67029e0 adb: move shell service to a separate file.
Upcoming changes to the shell will require significant additions to
the subprocess code, and it will be cleaner if it's in a separate file.

The only functional change here is a new debug tag specifically for
the shell service. Everything else has been copied exactly as-is in
order to make it easier to determine what's changing in upcoming CLs.

Change-Id: I13bd4294059051ee10e0d0c6a06affd8eca62967
2015-09-04 08:52:35 -07:00
Tom Cherry 2270dbbc84 combine adbd.rc with init.usb.rc
init.usb.rc and adbd.rc contain similar contents and belong in the same
file.

This file also belongs on the ramdisk as adbd is on the ramdisk, not the
system partition, therefore resolving to keep init.usb.rc in its current
location and combining the contents of adbd.rc is the best approach

Change-Id: I430f8fea58694679e7b8b7be69ce87daadd616f4
2015-09-03 16:19:04 -07:00
Elliott Hughes 27e427aaa2 am db31ac76: am 478da637: Merge "Improve adb sync_send error reporting."
* commit 'db31ac76baf732244b9492a96db43fd90070411a':
  Improve adb sync_send error reporting.
2015-09-03 21:41:56 +00:00
Elliott Hughes db31ac76ba am 478da637: Merge "Improve adb sync_send error reporting."
* commit '478da6374b5f4a5742566edfe3057c674a51615e':
  Improve adb sync_send error reporting.
2015-09-03 21:33:59 +00:00
Elliott Hughes 081696d27c Improve adb sync_send error reporting.
Bug: http://b/23786900
Change-Id: I71f10de8d767eaf8bf0f5d9b8c304527e2b953ff
2015-09-03 13:55:55 -07:00
Yabin Cui 9bbc68dd07 am 7d0b4ada: am 6562c151: Merge "adb: clean up debug tracing a little."
* commit '7d0b4ada0bf539a0f48b00e211799400aa733f4d':
  adb: clean up debug tracing a little.
2015-09-03 18:14:05 +00:00
Yabin Cui 7d0b4ada0b am 6562c151: Merge "adb: clean up debug tracing a little."
* commit '6562c1513b2b7bd88da8b1d0c88b89e66b2dcd69':
  adb: clean up debug tracing a little.
2015-09-03 17:38:57 +00:00
Yabin Cui 6562c1513b Merge "adb: clean up debug tracing a little." 2015-09-03 17:32:44 +00:00
Yabin Cui 7a3f8d6691 adb: clean up debug tracing a little.
Always use LOG() for debug tracing.
Remove useless D_lock. I believe it is useless to lock just before and after fprintf.

I verified the log output both on host and on device. The output looks fine to me.

Change-Id: I96ccfe408ff56864361551afe9ad464d197ae104
2015-09-02 20:21:00 -07:00
Dan Willemsen 54afdbaef7 am a4b8f9f1: am bfe32228: Merge "Remove USE_MINGW/CYGWIN; Whitelist windows modules"
* commit 'a4b8f9f1c2d9fb6795c81ae39441e720662602d0':
  Remove USE_MINGW/CYGWIN; Whitelist windows modules
2015-09-03 02:15:32 +00:00
Dan Willemsen a4b8f9f1c2 am bfe32228: Merge "Remove USE_MINGW/CYGWIN; Whitelist windows modules"
* commit 'bfe322285fdbe86fdc01fdc4c711e22e894bdaee':
  Remove USE_MINGW/CYGWIN; Whitelist windows modules
2015-09-03 00:39:19 +00:00
Dan Willemsen 87a419c8b1 Remove USE_MINGW/CYGWIN; Whitelist windows modules
CYGWIN is not supported, USE_MINGW and HOST_OS==windows are being
replaced with LOCAL_..._windows variables.

Bug: 23566667
Change-Id: I3e4a1e4097dc994cf5abdce6939e83a91758fd75
2015-09-02 17:10:35 -07:00
Elliott Hughes 0b23a08b27 am 1428640f: am 5d804006: Merge "adb/base win32 tests: fix comment and open() flags"
* commit '1428640f5cf69ede7dcafa7ae5ecca5a0a4fff50':
  adb/base win32 tests: fix comment and open() flags
2015-09-01 22:39:00 +00:00
Elliott Hughes 1428640f5c am 5d804006: Merge "adb/base win32 tests: fix comment and open() flags"
* commit '5d8040060515128f2bee9b4759d0618b90c4d70c':
  adb/base win32 tests: fix comment and open() flags
2015-09-01 22:10:57 +00:00
Spencer Low 2fbeb0cc71 adb/base win32 tests: fix comment and open() flags
Match base's use of O_BINARY.

Change-Id: I930b5c8fddde20966580069f2e681b99cb26f1a3
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-01 14:57:58 -07:00
Elliott Hughes 59224c9537 resolved conflicts for merge of 46603db5 to mnc-dr-dev-plus-aosp
Change-Id: I3fb7ff8e9d9313c294620ae0ce63a17766940ec4
2015-09-01 11:25:24 -07:00
Yabin Cui 14bf82e21f am 2ae47a0b: Merge "adb: add unit test for fdevent."
* commit '2ae47a0b54c51d05cfb5bab3e1d7a34d5d15ba1b':
  adb: add unit test for fdevent.
2015-09-01 16:37:39 +00:00
Yabin Cui 7a3dc5eacf am 1e19317e: Merge "adb: improve names for transport threads."
* commit '1e19317e575e1020cc0c241c4591a3f95f6a45c4':
  adb: improve names for transport threads.
2015-09-01 16:37:35 +00:00
Yabin Cui 85c04dfeb6 am 1531cee6: Merge "adb: remove workaround for b/6558362."
* commit '1531cee658ecc46a8eda3c1bc13a09fd4fa73eb9':
  adb: remove workaround for b/6558362.
2015-09-01 16:37:22 +00:00
Elliott Hughes 7dbc0936e8 am b6bfd36c: Merge "Distinguish transport threads."
* commit 'b6bfd36c19626ef1aca3b5d28092721c6b498a34':
  Distinguish transport threads.
2015-09-01 16:36:41 +00:00
Siva Velusamy 1f9d3b07a6 am c9525ec3: Merge "adb: set thread names (linux & mac)"
* commit 'c9525ec366232aa6a0968be1cc8e8abc37df789f':
  adb: set thread names (linux & mac)
2015-09-01 16:36:29 +00:00
Yabin Cui 2ae47a0b54 Merge "adb: add unit test for fdevent." 2015-08-31 22:40:04 +00:00
Yabin Cui 1e19317e57 Merge "adb: improve names for transport threads." 2015-08-31 21:21:21 +00:00
Yabin Cui d6ab3c2245 adb: improve names for transport threads.
The old names seems confusing. output_thread was reading remote data and writing to
local sockets. input_thread was reading local sockets data and writing to remote.
This change tries to make it clear by renaming output_thread to read_transport thread,
and renaming input_thread to write_transport thread.

Change-Id: I2e7b4cde7a94d436f3745e9e3ab10780e7caa8ac
2015-08-31 13:34:27 -07:00
Yabin Cui c6424585a2 adb: remove workaround for b/6558362.
I believe the problem has been fixed in https://android-review.googlesource.com/#/c/168412/.
So it's time to remove the workaround.

Bug: 6558362
Change-Id: I399c18eda0693f3c51feac07ff59a0a4b5558128
2015-08-31 12:10:11 -07:00
Elliott Hughes 0c3914a44d Distinguish transport threads.
Use "<-" and "->" to work around Linux's very short thread name limit.

Bug: http://b/23423333
Change-Id: I9f3f096415b47162dacb660cd0a97ac7ff6107e6
2015-08-31 10:46:05 -07:00
Siva Velusamy 49ee7cf9a1 adb: set thread names (linux & mac)
Bug: 23423333
Change-Id: I0069f32ddbae2a10fb130064f721facf45b2cc09
2015-08-31 07:52:52 -07:00
Yabin Cui bec02fc43d adb: add unit test for fdevent.
Change-Id: Ic26cda5d8e84425bc60ce36bc686bb6917c4ca3c
2015-08-28 21:33:22 -07:00
Elliott Hughes b77146ce7c am 9f07f879: Merge "fatal and fatal_errno should be noreturn."
* commit '9f07f87908f072d63d8bb9ded91616af8d3edbb4':
  fatal and fatal_errno should be noreturn.
2015-08-29 02:30:50 +00:00
Yabin Cui 432ea8f94e am a3bdc6ab: Merge "adb: clean up transport disconnect operations."
* commit 'a3bdc6aba29950b38a4c8ab785e5828451e97140':
  adb: clean up transport disconnect operations.
2015-08-29 02:30:49 +00:00
Elliott Hughes 9f07f87908 Merge "fatal and fatal_errno should be noreturn." 2015-08-29 02:22:18 +00:00
Yabin Cui a3bdc6aba2 Merge "adb: clean up transport disconnect operations." 2015-08-29 02:21:46 +00:00
Elliott Hughes 2f3342fa33 fatal and fatal_errno should be noreturn.
Change-Id: I9c5d9cb5ed743d13e65112a111cc9544ec5da339
2015-08-28 19:13:10 -07:00
Yabin Cui b329824e6c adb: clean up transport disconnect operations.
Move operations from global functions into member functions.
Add unit test.

Change-Id: Id4543d8e78541eb08c8e629f180c605c699737ec
2015-08-28 16:36:00 -07:00
Elliott Hughes 9382e6c071 am f6224587: Merge "Improve adb tracing."
* commit 'f6224587e5fdb8d659172ba5a87a55685a94adf7':
  Improve adb tracing.
2015-08-28 23:09:40 +00:00
Elliott Hughes f6224587e5 Merge "Improve adb tracing." 2015-08-28 21:56:46 +00:00
Elliott Hughes bd4b1fa4a9 Improve adb tracing.
The existing format was unreadable; putting the pid and tid first helps
somewhat. Also remove the unused qemu tracing which wasn't called anywhere.

Change-Id: I37ef3c556fe17b237ba1d8ca3216e2155ce5d0de
2015-08-28 14:46:33 -07:00
Yabin Cui bbe5de2307 am 88a51cd4: Merge "adb: call run_transport_disconnects() only once."
* commit '88a51cd4d8377516f693720f427511cb40e90b75':
  adb: call run_transport_disconnects() only once.
2015-08-28 20:59:30 +00:00
Yabin Cui 88a51cd4d8 Merge "adb: call run_transport_disconnects() only once." 2015-08-28 20:50:07 +00:00
Elliott Hughes bffa890641 am e73a8a23: Merge "win32: adb start-server shows stdout/stderr output from actual server"
* commit 'e73a8a2388f019b0f7a6e468af27056edbb02521':
  win32: adb start-server shows stdout/stderr output from actual server
2015-08-28 20:23:49 +00:00
Elliott Hughes e73a8a2388 Merge "win32: adb start-server shows stdout/stderr output from actual server" 2015-08-28 20:13:40 +00:00
Elliott Hughes 4417c38a1e am a54f14eb: Merge "adb unittest: get test_unicode_paths passing on win32"
* commit 'a54f14eb95d73c91aaa2a4387a79d897a4731060':
  adb unittest: get test_unicode_paths passing on win32
2015-08-28 20:07:47 +00:00
Elliott Hughes a54f14eb95 Merge "adb unittest: get test_unicode_paths passing on win32" 2015-08-28 20:00:53 +00:00
Elliott Hughes be881b65ca am 1d9253f2: Merge "adb: fix adb install and adb push exit code, error handling, unittest"
* commit '1d9253f255c60069c4187f0c43b2b22015fd5688':
  adb: fix adb install and adb push exit code, error handling, unittest
2015-08-28 19:52:18 +00:00
Elliott Hughes 1d9253f255 Merge "adb: fix adb install and adb push exit code, error handling, unittest" 2015-08-28 19:46:46 +00:00
Yabin Cui adab77ad50 am 7b6fa7ed: Merge "adb: remove adisconnect in aremotesocket."
* commit '7b6fa7ed304cbd682e4c4cb539f2e4f8047aedc4':
  adb: remove adisconnect in aremotesocket.
2015-08-28 18:57:35 +00:00
Yabin Cui 12d7f0909a adb: call run_transport_disconnects() only once.
Currently run_transport_disconnects() are called twice. One is in
handle_offline(), another is before destroying transport.
The users of disconnect callback are listener, adb_auth_client, and
remote_sockets. All of them need only to be called once. And after
handle_offline, no new listeners, adb_auth_client, or remote_sockets
can be connected to the offlined transport. So I think we can remove
the second call to run_transport_disconnects().

Change-Id: I1ef8b6b7b5ab7ae1bad109be107c85973d65a2e3
2015-08-28 11:39:37 -07:00
Spencer Low d8cce1817b adb: fix adb install and adb push exit code, error handling, unittest
adb push was not returning a bad exit code when write_data_file() or
write_data_link() failed. I encountered this when running the unittest
on Windows which can get into situations where stat() succeeds, but
open() fails due to pre-existing exclusive file access (which typically
doesn't exist on unix).

The same code is used by adb install, so this also fixes its error
handling.

Fixed some fd leaks and propagation of errors when reading a file.

Fixed a unittest to close temp files before reading them.

Change-Id: Ieba0026fa4c79eb0484676e4f2faaac9603ef584
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-28 11:38:28 -07:00
Spencer Low de4505f819 adb unittest: get test_unicode_paths passing on win32
The Python 2 subprocess class doesn't use Unicode, so as a work-around
write the command line to a UTF-8 batch file and run that.

I modified the test to use u'blah' without .encode('utf-8') because the
Python docs recommend dealing with string variables like that. When
formatting a string with a unicode parameter, use u'foo' on the constant
string to make it unicode.

I also tested this on Linux and it seems to work fine (I did ls in the
middle of the test to make sure the filenames came out right, etc.).

I had to close the temporary files before adb tries to read/write them
because filesystem semantics are different on Windows (technically I
might be able to modify adb to try to open files with more permissive
share flags, but then I'm not sure if Python uses the right share flags.
Basically, I'd be opening another can of worms.).

Fixed the test to delete a temp file on the device once it is done.

Change-Id: Id0c34e26d7697fbbb47a44ae45298bed5e8c59d6
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-28 01:20:03 -07:00
Yabin Cui fd28f327ee adb: remove adisconnect in aremotesocket.
The function of remote_socket_disconnect() is to make sure
the local_sockets and remote_sockets are closed when the binded
transport is disconnected. However, as we call close_all_sockets()
in handle_offline(), we don't need remote_socket_disconnect() any more.

Change-Id: I575f632d9f8703149f34e0210eb698a56e2516a9
2015-08-27 19:35:47 -07:00
Yabin Cui a483eae5b1 am 4f8d5b01: Merge "adb: disconnect: fix write-after-free memory corruption and crash."
* commit '4f8d5b01281e751168718c7b0a74db34352aaf1e':
  adb: disconnect: fix write-after-free memory corruption and crash.
2015-08-27 23:05:43 +00:00
Yabin Cui f4b9928563 adb: disconnect: fix write-after-free memory corruption and crash.
Transport atransport objects are semi-reference counted: the input and
output threads each hold a reference. The adb disconnect command was
calling transport_unref to release a reference that it never had in the
first place. This meant that the refcount dropped to zero and the object
was deleted before either the input or output thread released its
reference. When that last thread released its reference, it wrote to
freed memory and also sometimes crashed.

This fix is to not release any unheld reference, instead it just kicks
the transport to break remote_read in output_thread. So all transport
close flow goes the following way:
output_thread (exit) -> main thread (offline the transport) ->
input thread (exit) -> main thread (destroy the transport)

Change-Id: Iad1fe718acc8716f3a79c8c22b426a1b2450452c
2015-08-27 14:41:07 -07:00
Yabin Cui 9f91681d50 am f3068123: Merge "adb: fix a fake data race on transport:kick reported by tsan."
* commit 'f3068123039e81cee85ce9103d01b5b2aceb2ba3':
  adb: fix a fake data race on transport:kick reported by tsan.
2015-08-27 18:29:50 +00:00
Yabin Cui f306812303 Merge "adb: fix a fake data race on transport:kick reported by tsan." 2015-08-27 18:25:02 +00:00
Yabin Cui 860169cbf8 am 804180b2: Merge "adb: fix a data race in local_socket_event_func."
* commit '804180b2ccf2ef4dedad7d136c060ecbdda7aac5':
  adb: fix a data race in local_socket_event_func.
2015-08-27 05:22:52 +00:00
Spencer Low 2122c7a148 win32: adb start-server shows stdout/stderr output from actual server
When launching the adb server (typically from adb start-server),
redirect stdout/stderr to anonymous pipes which are read by threads in
the parent process, to make error diagnosis easier.

If there is an error during adb start-server, the output looks like:

> adb start-server
* daemon not running. starting it now on port 5037 *
error: could not blah                 # from server process
could not read ok from ADB Server     # from launch_server
* failed to start daemon *            # from adb_connect
error: cannot connect to daemon       # from adb_commandline

Fix handle-leaks in launch_server by using new unique_handle class
that is based on std::unique_ptr.

In the server, close stdin and redirect to adb.log *before* sending the
ACK, so that any errors are reported early instead of after the ACK.

Change-Id: I943881210a0ea9458fc36851339f916c3d6a0830
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-26 18:46:09 -07:00
Elliott Hughes 24f165f121 Minimal fix for adb backup.
In master this code has been completely rewritten. This is the minimal fix
against the mnc-sdk-release source.

Bug: http://b/23015233
Bug: https://code.google.com/p/android/issues/detail?id=183490
Change-Id: Iac30993bd2b1b354f8518d8ea2a9ae680ebe4177
2015-08-26 22:30:56 +00:00
Yabin Cui d8459b3d3c adb: fix a fake data race on transport:kick reported by tsan.
It is reported by tsan as a double checked locking. But I think
it is not a real data race. Because I think the old code is able
to make sure t->kick() is only called once, and the caller of
kick_transport is not relying on the side-effect of calling
t->kick().
But as it is not perf critical, I don't mind breaking the double
checked locking pattern.

Bug: 23385662
Change-Id: Ie3597dd56bb514117c3865d2afcfd7c115731a78
2015-08-26 15:22:56 -07:00
Yabin Cui 804180b2cc Merge "adb: fix a data race in local_socket_event_func." 2015-08-26 22:11:26 +00:00
Yabin Cui 0067412421 adb: fix a data race in local_socket_event_func.
If s->peer->enqueue() failed, s may be freed. So we should use
saved_xxx instead of s->xxx before verifying the return value.

Change-Id: I6c072406dceb98e2d02798d0dcdc428fa99e66fb
2015-08-26 15:06:43 -07:00
Yabin Cui 4edb97abb7 am f03aa667: am fbdd5ee2: Merge "adb: keep all asocket operations in the main thread."
* commit 'f03aa6670e39ef1a46211960d134b2528a3649f5':
  adb: keep all asocket operations in the main thread.
2015-08-26 19:55:19 +00:00
Yabin Cui 34f45c5663 adb: keep all asocket operations in the main thread.
As far as I can see, all asockets operations happen in fdevent_loop()
in the main thread, excepting close_all_sockets(). Instead of adding
lock and ref_count for each asocket, a simpler way would be moving
close_all_sockets() from input_thread to the main thread.

In input_thread(), there are two path to break the loop and call
close_all_sockets(). One path is when receiving offline A_SYNC, which
is sent by the main thread. The other path is when read_packet
fails, which I believe is almost not possible and doesn't matter
(Because t->fd is closed just before t is freed.). So I move
close_all_sockets() to handle_offline() in the main thread.

the socket_list_lock in sockets.cpp could be removed. But I prefer
to leave it for the following changes.

Bug: 6558362
Change-Id: I5da23f60a67a331262c62693b9b127fe2689c799
2015-08-26 11:27:43 -07:00
Elliott Hughes 8303f54a58 am b6ae989a: am 0ac29519: Merge "Don\'t build 32-bit host libadb."
* commit 'b6ae989acf9958632ce91d2f06fd185aeb9fd0d3':
  Don't build 32-bit host libadb.
2015-08-26 02:49:20 +00:00
Elliott Hughes daa6c463a9 Don't build 32-bit host libadb.
Change-Id: Ib6ad3db2dc160273d20fa14e0820f29ed649d75a
2015-08-25 19:38:14 -07:00
Elliott Hughes 1533f95bba am 615af25f: am a421c1e5: Merge "Possible Mac build fix."
* commit '615af25ffdde99331c173499446e08c3a7ec32a8':
  Possible Mac build fix.
2015-08-26 01:14:30 +00:00
Elliott Hughes 62077d32a2 Possible Mac build fix.
The error was this:

  system/core/adb/usb_osx.cpp:203:74: error: values of type 'UInt32' should not
  be used as format arguments; add an explicit cast to 'unsigned int' instead
  [-Werror,-Wformat]
    snprintf(devpathBuf, sizeof(devpathBuf), "usb:%" PRIu32 "X", locationId);
                                                  ~~~            ^~~~~~~~~~
                                                                 (unsigned int)

Which seems to be because on LP64 UInt32 is "unsigned int" but on LP32 it was
"unsigned long". We don't have to care about LP32, so -- if we can -- we're
probably better off just using uint32_t instead of UInt32.

Change-Id: I576f76cf2016ee59caccbc317ef74b6e8d71d722
2015-08-25 17:48:12 -07:00
Elliott Hughes 4f2015a155 am 9492db23: am 62643302: Merge "Not all filesystems support setting SELinux labels."
* commit '9492db23b9feeb589be36fece46e55dc66d7f1dd':
  Not all filesystems support setting SELinux labels.
2015-08-26 00:30:33 +00:00
Elliott Hughes 383444085a Not all filesystems support setting SELinux labels.
Bug: http://b/23530370
Change-Id: Ie4deb3544304754696f049d17b12168cad4a51fd
2015-08-25 16:33:50 -07:00
Elliott Hughes 39206a08d8 am 1ce12d39: am 43f43d87: Merge "Move adb\'s selinux_android_restorecon up and check for failures."
* commit '1ce12d397f1f563ee3eac4c1fdb907909d6eeff1':
  Move adb's selinux_android_restorecon up and check for failures.
2015-08-25 20:43:55 +00:00
Elliott Hughes 0adc09721f Move adb's selinux_android_restorecon up and check for failures.
Change-Id: Ib3ff282cf52df03f3b9a0abecf0abda99d7df641
2015-08-25 13:14:07 -07:00
Elliott Hughes e4baae6d06 am 12d762e1: am e8e272c5: Merge "EINTR is handled by adb_read/unix_read and friends."
* commit '12d762e17694c0137aa7570b4b71536e59643bb0':
  EINTR is handled by adb_read/unix_read and friends.
2015-08-25 20:02:46 +00:00
Elliott Hughes e8e272c525 Merge "EINTR is handled by adb_read/unix_read and friends." 2015-08-25 19:51:01 +00:00
Elliott Hughes 9ccf4bfbde resolved conflicts for merge of 068ee4d0 to mnc-dev-plus-aosp
Change-Id: If276934797138d13fe8c56711615b477e05ee484
2015-08-25 11:24:45 -07:00
Elliott Hughes 9bc8005e07 resolved conflicts for merge of 3ecba7f9 to mnc-dev-plus-aosp
Change-Id: I46452c03bbda9604f2af2e1edce5d48c6865d436
2015-08-25 11:21:58 -07:00
Elliott Hughes 478bca2e72 resolved conflicts for merge of ba8fc829 to mnc-dev-plus-aosp
Change-Id: Ia4daf846df5a86ebca1b6c8d9e41f1633001836f
2015-08-25 11:16:36 -07:00
Elliott Hughes 7baecbe6a3 Fix the fs_config call.
fs_config ORs in bits to the existing mode value.

Change-Id: I23f0655f9c4c8c8dc43ed979f3b519d7c03a11f8
2015-08-25 11:09:04 -07:00
Elliott Hughes 56bf309843 Fix 32-bit build.
fs_config uses "unsigned int" instead of mode_t. Work around this.

Change-Id: I57b97d5bfc1b88089a41b4e8a50f1391b5c5113b
2015-08-25 11:01:39 -07:00
Elliott Hughes 8fcd8bc046 EINTR is handled by adb_read/unix_read and friends.
No need to clutter the code with cases that won't happen.

Change-Id: I47c5a2e6170f902d2618719f44492234a4869567
2015-08-25 10:59:45 -07:00
Elliott Hughes fdd4e58868 Clean up error handling/reporting in file_sync_service.cpp.
In an earlier code review it was pointed out that there was something
very weird about fail_errno. It didn't seem to make sense that we'd
often try to continue after reporting failure. This patch cleans up
all that and assumes that if we've reported failure to the client,
we should stop what we're doing.

Bug: http://b/23437039
Change-Id: I39c38650ed9f9d5e30adbf68a7545c9e4a6ab812
2015-08-25 08:41:05 -07:00
Elliott Hughes e3bbb2ab00 am 6c04e9a9: am 42640e52: Merge "Add missing #include <memory> for std::unique_ptr on Windows."
* commit '6c04e9a9eca2903c2496ec735c359ed57467d52f':
  Add missing #include <memory> for std::unique_ptr on Windows.
2015-08-24 22:05:17 +00:00
Elliott Hughes 42640e5224 Merge "Add missing #include <memory> for std::unique_ptr on Windows." 2015-08-24 21:50:26 +00:00
Elliott Hughes a925dba0e0 Add missing #include <memory> for std::unique_ptr on Windows.
Change-Id: Ic02f53003a20a646cbbf2aa08e0e10be9bd8b97f
2015-08-24 14:49:43 -07:00
Elliott Hughes 201eaa683a am 5c027334: am 93b9e865: Merge "There are no big endian hosts, grandpa."
* commit '5c027334cce4f0106d5d271d7924eafc752bd584':
  There are no big endian hosts, grandpa.
2015-08-24 21:45:12 +00:00
Elliott Hughes f4465203b6 There are no big endian hosts, grandpa.
Change-Id: I6f64f702f919fe4af10d82c5f395a051571815ed
2015-08-24 14:27:03 -07:00
Elliott Hughes 6b5f77c9bb am c583c511: am 186f1dee: Merge "adb sync cleanup."
* commit 'c583c5112bb6634114cd9759c1cfbad61a13b397':
  adb sync cleanup.
2015-08-24 20:59:50 +00:00
Elliott Hughes 186f1dee2a Merge "adb sync cleanup." 2015-08-24 20:48:01 +00:00
Elliott Hughes aa24549190 adb sync cleanup.
We can double the speed of "adb sync" (on N9) if we increase SYNC_DATA_MAX
from 64KiB to 256KiB. This change doesn't do that, because I still haven't
managed to plumb through the information about whether we're a new adb/adbd
to file_sync_client.cpp and file_sync_service.cpp. But this is already a big
change with a lot of cleanup, so let's do the cleanup and worry about the
intended change another day...

This change does improve performance somewhat by halving the number of
lstat(2) calls made on the client side, and ensuring that most packets are
sent with a single write. This has the pleasing result of making the null
sync on an AOSP N9 go from just over 300ms to around 100ms, which means it
now seems instantaneous (https://en.wikipedia.org/wiki/Mental_chronometry).

Change-Id: If9f6d4c1f93ec752b95f71211bbbb1c513045166
2015-08-24 11:15:01 -07:00
Jack Pham 47c3ce56ed adbd: enable USB SuperSpeed (again)
The descriptors to enable USB 3.0 SuperSpeed support had previously
been added in commit d6ee9f26a5
but were removed when the v1/v2 descriptor handling was refactored
in commits ab3446dd34 and again in
c49f51c451. Now that the dust has
settled, add back the SS descriptors to re-enable USB 3.0.

Bug: 23385314
Change-Id: I8de7c7e50d9216a7492ce7863e3aaf92ff805eff
(cherry picked from commit a190c800bf)
2015-08-24 18:03:03 +00:00
Badhri Jagan Sridharan ff490354f4 am 46f24955: am e3c02883: Merge "adbd: enable USB SuperSpeed (again)"
* commit '46f24955c8c30992c8b885fe2c4531777223315d':
  adbd: enable USB SuperSpeed (again)
2015-08-24 17:45:38 +00:00
Badhri Jagan Sridharan e3c028836f Merge "adbd: enable USB SuperSpeed (again)" 2015-08-24 17:33:20 +00:00
Siva Velusamy ef39b2613c am 5b476736: am 9498fc68: Merge "Use glog for logging in the OSX USB layer"
* commit '5b476736da368ea679a9da8eb861c74451e4c689':
  Use glog for logging in the OSX USB layer
2015-08-24 15:47:57 +00:00
Siva Velusamy 9498fc68ec Merge "Use glog for logging in the OSX USB layer" 2015-08-24 15:35:51 +00:00
Siva Velusamy 743883b570 Use glog for logging in the OSX USB layer
Change-Id: I8a3a4dfc768fdd335f03dc582c85b410c808aeb7
2015-08-24 08:22:15 -07:00
Tom Cherry 60eb73ed6a am 54b22ca2: am ff5be396: Merge changes from topic \'init-rc-breakup\'
* commit '54b22ca2488e4901265c99a42b5c5e0725a99199':
  init: Queue Triggers instead of Actions
  bundle init.rc contents with its service
2015-08-21 18:20:22 +00:00
Tom Cherry 20391b1de5 bundle init.rc contents with its service
Bug: 23186545
Change-Id: I52616b8ab1165fdef716f9b8f958665f2308c12e
2015-08-21 10:14:43 -07:00
Elliott Hughes 22b510adc5 am 2b0deb91: am a169f3b4: Merge "adb: win32: fix unittest exit code parsing"
* commit '2b0deb91c3dca2b7b2a5ef0445fed73db63a922d':
  adb: win32: fix unittest exit code parsing
2015-08-19 03:50:09 +00:00
Spencer Low b7e79af048 adb: win32: fix unittest exit code parsing
adb on Windows uses \r\n line-endings, so take that into account when
parsing output for the exit code.

Change-Id: I6a3d7c5ca455b0f0f7dae174866857e0aeee9926
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-16 16:38:47 -07:00
David Pursell f3f5bce204 am 6a701bd9: am b53b521e: Merge "Add `adb features`."
* commit '6a701bd94b067c2ab873964f63c3d954bc59610f':
  Add `adb features`.
2015-08-14 16:13:13 +00:00
David Pursell f53c7af156 am be1f5732: am f4bda753: Merge "Add feature list to connection banner."
* commit 'be1f57325f6fe1702b0d18fcdb21efe4731a191d':
  Add feature list to connection banner.
2015-08-14 16:13:11 +00:00
Dan Albert 90d4b739ab Add `adb features`.
Shows the features supported by the active adb server.

Change-Id: I4a58a2ca082823c43f7a49e2c62ff80df6426756
2015-08-14 08:25:23 -07:00
Dan Albert 1792c23cb8 Add feature list to connection banner.
This allows us to test for features explicitly rather than relying on
the protocol version number, allowing us to fall back gracefully if a
feature is not supported.

This will be needed for the upcoming shell upgrades for stdout/stderr
separation and exit code reporting.

Change-Id: Ibb1d8ad2611f7209901ee76d51346b453e9c5873
2015-08-14 08:24:37 -07:00
Elliott Hughes 2733c14232 am 2416b832: am 15c6de75: Merge "Start iterating USB pipe endpoints from 1."
* commit '2416b8320cdce59ae267d60d89b0ef96de6a9d95':
  Start iterating USB pipe endpoints from 1.
2015-08-14 03:21:47 +00:00
Elliott Hughes 2d4f852da4 Start iterating USB pipe endpoints from 1.
Bug: http://b/22829602
Change-Id: I5051880730ba8fadae5d78f1d19b5d527610d4a5
2015-08-13 16:00:12 -07:00
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
Elliott Hughes 6b940e1349 Merge "adb: win32: define UNICODE/_UNICODE, Unicode error messages, misc" 2015-08-03 21:16:26 +00:00
Elliott Hughes 6355f2c140 Merge "adb: win32: call SystemErrorCodeToString() from more places" 2015-08-03 21:04:01 +00:00
Elliott Hughes 3841a9f7cb Leave the evidence lying around if an adb test fails.
Not seeing the full output from the failed adb command is probably
the biggest issue when debugging a test failure, but this doesn't
help either.

Change-Id: Ic42cbced8be252185a799b27c210a744188a4201
2015-08-03 13:58:49 -07:00
Elliott Hughes 8f13dc4226 am 6eb9aa62: am 6bf93400: Merge "adb: fix mkdirs / adb pull with relative paths, fix win32 issues"
* commit '6eb9aa62d3b112f004d39906d6994f37eabd95a3':
  adb: fix mkdirs / adb pull with relative paths, fix win32 issues
2015-08-03 20:42:03 +00:00
Spencer Low 22191c30a6 adb: fix mkdirs / adb pull with relative paths, fix win32 issues
Relative paths were being prefixed with OS_PATH_SEPARATOR on unix and
win32 causing adb to incorrectly try to make directories at the root.
Plus, absolute paths didn't work on win32 (C: got prefixed into \C:).

This fix is to use dirname (available on win32 via mingw's crt) to do
the messy parsing.

I added a test for the relative path case.

Change-Id: Ibb0a4a8ec7756351d252a4d267122ab18e182858
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-03 13:24:18 -07:00
Elliott Hughes bc3c21b93f am c3766916: am 8c61e029: Merge "adb_test/libbase_test: win32: get some tests working"
* commit 'c376691617623c26fe7eb14184f874214e2d2173':
  adb_test/libbase_test: win32: get some tests working
2015-08-03 20:01:10 +00:00
Spencer Low cf168a82e9 adb_test/libbase_test: win32: get some tests working
adb_test:

* Fix adb_utils directory_exists test for Windows. The test actually
fails because directory_exists() is not aware of junctions or symlinks,
but I'm not really sure if that is a bad thing (since these are rare on
Windows to begin with).

* Fix crash during transport tests due to mutex not being initialized.

* io tests fail for various reasons (see adb_io_test.cpp for more info).

libbase_test:

* Get it building on Win32 by implementing mkstemp() and mkdtemp().

* Run StringPrintf %z test on Windows because it passes because we build
with __USE_MINGW_ANSI_STDIO which implements %z.

* I didn't fixup the logging tests: some logging tests fail because when
abort() is called on Windows, by default it pops up UI asking whether a
crash dump should be sent to Microsoft. To some degree this makes sense,
as I think LOG(FATAL) does crash dumping in Chromium. This should be
revisited in the future.

Change-Id: Iaa2433e5294ff162e0b2aa9fe6e4ec09a6893f7a
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-03 12:44:43 -07:00
Elliott Hughes 3f0a014281 am d2984900: am 11ca81fc: Merge "Remove adb\'s unused get_my_path for Windows."
* commit 'd29849007a37daf45e20e6d0f9f3232c2ad4fc30':
  Remove adb's unused get_my_path for Windows.
2015-08-03 15:45:55 +00:00
Spencer Low 8df9032176 adb: win32: call SystemErrorCodeToString() from more places
Improve some error messages, or trace output.

Change-Id: Ib09fac33a296f090d37f125cad7556fc5b5e928e
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-02 18:50:17 -07:00
Spencer Low e347c1dd47 adb: win32: define UNICODE/_UNICODE, Unicode error messages, misc
Define the UNICODE and _UNICODE preprocessor symbols to make passing
char* to Ansi/Unicode-agnostic Windows and C Runtime APIs break the
build. The solution is to call wide Windows and C Runtime APIs and use
widen(utf8).c_str(). Most code was already calling wide APIs. Defining
these symbols makes a call to CreateEvent() (which previously mapped to
CreateEventA()) turn into a call to CreateEventW().

Make SystemErrorCodeToString() use Unicode.

Add various comments.

Change-Id: I9b212412348a29826718e897a486489e1f142d16
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-02 18:13:54 -07:00
Spencer Low a5b06b0ff8 adb: win32: fix USB device hang when resuming from sleep/hibernation
After resuming Windows from sleep or hibernation, USB connections are not
automatically disconnected. Writing to the USB connections does not return any
errors, but read never returns. My theory is that the device saw the host
sleep/hibernation as a disconnect, so the device is waiting for re-auth from the
host as if the host was just connected.

To solve this, detect resume from sleep/hibernation, disconnect all USB
connections and let the device poll thread re-detect the USB devices in 1 sec.

This is done by using a hidden window that receives power notifications. The
hidden window code is based on Chromium's similar code (platform-tools already
includes the Chromium Authors license).

This depends on a change to AdbWinUsbApi.dll that makes AdbCloseHandle(endpoint)
abort any pending IOs and wait for those IOs to be aborted.

I expect that this should solve many adb and Android Studio related bugs
regarding hangs or errors.

Also in this change:

 - Add D() logging for any errors from AdbWinApi.dll API calls.

 - Stop setting errno to Win32 error values which the caller can't really do
   anything with. Stop calling SetLastError() because the callers don't check
   GetLastError() anyway.

 - Check the return value from writing zero length packets.

 - If the full amount of data isn't written, return an error.

 - Upon any usb_read/usb_write error, kick the connection instead of only
   kicking when ERROR_INVALID_HANDLE is encountered.

 - Restructure some code from nested-if-trees to goto-fail to make it easier
   to follow.

 - Delete usb_name() since it isn't thread-safe and it isn't used.

Change-Id: Iffcf5315ad8593d0c7e93012afaabe6fae354ac1
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-01 19:19:09 -07:00
Yabin Cui 2df4804ace am 20e8b384: am c70ac57d: Merge "adb: poll for emulator connection."
* commit '20e8b384c6ad8718764e138cc9013623cad8f400':
  adb: poll for emulator connection.
2015-08-01 01:04:00 +00:00
Elliott Hughes 16d79c7318 Remove adb's unused get_my_path for Windows.
Change-Id: I3cfb4677acaf6acaf512b3cdce6c11bdb2bd0578
2015-07-31 17:54:24 -07:00
Yabin Cui c70ac57db0 Merge "adb: poll for emulator connection." 2015-08-01 00:50:39 +00:00
Elliott Hughes 66429b34d0 am b8b71186: am 367fb503: Merge "adb: win32: Unicode path names, env vars, some console support"
* commit 'b8b7118614e8d6bd9a683ecd624915519f8933a9':
  adb: win32: Unicode path names, env vars, some console support
2015-08-01 00:06:48 +00:00
Elliott Hughes 367fb50333 Merge "adb: win32: Unicode path names, env vars, some console support" 2015-07-31 23:50:52 +00:00
Elliott Hughes 5e6d1dcfac am 3d561748: am ec035950: Merge "Clean up -p handling slightly."
* commit '3d5617487c07f1fcbdf23755e0ca01559e3c5f3b':
  Clean up -p handling slightly.
2015-07-31 22:32:00 +00:00
Spencer Low c3211557b3 adb: win32: file descriptor reliability improvements
When repeatedly opening and closing a file descriptor, the sequence of
fds returned was: 100...227,100,100,100,100,100... Basically, the first
wave was constantly increasing fds, but after the entire fd table was
traversed once, the alloc algorithm would switch to returning the first
free fd. This is sub-optimal for reliability because use-after-free bugs
would be more likely to be hit because right after a close, the same fd
would be given out next.

This change makes the alloc algorithm use a persistent clock hand that
walks forward through the fd table (wrapping around if necessary),
searching for a free fd.

This change adds locking for fd closing:

 - This prevents multiple concurrent closes of the same fd.

 - There was a race between alloc and close that wasn't guaranteed to be
   correct: close would set f->clazz to NULL last, but without any
   preceding memory barrier/fence, then the alloc thread would check for
   NULL. It probably worked out ok in practice, but it is probably best
   to fix this up with a lock (as in this change) or a memory barrier/fence
   (but this code isn't about performance, so why go with a complicated
   barrier/fence?)

Also in this change:

 - Use errno = EMFILE for the out of fds case.

 - Clear FH->name

Change-Id: Ic11d2a1a9d53996edfc1ca13566a2f46de4a4316
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-31 15:13:52 -07:00
Yabin Cui 0e2c194659 adb: poll for emulator connection.
Bug: 19974213
Change-Id: I336f3ad6f428277c54479e5b8c45d5343c64f472
2015-07-31 14:25:19 -07:00
Spencer Low cf4ff64f2d adb: win32: Unicode path names, env vars, some console support
Initial support for Unicode file/dir names. Unicode paths can be passed
on the command line, directory enumeration can enumerate Unicode paths,
Unicode paths are used for file access, and Unicode paths can be output
on the console correctly.

Also Unicode environment variable access.

Initial support for Unicode output from adb shell (which uses
adb_fwrite()). This is partial because the corner case of an
adb_fwrite() call with an incomplete UTF-8 multi-byte sequence does not
output correctly, but this should be uncommon, is better than what we
had before (*always* incorrect UTF-8 multi-byte sequences) and can be
fixed in the future.

Calls to Windows APIs with char strings were changed to pass wchar_t
strings to the FooW() variants.

For more details, see the giant comment in sysdeps_win32.cpp.

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

Change-Id: I7ebf6713bb635638b986ccee97b354428837c9c5
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-31 13:30:41 -07:00
Elliott Hughes 048b27c066 Clean up -p handling slightly.
Change-Id: I8a5cd4a7adb0dde9d09e0cbb620874b1bca35e43
2015-07-31 13:18:22 -07:00
Elliott Hughes c0d738f331 am 6dca1987: am cf4dba5a: Merge "adb: win32: initial IPv6 support and improved Winsock error reporting"
* commit '6dca19875325a2ed25f9b55d736a9f6d17afeaad':
  adb: win32: initial IPv6 support and improved Winsock error reporting
2015-07-31 18:26:20 +00:00
Elliott Hughes cf4dba5ab3 Merge "adb: win32: initial IPv6 support and improved Winsock error reporting" 2015-07-31 18:11:45 +00:00
Yabin Cui 739349cd13 am a6fda917: am dc1fb361: Merge "Make clear of the data length sent by write_packet."
* commit 'a6fda917252ab9e47d89e181adbc22bccba1ca6c':
  Make clear of the data length sent by write_packet.
2015-07-31 17:07:00 +00:00
Spencer Low 5200c6670f adb: win32: initial IPv6 support and improved Winsock error reporting
Call getaddrinfo() for connecting to IPv6 destinations.

Winsock APIs do not set errno. WSAGetLastError() returns Winsock errors
that are more numerous than BSD sockets, so it really doesn't make sense
to map those to BSD socket errors. Plus, even if we did that, the
Windows C Runtime (that mingw binaries use) has a strerror() that does
not recognize BSD socket error codes.

The solution is to wrap the various libcutils socket_* APIs with
sysdeps.h network_* APIs. For POSIX, the network_* APIs just call
strerror(). For Windows, they call SystemErrorCodeToString() (adapted
from Chromium).

Also in this change:

 - Various other code was modified to return errors in a std::string*
   argument, to be able to surface the error string to the end-user.

 - Improved error checking and use of D() to log Winsock errors for
   improved debuggability.

 - For sysdeps_win32.cpp, added unique_fh class that works like
   std::unique_ptr, for calling _fh_close().

 - Fix win32 adb_socketpair() setting of errno in error case.

 - Improve _socket_set_errno() D() logging to reduce confusion. Map
   a few extra error codes.

 - Move adb_shutdown() lower in sysdeps_win32.cpp so it can call
   _socket_set_errno().

 - Move network_connect() from adb_utils.cpp to sysdeps.h.

 - Merge socket_loopback_server() and socket_inaddr_any_server() into
   _network_server() since most of the code was identical.

Change-Id: I945f36870f320578b3a11ba093852ba6f7b93400
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-30 23:07:55 -07:00
Elliott Hughes e0b43a1785 resolved conflicts for merge of 4e90b0ae to mnc-dev-plus-aosp
Change-Id: Iff0f469f09a0ad442db5b593345eaf52c3ca8104
2015-07-30 20:07:12 -07:00
Yabin Cui 6264129434 Make clear of the data length sent by write_packet.
Change-Id: If51b4feaa19a710874999ad7e6131ff2e56a9f8a
2015-07-30 20:01:10 -07:00
Elliott Hughes 5c74270f95 More adb cleanup.
This removes adb_dirstart and adb_dirstop. It also fixes a couple of memory
leaks by switching to std::string. This also fixes the bug in the previous
change --- mkdirs is given input like "/system/bin/sh" and only expected to
create "/system/bin". In a later change, we should remove mkdirs and only
expose the intended "unlink && mkdirs && create" functionality.

Change-Id: I30289dc1b3dff575cc1b158d993652178f587552
2015-07-30 17:46:58 -07:00
Elliott Hughes d2117974e4 resolved conflicts for merge of 486645ee to mnc-dev-plus-aosp
Change-Id: I027a4de6e4ebae3bee6b7d2e56bd39c284b8a062
2015-07-30 16:33:50 -07:00
Alex Vallée 47d67c96ec Write mkdirs in more idiomatic C++ style.
~ Rewrote mkdirs to be in C++ style.
~ Replaced adb_dir{start,stop} with std::string params and (r)find.
+ Added test for mkdirs.

Also make base/test_utils.h public and support temporary directories
as well as files.

Change-Id: I6fcbdc5e0099f3359d3aac6b00c436f250ca1329
2015-07-30 15:08:53 -07:00
Dan Albert e12db0b201 am bec459a2: am 480bea33: Merge "Add top level sanitize options for ADB."
* commit 'bec459a277a0e391f5d36280bbf37eb6d84562fe':
  Add top level sanitize options for ADB.
2015-07-30 19:02:16 +00:00
Dan Albert 480bea3372 Merge "Add top level sanitize options for ADB." 2015-07-30 18:44:37 +00:00
Dan Albert 9113b47eac Add top level sanitize options for ADB.
Host and target are split here because the target can really only use
ubsan (most sanitizers don't support static executables).

Change-Id: I8a5a5adeeef5c27aaaa3d8145b1570760b764ce3
2015-07-30 10:25:32 -07:00
Dan Albert 6036a4ff9a am cc552ea3: am 3b5b1328: Merge "adb/test_device.py fixes for win32 and no use of ANDROID_SERIAL"
* commit 'cc552ea335497ecd95db3eae136d10ab3026d171':
  adb/test_device.py fixes for win32 and no use of ANDROID_SERIAL
2015-07-30 17:21:06 +00:00
Dan Albert 3b5b132817 Merge "adb/test_device.py fixes for win32 and no use of ANDROID_SERIAL" 2015-07-30 17:04:52 +00:00
Elliott Hughes c6dbc85845 am 42dbc4b1: am 44443bea: Merge "Use _WIN32 rather than HAVE_WINSOCK."
* commit '42dbc4b1859fe4de16b19e9b74324b345c5fcb9d':
  Use _WIN32 rather than HAVE_WINSOCK.
2015-07-30 15:17:07 +00:00
Elliott Hughes 44443bead6 Merge "Use _WIN32 rather than HAVE_WINSOCK." 2015-07-30 14:49:56 +00:00
Spencer Low 3e7feda3c5 adb/test_device.py fixes for win32 and no use of ANDROID_SERIAL
If ANDROID_SERIAL was not set, test_device.py was failing.

Use posixpath.join instead of os.path.join for make_random_device_files.

Change-Id: I24bfa43ba2a89a9a768f505fc0bba9d873082b2f
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-30 01:19:52 -07:00
Yasuhiro Matsuda eeea3fc1be am 1a1f9beb: am dcf89091: Merge "Add a script to record Android boot time."
* commit '1a1f9beb1dbd0da0f305ff44816661cc404ba877':
  Add a script to record Android boot time.
2015-07-30 05:47:39 +00:00
Yasuhiro Matsuda dcf890914c Merge "Add a script to record Android boot time." 2015-07-30 05:21:41 +00:00
Yasuhiro Matsuda ab3798399d Add a script to record Android boot time.
perfboot.py repeats the record of each event log during Android
boot specified times. By default, interval between measurements
is adjusted in such a way that CPUs are cooled down sufficiently
to avoid boot time slowdown caused by CPU thermal throttling.
This script also works around the issue of dropbox slowing down
boot time on userdebug build (http://b/20890386) by limiting
the number of files to be created by dropbox.
The result is output in a tab-separated value format.

BUG: 22207911
Change-Id: I0ddbac5d1c941efda87bc6db6388d8194d4bb3dd
2015-07-30 14:16:15 +09:00
Elliott Hughes 2b72d68eb8 am e0541c7d: am a6597598: Merge "fix adb {forward,reverse} --no-rebind"
* commit 'e0541c7d7e329f83b23bfde4f515cefd39d65a66':
  fix adb {forward,reverse} --no-rebind
2015-07-30 01:06:27 +00:00
Elliott Hughes adbf442a51 Use _WIN32 rather than HAVE_WINSOCK.
Change-Id: I9855b6fe72e2f2f3a8360c0993a67cb988024ee4
2015-07-29 17:45:24 -07:00
Spencer Low a6b340af12 fix adb {forward,reverse} --no-rebind
adb forward --no-rebind (and the matching reverse command) seem to have
been broken by 424af02f36. I fixed-up the
string parsing and also fixed the error message not to include
strerror(errno) since that does not apply because it is an
application-level error that doesn't have anything to do with the
OS/libc.

Change-Id: Iba7286283bfcf1782076355edcd9c355c0a0edfd
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-29 17:21:21 -07:00
Dan Albert dee79f85b6 am fa3622b2: am c0e8d0fc: Merge "Fix AndroidDevice.get_prop, add tests."
* commit 'fa3622b22481787202808101a772ac2270cf96cd':
  Fix AndroidDevice.get_prop, add tests.
2015-07-29 00:17:19 +00:00
Dan Albert c0e8d0fc50 Merge "Fix AndroidDevice.get_prop, add tests." 2015-07-28 23:46:10 +00:00
Dan Albert e2b4a5fee0 Fix AndroidDevice.get_prop, add tests.
Had messed this up while refactoring before I submitted and neglected
to add a test. Thanks to mazda@ for catching this.

Also disabled the root/unroot tests for user builds.

Change-Id: Icb819a820a2afa227d548d678ae471d5195f0b96
2015-07-28 16:42:58 -07:00
Elliott Hughes 24419f3c2e am ce2047a9: am 1a706865: Merge "Fix const-ness of strrchr callers."
* commit 'ce2047a947eaf3c02e39c22a7b461e8a0acd87f2':
  Fix const-ness of strrchr callers.
2015-07-28 21:54:23 +00:00
Elliott Hughes 3e7048c027 Fix const-ness of strrchr callers.
This causes build failures in google3 where they use GCC. glibc only
provides const-correct overloads for string functions for GCC >= 4.4,
but clang -- which is what we use -- pretends to be GCC 4.2.

Change-Id: I2a054823ea6201ebcea46d5e77b80a975eefc622
2015-07-28 08:07:21 -07:00
Dan Albert 0566ab6fed am 05432f07: am 20cf8702: Merge "Create adb Python package."
* commit '05432f07eb34ff4f3956fc3fdc9fc713bf6ced9b':
  Create adb Python package.
2015-07-28 00:17:13 +00:00
Dan Albert 8e1fdd7806 Create adb Python package.
This is mostly just the AdbWrapper that we used in our tests, but I've
cleaned up the API to be a little more Pythonic (mostly in the sense
that commands are passed as lists rather than strings that are
shlex.split() by the shell command), and implemented the workaround
error checking for adb shell.

Move the tests up a directory. Having them buried a level down has
only been annoying.

There are now two files containing Python tests. test_device.py
contains tests specifically checking the AndroidDevice API, and
test_adb.py checks the ADB client program. To run both, use

    python -m unittest discover [-v]

Change-Id: Ibd158c528d31126a5b048bd00bc93039dbc468bc
2015-07-27 15:52:15 -07:00
Elliott Hughes 5bd3c3bb54 am b8fa711f: am 3fe6de1c: Merge "Add a simple test for using non-ASCII paths with adb."
* commit 'b8fa711fa92791f67592d9b9730354b1dd9e78e5':
  Add a simple test for using non-ASCII paths with adb.
2015-07-24 23:37:20 +00:00
Elliott Hughes 3fe6de1c39 Merge "Add a simple test for using non-ASCII paths with adb." 2015-07-24 23:07:56 +00:00
Elliott Hughes 614e0a47d3 Add a simple test for using non-ASCII paths with adb.
Bug: https://code.google.com/p/android/issues/detail?id=8185
Change-Id: If28a0ff345f44b60d6651bb36afb0bf72fe55e16
2015-07-24 15:26:46 -07:00
Elliott Hughes 187afaf54f am 7d86f5e5: am 239f6ac8: Merge "Fix Win32 adb build (for the second time today)."
* commit '7d86f5e527c01d3fda84575af98888ee117159ee':
  Fix Win32 adb build (for the second time today).
2015-07-24 22:02:47 +00:00
Elliott Hughes 4f1d7b55d7 Fix Win32 adb build (for the second time today).
Change-Id: I83cb407660cd8b5ed65a80574875fe261e8a8926
2015-07-24 14:32:46 -07:00
Elliott Hughes 994e9ea787 am f077e45c: am 9dad4ec4: Merge "Clean up the locking in usb_linux.cpp."
* commit 'f077e45cc47d1bf16779f3a689bd0cd857cb7f03':
  Clean up the locking in usb_linux.cpp.
2015-07-24 21:03:08 +00:00
Elliott Hughes 4bc35f3e4c am 51d08e8e: am 2e942a47: Merge "Fix Win32 adb build."
* commit '51d08e8e7abe50051650b1ea5936006c6d6da3e9':
  Fix Win32 adb build.
2015-07-24 21:02:54 +00:00
Elliott Hughes 5937a860f3 am 1f76c1ab: am 9727a6a0: Merge "Report getaddrinfo failures correctly."
* commit '1f76c1abea3196a61f85164a078d44505d3a6b5e':
  Report getaddrinfo failures correctly.
2015-07-24 21:02:36 +00:00
Elliott Hughes 9dad4ec440 Merge "Clean up the locking in usb_linux.cpp." 2015-07-24 20:21:53 +00:00
Elliott Hughes 812f030477 Clean up the locking in usb_linux.cpp.
tsan complained that usb_bulk_write accesses usb_handle members outside
a lock. Fix that, but by moving everything over to C++11 locking.

Note that the old code was checking whether pthread_cond_timedwait returned
a negative value, which it will never do --- it will signal timeout (or
any other error) by returning a positive errno value. The rewrite does
what they appeared to intend to do (break out on timeout), rather than
what they actually did (keep trying forever).

Bug: http://b/22598587
Change-Id: Iab6869ffed4874143a7da97193d6b09e34cf2933
2015-07-24 12:35:50 -07:00
Elliott Hughes d48dbd89c8 Fix Win32 adb build.
Change-Id: I0a07379c470b7fa7f9bdef68c17ccb7bd0bd2079
2015-07-24 11:35:40 -07:00
Elliott Hughes 381cfa9a8b Report getaddrinfo failures correctly.
Also move us off the "convenience" function because you can't get useful
error reporting from it.

Change-Id: I5fcc6a6d762f5f60906980a7835f01a35045be65
2015-07-23 21:14:38 -07:00
Elliott Hughes b877d72a86 am f5defe75: am 89cc750e: Merge "Don\'t limit Windows USB reads."
* commit 'f5defe752334c557a6be2d7242c944a81f11be76':
  Don't limit Windows USB reads.
2015-07-23 18:47:51 +00:00
Elliott Hughes d704ede392 am 2fc8a91e: am 6b40d0aa: Merge "adb: win32: fix exec-in and exec-out to use binary mode"
* commit '2fc8a91eb35556b6f2bb4018b0fe2c08de55fe1c':
  adb: win32: fix exec-in and exec-out to use binary mode
2015-07-23 18:47:50 +00:00