From 083837c36185463855d05f78ab21e4fbcaa2482d Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 12 Apr 2017 16:44:47 -0400 Subject: [PATCH] Add a variable EXPERIMENTAL_ADB_CHANNEL_TCP_PORT to try using adb forward with a TCP port instead of a UNIX socket. This is less secure but may work around an OS X/adb bug. --- adb-channel | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/adb-channel b/adb-channel index 51ecffd..8b8cca9 100755 --- a/adb-channel +++ b/adb-channel @@ -2,21 +2,33 @@ set -e -t=`mktemp -d -t adb-channel.XXXXXX` - remote=${1} activity=${2} delay=${3} -atexit() { - [ -z "${activity}" ] || adb shell am force-stop ${activity%%/*} - adb forward --remove localfilesystem:"${t}/sock" - rm -rf "${t}" -} -trap atexit EXIT +case "${EXPERIMENTAL_ADB_CHANNEL_TCP_PORT}" in + '') + t=`mktemp -d -t adb-channel.XXXXXX` + adb_sock=localfilesystem:"${t}/sock" + socat_sock=unix:"${t}/sock" + atexit() { + [ -z "${activity}" ] || adb shell am force-stop ${activity%%/*} + adb forward --remove "${adb_sock}" + rm -rf "${t}" + } + trap atexit EXIT + ;; + *) + echo >&2 "WARNING: this ADB channel is open to everyone on this computer." + adb_sock=tcp:"${EXPERIMENTAL_ADB_CHANNEL_TCP_PORT}" + socat_sock=tcp:localhost:"${EXPERIMENTAL_ADB_CHANNEL_TCP_PORT}" + ;; +esac + trap 'exit 0' HUP INT ALRM TERM [ -z "${activity}" ] || adb shell am start -W ${activity} [ -z "${delay}" ] || sleep "${delay}" -adb forward localfilesystem:"${t}/sock" "${remote}" -socat stdio unix:"${t}/sock" + +adb forward "${adb_sock}" "${remote}" +socat stdio "${socat_sock}"