Skip to content

Instantly share code, notes, and snippets.

@dino-su
Created November 1, 2016 07:13
Show Gist options
  • Save dino-su/b60c94413c6da42aa5647d021c2c514b to your computer and use it in GitHub Desktop.
Save dino-su/b60c94413c6da42aa5647d021c2c514b to your computer and use it in GitHub Desktop.
adb monitor
#!/bin/bash
cat << EOF
###########################################################
# Workaround adb disconnecting issue on macOS Sierra
#
# More info:
# https://code.google.com/p/android/issues/detail?id=219085
# credits to: [email protected], [email protected]
###########################################################
EOF
function monitor_adb () {
adb start-server
echo "[$(date)] adb started"
while [ "$(adb shell echo 1)" ]; do sleep 5; done
echo "[$(date)] adb is broken, restarting"
adb kill-server
adb start-server || adb start-server
adb reverse tcp:8081 tcp:8081
}
while [ true ]; do time monitor_adb ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment