'sf_stop_bootanim' is useful for tracking the time wasted by
showing the 'outro' part of the boot animation.
'wm_boot_animation_done' is also useful for tracking user
perceived boot time.
(cherry-pick of cbcf2778c3)
Bug: 22207911
Change-Id: I3549338a2161fa29675993c239f57809270797f8
system.img may contain the root directory as well. In that case, we
need to create some symlinks init.rc would during the build.
Change-Id: I4e7726f38c0f9cd9846c761fad1446738edb52c0
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
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>
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>
* 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.
Change-Id: Ia01f94e8258503381a1df6d3da6e40de59e57125
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
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>
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>
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>
Brillo will need to run new native system services, so reserve
a reasonable UID range to accomodate them. Having 1000 UIDs will
allow us to sub-partition this range if needed.
The range can be used by any OEM, not just Brillo, so name it
accordingly.
Bug: 22555869
Change-Id: I752428ee5025bf064a35ecbe6da50c041d87b724
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>
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>