aboutsummaryrefslogtreecommitdiff
path: root/devel/android-tools-adb
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2017-08-22 13:01:20 +0000
committerJan Beich <jbeich@FreeBSD.org>2017-08-22 13:01:20 +0000
commit212056367b28056afc7702fbe11fef0d918cf928 (patch)
tree55352d2b91e51ca0f722cf9f1707bebdec74d38c /devel/android-tools-adb
parent6136e71df8b825739644ed12aa659d6350647fee (diff)
downloadports-212056367b28056afc7702fbe11fef0d918cf928.tar.gz
ports-212056367b28056afc7702fbe11fef0d918cf928.zip
devel/android-tools-{adb,fastboot}: update to 8.0.0.r4 (oreo)
Notes
Notes: svn path=/head/; revision=448522
Diffstat (limited to 'devel/android-tools-adb')
-rw-r--r--devel/android-tools-adb/Makefile36
-rw-r--r--devel/android-tools-adb/distinfo14
-rw-r--r--devel/android-tools-adb/files/Makefile31
-rw-r--r--devel/android-tools-adb/files/extra-patch-adb_sysdeps_mutex.h9
-rw-r--r--devel/android-tools-adb/files/extra-patch-base_file.cpp11
-rw-r--r--devel/android-tools-adb/files/extra-patch-base_include_android-base_logging.h11
-rw-r--r--devel/android-tools-adb/files/get_my_path_freebsd.cpp35
-rw-r--r--devel/android-tools-adb/files/patch-adb_adb__auth__host.cpp43
-rw-r--r--devel/android-tools-adb/files/patch-adb_client_usb__libusb.cpp30
-rw-r--r--devel/android-tools-adb/files/patch-adb_commandline.h11
-rw-r--r--devel/android-tools-adb/files/patch-adb_sysdeps__test.cpp10
-rw-r--r--devel/android-tools-adb/files/patch-adb_sysdeps_posix_network.cpp10
-rw-r--r--devel/android-tools-adb/files/patch-adb_transport__usb.cpp11
-rw-r--r--devel/android-tools-adb/files/patch-adb_usb.h20
-rw-r--r--devel/android-tools-adb/files/patch-base_file.cpp47
-rw-r--r--devel/android-tools-adb/files/patch-base_file__test.cpp42
-rw-r--r--devel/android-tools-adb/files/patch-include_cutils_trace.h17
-rw-r--r--devel/android-tools-adb/files/patch-libcrypto__utils_android__pubkey.c79
-rw-r--r--devel/android-tools-adb/files/usb_libusb.cpp615
19 files changed, 390 insertions, 692 deletions
diff --git a/devel/android-tools-adb/Makefile b/devel/android-tools-adb/Makefile
index d6242d67f81a..e4a65e49ad0c 100644
--- a/devel/android-tools-adb/Makefile
+++ b/devel/android-tools-adb/Makefile
@@ -2,12 +2,14 @@
PORTNAME= android-tools-adb
DISTVERSIONPREFIX= android-
-DISTVERSION?= 7.1.2_r17
+DISTVERSION?= 8.0.0_r4
PORTREVISION?= 0
CATEGORIES= devel comms
+
.ifndef EXTRA_PATCHES
-PATCH_SITES= https://github.com/android/platform_system_core/commit/
-PATCHFILES= b4cff495a1f9.patch:-p1
+PATCH_SITES= https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
+PATCHFILES+= 46de1d7f03b7.patch:-p1
+PATCHFILES+= 5d002b8d6ae0.patch:-p1
.endif
MAINTAINER= jbeich@FreeBSD.org
@@ -23,17 +25,16 @@ GH_PROJECT= platform_system_core
.ifdef DISTVERSIONSUFFIX
GH_REVISION= ${DISTVERSIONSUFFIX:S/-g//} # snapshot
.else
-GH_REVISION= 1346a4012db4 # generated by: make update-revision
+GH_REVISION= f6a78079a81a # generated by: make update-revision
.endif
CONFLICTS_INSTALL?= ${PORTNAME}-devel-*
.ifndef EXTRA_PATCHES
-EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-adb_sysdeps_mutex.h
-EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-base_file.cpp
+EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-base_include_android-base_logging.h
.endif
-USES+= compiler:c++11-lib pkgconfig ssl uidfix
+USES+= compiler:c++14-lang pkgconfig ssl uidfix
BUILD_WRKSRC= ${WRKSRC}/adb
INSTALL_WRKSRC= ${BUILD_WRKSRC}
TEST_WRKSRC= ${BUILD_WRKSRC}
@@ -47,7 +48,8 @@ TEST_TARGET= test
PLIST_FILES= bin/adb
PORTDOCS= *
-OPTIONS_DEFINE+=BASH DOCS TEST
+OPTIONS_DEFINE+=MDNSRESPONDER BASH DOCS TEST TEST_PYTHON
+OPTIONS_DEFAULT=MDNSRESPONDER
OPTIONS_SUB= yes
.if make(makesum) # for optional distfiles
@@ -62,11 +64,19 @@ BASH_VARS= LICENSE+=MIT LICENSE_COMB=multi
DOCS_MAKE_ARGS_OFF= FILES="" FILESDIR=""
+MDNSRESPONDER_LIB_DEPENDS= libdns_sd.so:net/mDNSResponder
+MDNSRESPONDER_USES= localbase:ldflags
+MDNSRESPONDER_LDFLAGS= -ldns_sd
+MDNSRESPONDER_MAKE_ENV_OFF= MDNSEXT=_unsupported
+
TEST_BUILD_DEPENDS+= googlemock>=1.6.0:devel/googlemock \
googletest>=1.6.0:devel/googletest
TEST_ALL_TARGET= adb_test
-pre-install-TEST-on: do-test
+TEST_PYTHON_DESC= ${TEST_DESC:S/tests/python &/}
+TEST_PYTHON_GH_PROJECT= platform_development:development
+TEST_PYTHON_BUILD_DEPENDS=${PYTHON_PKGNAMEPREFIX}mock>0:devel/py-mock
+TEST_PYTHON_USES= python:2.7,build
post-patch:
# XXX Hidden by poudriere/tinderbox, see lindev(4) for FreeBSD < 11.0
@@ -75,6 +85,14 @@ post-patch:
${WRKSRC}/adb/adb_io_test.cpp; \
fi
+pre-install-TEST-on: do-test
+
+pre-install-TEST_PYTHON-on:
+# XXX python tests may leave behind running adb server
+ ${SETENV} PATH=${BUILD_WRKSRC}:${PATH} \
+ PYTHONPATH=${WRKSRC_development}/python-packages \
+ ${PYTHON_CMD} -m unittest discover -vs ${BUILD_WRKSRC}
+
post-install-BASH-on:
${MKDIR} ${STAGEDIR}${PREFIX}/${BASH_PLIST_FILES:H}
${INSTALL_DATA} ${WRKSRC_bashcomp}/android \
diff --git a/devel/android-tools-adb/distinfo b/devel/android-tools-adb/distinfo
index 2fd374a1fb99..0c0e5504e65c 100644
--- a/devel/android-tools-adb/distinfo
+++ b/devel/android-tools-adb/distinfo
@@ -1,7 +1,11 @@
-TIMESTAMP = 1495068953
-SHA256 (android-platform_system_core-android-7.1.2_r17_GH0.tar.gz) = fb8d053d846f439951c651f205c9c914531d8dace86da60474f6675a92576449
-SIZE (android-platform_system_core-android-7.1.2_r17_GH0.tar.gz) = 1596372
+TIMESTAMP = 1498603192
+SHA256 (android-platform_system_core-android-8.0.0_r4_GH0.tar.gz) = 3eb686edb1ccaa7312fb195b65c413823a6d60442d519c499c18b2d18c3094a9
+SIZE (android-platform_system_core-android-8.0.0_r4_GH0.tar.gz) = 5115403
SHA256 (mbrubeck-android-completion-c1b0656_GH0.tar.gz) = ca3311ba47a5edd56c929ac9aae57c02c2c3f1636519c5f67abb00b6e3ecd75c
SIZE (mbrubeck-android-completion-c1b0656_GH0.tar.gz) = 5967
-SHA256 (b4cff495a1f9.patch) = cfb45f82866c7b46bdb9aa62aa0f856c243c13083f37e93b07c4491ad2b7db50
-SIZE (b4cff495a1f9.patch) = 2066
+SHA256 (android-platform_development-android-8.0.0_r4_GH0.tar.gz) = b6399cc349a332ef818f5041dd39742322bcf96d54663ec8a11e38cb5271096c
+SIZE (android-platform_development-android-8.0.0_r4_GH0.tar.gz) = 93751770
+SHA256 (46de1d7f03b7.patch) = 93bf49a9a93f2b660f39041f8dbd179ea8f1170c1bebeee42f7df1dc1c393579
+SIZE (46de1d7f03b7.patch) = 12346
+SHA256 (5d002b8d6ae0.patch) = 0d105587abea3afbfd320a95be3f8532f213778a6f699150c4d4477334c9eef2
+SIZE (5d002b8d6ae0.patch) = 1385
diff --git a/devel/android-tools-adb/files/Makefile b/devel/android-tools-adb/files/Makefile
index 3a5ef4ffd42c..015102eb24b5 100644
--- a/devel/android-tools-adb/files/Makefile
+++ b/devel/android-tools-adb/files/Makefile
@@ -8,7 +8,6 @@ FILESDIR?=${DOCDIR}/${PROG}
FILES= *.[Tt][Xx][Tt]
SRCS+= adb.cpp
-SRCS+= adb_auth.cpp
SRCS+= adb_auth_host.cpp
SRCS+= adb_client.cpp
SRCS+= adb_io.cpp
@@ -24,51 +23,62 @@ SRCS+= file_sync_client.cpp
SRCS+= line_printer.cpp
SRCS+= services.cpp
SRCS+= shell_service_protocol.cpp
+SRCS+= socket_spec.cpp
SRCS+= ../adb/sockets.cpp
SRCS+= sysdeps_unix.cpp
SRCS+= transport.cpp
SRCS+= transport_local.cpp
+SRCS+= transport_mdns${MDNSEXT}.cpp
SRCS+= transport_usb.cpp
TEST_SRCS+= adb_io_test.cpp
+TEST_SRCS+= adb_listeners_test.cpp
TEST_SRCS+= adb_utils_test.cpp
TEST_SRCS+= bugreport_test.cpp
TEST_SRCS+= fdevent_test.cpp
TEST_SRCS+= shell_service_protocol_test.cpp
+TEST_SRCS+= socket_spec_test.cpp
TEST_SRCS+= socket_test.cpp
TEST_SRCS+= sysdeps_test.cpp
TEST_SRCS+= transport_test.cpp
.PATH: ${.CURDIR}/client
SRCS+= main.cpp
+SRCS+= usb_libusb.cpp
.PATH: ${.CURDIR}/sysdeps
+SRCS+= errno.cpp
TEST_SRCS+= stat_test.cpp
-.PATH: ${EXTRADIR}
-SRCS+= get_my_path_freebsd.cpp
-SRCS+= usb_libusb.cpp
+.PATH: ${.CURDIR}/sysdeps/posix
+SRCS+= network.cpp
.PATH: ${.CURDIR}/../base
SRCS+= file.cpp
SRCS+= logging.cpp
SRCS+= parsenetaddress.cpp
+SRCS+= quick_exit.cpp
SRCS+= stringprintf.cpp
SRCS+= strings.cpp
TEST_SRCS+= file_test.cpp
TEST_SRCS+= logging_test.cpp
TEST_SRCS+= parsenetaddress_test.cpp
+TEST_SRCS+= quick_exit_test.cpp
TEST_SRCS+= stringprintf_test.cpp
TEST_SRCS+= strings_test.cpp
TEST_SRCS+= test_main.cpp
TEST_SRCS+= test_utils.cpp
+.PATH: ${.CURDIR}/../libcrypto_utils
+SRCS+= android_pubkey.c
+
+.PATH: ${.CURDIR}/../libcrypto_utils/tests
+TEST_SRCS+= android_pubkey_test.cpp
+
.PATH: ${.CURDIR}/../libcutils
SRCS+= socket_inaddr_any_server_unix.c
SRCS+= socket_local_client_unix.c
SRCS+= socket_local_server_unix.c
-SRCS+= socket_loopback_client_unix.c
-SRCS+= socket_loopback_server_unix.c
SRCS+= socket_network_client_unix.c
SRCS+= ../libcutils/sockets.cpp
SRCS+= load_file.c
@@ -78,13 +88,16 @@ CPPFLAGS.sockets.cpp+= -o ${.TARGET}
# required by base/file.cpp
.PATH: ${.CURDIR}/../liblog
+SRCS+= config_read.c
SRCS+= config_write.c
SRCS+= fake_log_device.c
SRCS+= fake_writer.c
+SRCS+= local_logger.c
SRCS+= logger_lock.c
SRCS+= logger_name.c
SRCS+= logger_write.c
-CPPFLAGS.config_write.c+= -DFAKE_LOG_DEVICE=1
+SRCS+= logprint.c
+SRCS+= stderr_write.c
REVISION?= $$(${GIT} rev-parse --short=12 HEAD 2>/dev/null || echo unknown)
@@ -95,13 +108,15 @@ CPPFLAGS+= -DHAVE_SYMLINKS
CPPFLAGS+= -DHAVE_TERMIO_H
CPPFLAGS+= -DHAVE_SYS_SOCKET_H
CPPFLAGS+= -D_FILE_OFFSET_BITS=64
+CPPFLAGS+= -DFAKE_LOG_DEVICE=1
CPPFLAGS+= -I${.CURDIR}
CPPFLAGS+= -I${.CURDIR}/../include
CPPFLAGS+= -I${.CURDIR}/../base/include
+CPPFLAGS+= -I${.CURDIR}/../libcrypto_utils/include
CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}}
CPPFLAGS+= $$(${PKG_CONFIG} libcrypto --cflags 2>/dev/null)
CPPFLAGS+= $$(${PKG_CONFIG} libusb-1.0 --cflags 2>/dev/null)
-CXXFLAGS+= -std=gnu++11
+CXXFLAGS+= -std=gnu++14
.ifndef COMPILE.c
CFLAGS+= ${CPPFLAGS}
diff --git a/devel/android-tools-adb/files/extra-patch-adb_sysdeps_mutex.h b/devel/android-tools-adb/files/extra-patch-adb_sysdeps_mutex.h
deleted file mode 100644
index 792d29f7f738..000000000000
--- a/devel/android-tools-adb/files/extra-patch-adb_sysdeps_mutex.h
+++ /dev/null
@@ -1,9 +0,0 @@
---- adb/sysdeps/mutex.h.orig 2016-06-23 07:04:56 UTC
-+++ adb/sysdeps/mutex.h
-@@ -104,4 +104,6 @@
-
- }
-
-+#else
-+#include <mutex>
- #endif
diff --git a/devel/android-tools-adb/files/extra-patch-base_file.cpp b/devel/android-tools-adb/files/extra-patch-base_file.cpp
deleted file mode 100644
index 754b02594d0c..000000000000
--- a/devel/android-tools-adb/files/extra-patch-base_file.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
---- base/file.cpp.orig 2016-08-08 21:10:17 UTC
-+++ base/file.cpp
-@@ -21,6 +21,8 @@
- #include <sys/stat.h>
- #include <sys/types.h>
-
-+#include <cstdio> // BUFSIZ
-+#include <cstring> // strerror
- #include <string>
-
- #include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin.
diff --git a/devel/android-tools-adb/files/extra-patch-base_include_android-base_logging.h b/devel/android-tools-adb/files/extra-patch-base_include_android-base_logging.h
new file mode 100644
index 000000000000..4d6ff0984562
--- /dev/null
+++ b/devel/android-tools-adb/files/extra-patch-base_include_android-base_logging.h
@@ -0,0 +1,11 @@
+--- base/include/android-base/logging.h.orig 2015-09-29 18:07:07 UTC
++++ base/include/android-base/logging.h
+@@ -321,7 +321,7 @@ struct LogAbortAfterFullExpr {
+ // DCHECKs are debug variants of CHECKs only enabled in debug builds. Generally
+ // CHECK should be used unless profiling identifies a CHECK as being in
+ // performance critical code.
+-#if defined(NDEBUG)
++#if defined(NDEBUG) || !defined(__ANDROID__)
+ static constexpr bool kEnableDChecks = false;
+ #else
+ static constexpr bool kEnableDChecks = true;
diff --git a/devel/android-tools-adb/files/get_my_path_freebsd.cpp b/devel/android-tools-adb/files/get_my_path_freebsd.cpp
deleted file mode 100644
index c935adf1292a..000000000000
--- a/devel/android-tools-adb/files/get_my_path_freebsd.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2009 bsdroid project
- * Alexey Tarasov <tarasov@dodologics.com>
- *
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#include <unistd.h>
-
-void
-get_my_path(char *exe, size_t maxLen)
-{
- int mib[4] = {
- CTL_KERN,
- KERN_PROC,
- KERN_PROC_PATHNAME,
- getpid()
- };
-
- sysctl(mib, 4, exe, &maxLen, NULL, 0);
-}
diff --git a/devel/android-tools-adb/files/patch-adb_adb__auth__host.cpp b/devel/android-tools-adb/files/patch-adb_adb__auth__host.cpp
new file mode 100644
index 000000000000..2fb3e5335c76
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-adb_adb__auth__host.cpp
@@ -0,0 +1,43 @@
+--- adb/adb_auth_host.cpp.orig 2016-06-29 23:43:15 UTC
++++ adb/adb_auth_host.cpp
+@@ -34,7 +34,9 @@
+ #include <android-base/stringprintf.h>
+ #include <android-base/strings.h>
+ #include <crypto_utils/android_pubkey.h>
++#if defined(OPENSSL_IS_BORINGSSL)
+ #include <openssl/base64.h>
++#endif
+ #include <openssl/evp.h>
+ #include <openssl/objects.h>
+ #include <openssl/pem.h>
+@@ -70,6 +72,30 @@ static std::string get_user_info() {
+ return " " + username + "@" + hostname;
+ }
+
++#if !defined(OPENSSL_IS_BORINGSSL)
++// https://boringssl.googlesource.com/boringssl/+/6601402%5E!/
++static int EVP_EncodedLength(size_t *out_len, size_t len) {
++ if (len + 2 < len) {
++ return 0;
++ }
++ len += 2;
++ len /= 3;
++
++ if (((len << 2) >> 2) != len) {
++ return 0;
++ }
++ len <<= 2;
++
++ if (len + 1 < len) {
++ return 0;
++ }
++ len++;
++
++ *out_len = len;
++ return 1;
++}
++#endif
++
+ static bool write_public_keyfile(RSA* private_key, const std::string& private_key_path) {
+ uint8_t binary_key_data[ANDROID_PUBKEY_ENCODED_SIZE];
+ if (!android_pubkey_encode(private_key, binary_key_data, sizeof(binary_key_data))) {
diff --git a/devel/android-tools-adb/files/patch-adb_client_usb__libusb.cpp b/devel/android-tools-adb/files/patch-adb_client_usb__libusb.cpp
new file mode 100644
index 000000000000..438930e32b32
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-adb_client_usb__libusb.cpp
@@ -0,0 +1,30 @@
+--- adb/client/usb_libusb.cpp.orig 2017-06-20 10:50:27 UTC
++++ adb/client/usb_libusb.cpp
+@@ -22,13 +22,14 @@
+
+ #include <atomic>
+ #include <chrono>
++#include <condition_variable>
+ #include <memory>
+ #include <mutex>
+ #include <string>
+ #include <thread>
+ #include <unordered_map>
+
+-#include <libusb/libusb.h>
++#include <libusb.h>
+
+ #include <android-base/file.h>
+ #include <android-base/logging.h>
+@@ -89,7 +89,11 @@ struct transfer_info {
+ };
+
+ namespace libusb {
++#if defined(__linux__) || defined(__APPLE__)
+ struct usb_handle : public ::usb_handle {
++#else
++struct usb_handle {
++#endif
+ usb_handle(const std::string& device_address, const std::string& serial,
+ unique_device_handle&& device_handle, uint8_t interface, uint8_t bulk_in,
+ uint8_t bulk_out, size_t zero_mask, size_t max_packet_size)
diff --git a/devel/android-tools-adb/files/patch-adb_commandline.h b/devel/android-tools-adb/files/patch-adb_commandline.h
new file mode 100644
index 000000000000..ac22e1d11e37
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-adb_commandline.h
@@ -0,0 +1,11 @@
+--- adb/commandline.h.orig 2016-09-28 18:07:09 UTC
++++ adb/commandline.h
+@@ -17,6 +17,8 @@
+ #ifndef COMMANDLINE_H
+ #define COMMANDLINE_H
+
++#include <stdio.h> // fwrite
++
+ #include "adb.h"
+
+ // Callback used to handle the standard streams (stdout and stderr) sent by the
diff --git a/devel/android-tools-adb/files/patch-adb_sysdeps__test.cpp b/devel/android-tools-adb/files/patch-adb_sysdeps__test.cpp
new file mode 100644
index 000000000000..5b8020400d9a
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-adb_sysdeps__test.cpp
@@ -0,0 +1,10 @@
+--- adb/sysdeps_test.cpp.orig 2017-06-27 22:39:52 UTC
++++ adb/sysdeps_test.cpp
+@@ -19,6 +19,7 @@
+
+ #include <atomic>
+ #include <condition_variable>
++#include <mutex>
+ #include <thread>
+
+ #include "adb_io.h"
diff --git a/devel/android-tools-adb/files/patch-adb_sysdeps_posix_network.cpp b/devel/android-tools-adb/files/patch-adb_sysdeps_posix_network.cpp
new file mode 100644
index 000000000000..a99ca23f25d5
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-adb_sysdeps_posix_network.cpp
@@ -0,0 +1,10 @@
+--- adb/sysdeps/posix/network.cpp.orig 2017-06-20 10:50:27 UTC
++++ adb/sysdeps/posix/network.cpp
+@@ -17,6 +17,7 @@
+ #include "sysdeps/network.h"
+
+ #include <errno.h>
++#include <string.h> // strerror
+ #include <netinet/in.h>
+ #include <sys/socket.h>
+
diff --git a/devel/android-tools-adb/files/patch-adb_transport__usb.cpp b/devel/android-tools-adb/files/patch-adb_transport__usb.cpp
new file mode 100644
index 000000000000..cb5cb68a926f
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-adb_transport__usb.cpp
@@ -0,0 +1,11 @@
+--- adb/transport_usb.cpp.orig 2017-06-20 10:50:27 UTC
++++ adb/transport_usb.cpp
+@@ -191,6 +191,8 @@ int is_adb_interface(int usb_class, int usb_subclass,
+ bool should_use_libusb() {
+ #if defined(_WIN32) || !ADB_HOST
+ return false;
++#elif !defined(__linux__) && !defined(__APPLE__)
++ return true;
+ #else
+ static bool disable = getenv("ADB_LIBUSB") && strcmp(getenv("ADB_LIBUSB"), "0") == 0;
+ return !disable;
diff --git a/devel/android-tools-adb/files/patch-adb_usb.h b/devel/android-tools-adb/files/patch-adb_usb.h
new file mode 100644
index 000000000000..c38b16752cc2
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-adb_usb.h
@@ -0,0 +1,20 @@
+--- adb/usb.h.orig 2017-06-20 10:50:27 UTC
++++ adb/usb.h
+@@ -43,6 +43,7 @@ namespace libusb {
+ ADB_USB_INTERFACE(libusb::usb_handle*);
+ }
+
++#if defined(__linux__) || defined(__APPLE__)
+ namespace native {
+ struct usb_handle;
+ ADB_USB_INTERFACE(native::usb_handle*);
+@@ -53,6 +54,9 @@ struct usb_handle {
+ };
+
+ ADB_USB_INTERFACE(::usb_handle*);
++#else
++using namespace libusb;
++#endif
+
+ #endif // linux host || darwin
+
diff --git a/devel/android-tools-adb/files/patch-base_file.cpp b/devel/android-tools-adb/files/patch-base_file.cpp
new file mode 100644
index 000000000000..ca20501150a6
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-base_file.cpp
@@ -0,0 +1,47 @@
+--- base/file.cpp.orig 2017-06-20 10:50:27 UTC
++++ base/file.cpp
+@@ -19,6 +19,10 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <libgen.h>
++#include <limits.h> // PATH_MAX
++#include <stdio.h> // BUFSIZ
++#include <stdlib.h> // realpath
++#include <string.h> // strerror
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <unistd.h>
+@@ -36,6 +39,9 @@
+ #if defined(__APPLE__)
+ #include <mach-o/dyld.h>
+ #endif
++#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
++#include <sys/sysctl.h>
++#endif
+ #if defined(_WIN32)
+ #include <windows.h>
+ #define O_CLOEXEC O_NOINHERIT
+@@ -251,6 +258,23 @@ std::string GetExecutablePath() {
+ if (result == 0 || result == sizeof(path) - 1) return "";
+ path[PATH_MAX - 1] = 0;
+ return path;
++#elif defined(KERN_PROC_PATHNAME)
++ char path[PATH_MAX + 1];
++ size_t path_len = sizeof(path);
++ int mib[] = {
++ CTL_KERN,
++#if defined(__NetBSD__)
++ KERN_PROC_ARGS,
++ -1,
++ KERN_PROC_PATHNAME,
++#else
++ KERN_PROC,
++ KERN_PROC_PATHNAME,
++ -1,
++#endif
++ };
++ int rc = sysctl(mib, arraysize(mib), path, &path_len, NULL, 0);
++ return rc ? "" : path;
+ #else
+ #error unknown OS
+ #endif
diff --git a/devel/android-tools-adb/files/patch-base_file__test.cpp b/devel/android-tools-adb/files/patch-base_file__test.cpp
new file mode 100644
index 000000000000..91950644efd3
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-base_file__test.cpp
@@ -0,0 +1,42 @@
+--- base/file_test.cpp.orig 2017-06-20 10:50:27 UTC
++++ base/file_test.cpp
+@@ -52,12 +52,20 @@ TEST(file, ReadFileToString_WriteStringToFile_symlink)
+ ASSERT_EQ(0, unlink(link.path));
+ ASSERT_EQ(0, symlink(target.path, link.path));
+ ASSERT_FALSE(android::base::WriteStringToFile("foo", link.path, false));
++#ifdef __linux__
+ ASSERT_EQ(ELOOP, errno);
++#else
++ ASSERT_EQ(EMLINK, errno);
++#endif
+ ASSERT_TRUE(android::base::WriteStringToFile("foo", link.path, true));
+
+ std::string s;
+ ASSERT_FALSE(android::base::ReadFileToString(link.path, &s));
++#ifdef __linux__
+ ASSERT_EQ(ELOOP, errno);
++#else
++ ASSERT_EQ(EMLINK, errno);
++#endif
+ ASSERT_TRUE(android::base::ReadFileToString(link.path, &s, true));
+ ASSERT_EQ("foo", s);
+ }
+@@ -131,6 +139,7 @@ TEST(file, RemoveFileIfExist) {
+
+ TEST(file, Readlink) {
+ #if !defined(_WIN32)
++#ifdef __linux__
+ // Linux doesn't allow empty symbolic links.
+ std::string min("x");
+ // ext2 and ext4 both have PAGE_SIZE limits.
+@@ -139,6 +148,10 @@ TEST(file, Readlink) {
+ // in current kernels (and marlin/sailfish where we're seeing this
+ // failure are still on 3.18, far from current). http://b/33306057.
+ std::string max(static_cast<size_t>(4096 - 2 - 1 - 1), 'x');
++#else
++ std::string min("");
++ std::string max(static_cast<size_t>(1024 - 1), 'x');
++#endif
+
+ TemporaryDir td;
+ std::string min_path{std::string(td.path) + "/" + "min"};
diff --git a/devel/android-tools-adb/files/patch-include_cutils_trace.h b/devel/android-tools-adb/files/patch-include_cutils_trace.h
new file mode 100644
index 000000000000..df785a1e3bd2
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-include_cutils_trace.h
@@ -0,0 +1,17 @@
+--- include/cutils/trace.h.orig 2017-06-20 10:50:27 UTC
++++ include/cutils/trace.h
+@@ -18,8 +18,14 @@
+ #define _LIBS_CUTILS_TRACE_H
+
+ #include <inttypes.h>
++#ifdef __cplusplus
++#include <atomic>
++using std::atomic_bool;
++using std::memory_order_acquire;
++#else
+ #include <stdatomic.h>
+ #include <stdbool.h>
++#endif
+ #include <stdint.h>
+ #include <stdio.h>
+ #include <sys/cdefs.h>
diff --git a/devel/android-tools-adb/files/patch-libcrypto__utils_android__pubkey.c b/devel/android-tools-adb/files/patch-libcrypto__utils_android__pubkey.c
new file mode 100644
index 000000000000..0f4172f4b9aa
--- /dev/null
+++ b/devel/android-tools-adb/files/patch-libcrypto__utils_android__pubkey.c
@@ -0,0 +1,79 @@
+--- libcrypto_utils/android_pubkey.c.orig 2016-04-16 00:01:39 UTC
++++ libcrypto_utils/android_pubkey.c
+@@ -110,6 +110,76 @@ cleanup:
+ return ret;
+ }
+
++#if !defined(OPENSSL_IS_BORINGSSL)
++// https://android.googlesource.com/platform/external/chromium_org/third_party/boringssl/src/+/6887edb%5E!/
++
++/* constant_time_select_ulong returns |x| if |v| is 1 and |y| if |v| is 0. Its
++ * behavior is undefined if |v| takes any other value. */
++static BN_ULONG constant_time_select_ulong(int v, BN_ULONG x, BN_ULONG y) {
++ BN_ULONG mask = v;
++ mask--;
++
++ return (~mask & x) | (mask & y);
++}
++
++/* constant_time_le_size_t returns 1 if |x| <= |y| and 0 otherwise. |x| and |y|
++ * must not have their MSBs set. */
++static int constant_time_le_size_t(size_t x, size_t y) {
++ return ((x - y - 1) >> (sizeof(size_t) * 8 - 1)) & 1;
++}
++
++/* read_word_padded returns the |i|'th word of |in|, if it is not out of
++ * bounds. Otherwise, it returns 0. It does so without branches on the size of
++ * |in|, however it necessarily does not have the same memory access pattern. If
++ * the access would be out of bounds, it reads the last word of |in|. |in| must
++ * not be zero. */
++static BN_ULONG read_word_padded(const BIGNUM *in, size_t i) {
++ /* Read |in->d[i]| if valid. Otherwise, read the last word. */
++ BN_ULONG l = in->d[constant_time_select_ulong(
++ constant_time_le_size_t(in->dmax, i), in->dmax - 1, i)];
++
++ /* Clamp to zero if above |d->top|. */
++ return constant_time_select_ulong(constant_time_le_size_t(in->top, i), 0, l);
++}
++
++static int BN_bn2bin_padded(uint8_t *out, size_t len, const BIGNUM *in) {
++ size_t i;
++ BN_ULONG l;
++
++ /* Special case for |in| = 0. Just branch as the probability is negligible. */
++ if (BN_is_zero(in)) {
++ memset(out, 0, len);
++ return 1;
++ }
++
++ /* Check if the integer is too big. This case can exit early in non-constant
++ * time. */
++ if ((size_t)in->top > (len + (BN_BYTES - 1)) / BN_BYTES) {
++ return 0;
++ }
++ if ((len % BN_BYTES) != 0) {
++ l = read_word_padded(in, len / BN_BYTES);
++ if (l >> (8 * (len % BN_BYTES)) != 0) {
++ return 0;
++ }
++ }
++
++ /* Write the bytes out one by one. Serialization is done without branching on
++ * the bits of |in| or on |in->top|, but if the routine would otherwise read
++ * out of bounds, the memory access pattern can't be fixed. However, for an
++ * RSA key of size a multiple of the word size, the probability of BN_BYTES
++ * leading zero octets is low.
++ *
++ * See Falko Stenzke, "Manger's Attack revisited", ICICS 2010. */
++ i = len;
++ while (i--) {
++ l = read_word_padded(in, i / BN_BYTES);
++ *(out++) = (uint8_t)(l >> (8 * (i % BN_BYTES))) & 0xff;
++ }
++ return 1;
++}
++#endif
++
+ static bool android_pubkey_encode_bignum(const BIGNUM* num, uint8_t* buffer) {
+ if (!BN_bn2bin_padded(buffer, ANDROID_PUBKEY_MODULUS_SIZE, num)) {
+ return false;
diff --git a/devel/android-tools-adb/files/usb_libusb.cpp b/devel/android-tools-adb/files/usb_libusb.cpp
deleted file mode 100644
index abc5522cf2ea..000000000000
--- a/devel/android-tools-adb/files/usb_libusb.cpp
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- * Copyright (C) 2009 bsdroid project
- * Alexey Tarasov <tarasov@dodologics.com>
- *
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define TRACE_TAG USB
-
-#include "sysdeps.h"
-
-#include <libusb.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "adb.h"
-#include "transport.h"
-
-ADB_MUTEX_DEFINE( usb_lock );
-static libusb_context *ctx = NULL;
-
-struct usb_handle
-{
- usb_handle *prev;
- usb_handle *next;
-
- libusb_device *dev;
- libusb_device_handle *devh;
- int interface;
- uint8_t dev_bus;
- uint8_t dev_addr;
-
- int zero_mask;
- unsigned char end_point_address[2];
- char serial[128];
-
- adb_cond_t notify;
- adb_mutex_t lock;
-};
-
-static usb_handle handle_list = {
- .prev = &handle_list,
- .next = &handle_list,
-};
-
-static void
-usb_cleanup()
-{
- libusb_exit(ctx);
-}
-
-static void
-report_bulk_libusb_error(int r)
-{
- switch (r) {
- case LIBUSB_ERROR_TIMEOUT:
- D("Transfer timeout");
- break;
-
- case LIBUSB_ERROR_PIPE:
- D("Control request is not supported");
- break;
-
- case LIBUSB_ERROR_OVERFLOW:
- D("Device offered more data");
- break;
-
- case LIBUSB_ERROR_NO_DEVICE :
- D("Device was disconnected");
- break;
-
- default:
- D("Error %d during transfer", r);
- break;
- };
-}
-
-static int
-usb_bulk_write(usb_handle *uh, const void *data, int len)
-{
- int r = 0;
- int transferred = 0;
-
- r = libusb_bulk_transfer(uh->devh, uh->end_point_address[1],
- (unsigned char *)data, len, &transferred, 0);
-
- if (r != 0) {
- D("usb_bulk_write(): ");
- report_bulk_libusb_error(r);
- return r;
- }
-
- return (transferred);
-}
-
-static int
-usb_bulk_read(usb_handle *uh, void *data, int len)
-{
- int r = 0;
- int transferred = 0;
-
- r = libusb_bulk_transfer(uh->devh, uh->end_point_address[0],
- (unsigned char *)data, len,
- &transferred, 0);
-
- if (r != 0) {
- D("usb_bulk_read(): ");
- report_bulk_libusb_error(r);
- return r;
- }
-
- return (transferred);
-}
-
-int
-usb_write(usb_handle *uh, const void *_data, int len)
-{
- unsigned char *data = (unsigned char*) _data;
- int n;
- int need_zero = 0;
-
- if (uh->zero_mask == 1) {
- if (!(len & uh->zero_mask)) {
- need_zero = 1;
- }
- }
-
- D("usb_write(): %p:%d -> transport %p", _data, len, uh);
-
- while (len > 0) {
- int xfer = (len > 4096) ? 4096 : len;
-
- n = usb_bulk_write(uh, data, xfer);
-
- if (n != xfer) {
- D("usb_write(): failed for transport %p (%d bytes left)", uh, len);
- return -1;
- }
-
- len -= xfer;
- data += xfer;
- }
-
- if (need_zero){
- n = usb_bulk_write(uh, _data, 0);
-
- if (n < 0) {
- D("usb_write(): failed to finish operation for transport %p", uh);
- }
- return n;
- }
-
- return 0;
-}
-
-int
-usb_read(usb_handle *uh, void *_data, int len)
-{
- unsigned char *data = (unsigned char*)_data;
- int n;
-
- D("usb_read(): %p:%d <- transport %p", _data, len, uh);
-
- while (len > 0) {
- int xfer = (len > 4096) ? 4096 : len;
-
- n = usb_bulk_read(uh, data, xfer);
-
- if (n != xfer) {
- if (n > 0) {
- data += n;
- len -= n;
- continue;
- }
-
- D("usb_read(): failed for transport %p (%d bytes left)", uh, len);
- return -1;
- }
-
- len -= xfer;
- data += xfer;
- }
-
- return 0;
-}
-
-int
-usb_close(usb_handle *h)
-{
- D("usb_close(): closing transport %p", h);
- adb_mutex_lock(&usb_lock);
-
- h->next->prev = h->prev;
- h->prev->next = h->next;
- h->prev = NULL;
- h->next = NULL;
-
- libusb_release_interface(h->devh, h->interface);
- libusb_close(h->devh);
- libusb_unref_device(h->dev);
-
- adb_mutex_unlock(&usb_lock);
-
- free(h);
-
- return (0);
-}
-
-void
-usb_kick(usb_handle *h)
-{
- D("usb_kick(): kicking transport %p", h);
-
- adb_mutex_lock(&h->lock);
- unregister_usb_transport(h);
- adb_mutex_unlock(&h->lock);
-
- h->next->prev = h->prev;
- h->prev->next = h->next;
- h->prev = NULL;
- h->next = NULL;
-
- libusb_release_interface(h->devh, h->interface);
- libusb_close(h->devh);
- libusb_unref_device(h->dev);
- free(h);
-}
-
-static int
-check_usb_interface(libusb_interface const *interface,
- libusb_device_descriptor const *desc,
- usb_handle *uh)
-{
- int e;
-
- if (interface->num_altsetting == 0) {
- D("check_usb_interface(): No interface settings");
- return -1;
- }
-
- libusb_interface_descriptor const *idesc = &interface->altsetting[0];
-
- if (idesc->bNumEndpoints != 2) {
- D("check_usb_interface(): Interface have not 2 endpoints, ignoring");
- return -1;
- }
-
- for (e = 0; e < idesc->bNumEndpoints; e++) {
- libusb_endpoint_descriptor const *edesc = &idesc->endpoint[e];
-
- if (edesc->bmAttributes != LIBUSB_TRANSFER_TYPE_BULK) {
- D("check_usb_interface(): Endpoint (%u) is not bulk (%u), ignoring",
- edesc->bmAttributes, LIBUSB_TRANSFER_TYPE_BULK);
- return -1;
- }
-
- if (edesc->bEndpointAddress & LIBUSB_ENDPOINT_IN)
- uh->end_point_address[0] = edesc->bEndpointAddress;
- else
- uh->end_point_address[1] = edesc->bEndpointAddress;
-
- /* aproto 01 needs 0 termination */
- if (idesc->bInterfaceProtocol == 0x01) {
- uh->zero_mask = edesc->wMaxPacketSize - 1;
- D("check_usb_interface(): Forced Android interface protocol v.1");
- }
- }
-
- D("check_usb_interface(): Device: %04x:%04x "
- "iclass: %x, isclass: %x, iproto: %x ep: %x/%x-> ",
- desc->idVendor, desc->idProduct, idesc->bInterfaceClass,
- idesc->bInterfaceSubClass, idesc->bInterfaceProtocol,
- uh->end_point_address[0], uh->end_point_address[1]);
-
- if (!is_adb_interface(desc->idVendor, desc->idProduct,
- idesc->bInterfaceClass, idesc->bInterfaceSubClass,
- idesc->bInterfaceProtocol))
- {
- D("not matches");
- return -1;
- }
-
- D("matches");
- return 1;
-}
-
-static int
-check_usb_interfaces(libusb_config_descriptor *config,
- libusb_device_descriptor *desc,
- usb_handle *uh)
-{
- int i;
-
- for (i = 0; i < config->bNumInterfaces; ++i) {
- if (check_usb_interface(&config->interface[i], desc, uh) != -1) {
- /* found some interface and saved information about it */
- D("check_usb_interfaces(): Interface %d of %04x:%04x "
- "matches Android device", i, desc->idVendor,
- desc->idProduct);
-
- return i;
- }
- }
-
- return -1;
-}
-
-static int
-register_device(usb_handle *uh, const char *serial)
-{
- D("register_device(): Registering %p [%s] as USB transport",
- uh, serial);
-
- usb_handle* usb = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle)));
- if (usb == nullptr) fatal("couldn't allocate usb_handle");
- memcpy(usb, uh, sizeof(usb_handle));
- strcpy(usb->serial, uh->serial);
-
- adb_cond_init(&usb->notify, 0);
- adb_mutex_init(&usb->lock, 0);
-
- adb_mutex_lock(&usb_lock);
-
- usb->next = &handle_list;
- usb->prev = handle_list.prev;
- usb->prev->next = usb;
- usb->next->prev = usb;
-
- adb_mutex_unlock(&usb_lock);
-
- char devpath[64];
- snprintf(devpath, sizeof(devpath), "ugen%d.%d",
- uh->dev_bus, uh->dev_addr);
-
- register_usb_transport(usb, serial, devpath, 1);
-
- return (1);
-}
-
-static int
-already_registered(usb_handle *uh)
-{
- usb_handle *usb = NULL;
- int exists = 0;
-
- adb_mutex_lock(&usb_lock);
-
- for (usb = handle_list.next; usb != &handle_list; usb = usb->next) {
- if ((usb->dev_bus == uh->dev_bus) &&
- (usb->dev_addr == uh->dev_addr))
- {
- exists = 1;
- break;
- }
- }
-
- adb_mutex_unlock(&usb_lock);
-
- return exists;
-}
-
-static void
-check_device(libusb_device *dev)
-{
- usb_handle uh;
- int i = 0;
- int found = -1;
- char serial[256] = {0};
-
- libusb_device_descriptor desc;
- libusb_config_descriptor *config = NULL;
-
- int r = libusb_get_device_descriptor(dev, &desc);
-
- if (r != LIBUSB_SUCCESS) {
- D("check_device(): Failed to get device descriptor");
- return;
- }
-
- if ((desc.idVendor == 0) && (desc.idProduct == 0))
- return;
-
- D("check_device(): Probing usb device %04x:%04x",
- desc.idVendor, desc.idProduct);
-
- if (!is_adb_interface(desc.idVendor, desc.idProduct,
- ADB_CLASS, ADB_SUBCLASS, ADB_PROTOCOL))
- {
- D("check_device(): Ignored due unknown vendor id");
- return;
- }
-
- uh.dev_bus = libusb_get_bus_number(dev);
- uh.dev_addr = libusb_get_device_address(dev);
-
- if (already_registered(&uh)) {
- D("check_device(): Device (bus: %d, address: %d) "
- "is already registered", uh.dev_bus, uh.dev_addr);
- return;
- }
-
- D("check_device(): Device bus: %d, address: %d",
- uh.dev_bus, uh.dev_addr);
-
- r = libusb_get_active_config_descriptor(dev, &config);
-
- if (r != 0) {
- if (r == LIBUSB_ERROR_NOT_FOUND) {
- D("check_device(): Device %4x:%4x is unconfigured",
- desc.idVendor, desc.idProduct);
- return;
- }
-
- D("check_device(): Failed to get configuration for %4x:%4x",
- desc.idVendor, desc.idProduct);
- return;
- }
-
- if (config == NULL) {
- D("check_device(): Sanity check failed after "
- "getting active config");
- return;
- }
-
- if (config->interface != NULL) {
- found = check_usb_interfaces(config, &desc, &uh);
- }
-
- /* not needed anymore */
- libusb_free_config_descriptor(config);
-
- r = libusb_open(dev, &uh.devh);
- uh.dev = dev;
-
- if (r != 0) {
- switch (r) {
- case LIBUSB_ERROR_NO_MEM:
- D("check_device(): Memory allocation problem");
- break;
-
- case LIBUSB_ERROR_ACCESS:
- D("check_device(): Permissions problem, "
- "current user priveleges are messed up?");
- break;
-
- case LIBUSB_ERROR_NO_DEVICE:
- D("check_device(): Device disconected, bad cable?");
- break;
-
- default:
- D("check_device(): libusb triggered error %d", r);
- }
- // skip rest
- found = -1;
- }
-
- if (found >= 0) {
- D("check_device(): Device matches Android interface");
- // read the device's serial number
- memset(serial, 0, sizeof(serial));
- uh.interface = found;
-
- r = libusb_claim_interface(uh.devh, uh.interface);
-
- if (r < 0) {
- D("check_device(): Failed to claim interface %d",
- uh.interface);
-
- goto fail;
- }
-
- if (desc.iSerialNumber != 0) {
- libusb_get_string_descriptor_ascii(uh.devh, desc.iSerialNumber,
- (unsigned char *)uh.serial, sizeof(uh.serial));
- }
- if (register_device(&uh, uh.serial) == 0) {
- D("check_device(): Failed to register device\n");
- goto fail_interface;
- }
- }
-
- return;
-
-fail_interface:
- libusb_release_interface(uh.devh, uh.interface);
-
-fail:
- libusb_close(uh.devh);
- uh.devh = NULL;
-}
-
-static int
-check_device_connected(usb_handle *uh)
-{
- int r = libusb_kernel_driver_active(uh->devh, uh->interface);
-
- if (r == LIBUSB_ERROR_NO_DEVICE)
- return 0;
-
- if (r < 0)
- return -1;
-
- return 1;
-}
-
-static void
-kick_disconnected()
-{
- usb_handle *usb = NULL;
-
- adb_mutex_lock(&usb_lock);
-
- for (usb = handle_list.next; usb != &handle_list; usb = usb->next) {
- if (check_device_connected(usb) == 0) {
- D("kick_disconnected(): Transport %p is not online anymore",
- usb);
-
- usb_kick(usb);
- }
- }
-
- adb_mutex_unlock(&usb_lock);
-}
-
-static void
-scan_usb_devices()
-{
- D("scan_usb_devices(): started");
-
- libusb_device **devs= NULL;
- libusb_device *dev= NULL;
- ssize_t cnt = libusb_get_device_list(ctx, &devs);
-
- if (cnt < 0) {
- D("scan_usb_devices(): Failed to get device list (error: %zd)",
- cnt);
-
- return;
- }
-
- int i = 0;
-
- while ((dev = devs[i++]) != NULL) {
- check_device(dev);
- }
-
- libusb_free_device_list(devs, 1);
-}
-
-static void
-device_poll_thread(void*)
-{
- adb_thread_setname("USB scan");
- D("device_poll_thread(): Created USB scan thread");
-
- for (;;) {
- sleep(5);
- kick_disconnected();
- scan_usb_devices();
- }
-}
-
-static void
-sigalrm_handler(int signo)
-{
- /* nothing */
-}
-
-void
-usb_init()
-{
- D("usb_init(): started");
- struct sigaction actions;
-
- atexit(usb_cleanup);
- int r = libusb_init(&ctx);
-
- if (r != LIBUSB_SUCCESS) {
- fatal_errno("Failed to init libusb");
- }
-
- memset(&actions, 0, sizeof(actions));
-
- sigemptyset(&actions.sa_mask);
-
- actions.sa_flags = 0;
- actions.sa_handler = sigalrm_handler;
-
- sigaction(SIGALRM, &actions, NULL);
-
- /* initial device scan */
- scan_usb_devices();
-
- /* starting USB event polling thread */
- if (!adb_thread_create(device_poll_thread, nullptr)) {
- fatal_errno("cannot create USB scan thread");
- }
-
- D("usb_init(): finished");
-}