From 6393a3f08363ca4d77f4dfe348798bac2ffabb9d Mon Sep 17 00:00:00 2001 From: Adrian DC Date: Sat, 16 Jun 2018 19:56:43 +0200 Subject: [PATCH] envsetup: Fix adb recovery state detections * The original commands were checking a file, and validating that adb ran without error, resulting in an always-true result * Fix eat and _adb_connected by properly checking the 'test -e' error code Change-Id: I49f82f04f4b51097be76f03bf7021203665da76f --- build/envsetup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/envsetup.sh b/build/envsetup.sh index 61181566..3132a65e 100644 --- a/build/envsetup.sh +++ b/build/envsetup.sh @@ -108,10 +108,10 @@ function eat() return 1 fi adb start-server # Prevent unexpected starting server message from adb get-state in the next line - if [ $(adb get-state) != device -a $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then + if [ $(adb get-state) != device -a $(adb shell 'test -e /sbin/recovery 2> /dev/null; echo $?') != 0 ] ; then echo "No device is online. Waiting for one..." echo "Please connect USB and/or enable USB debugging" - until [ $(adb get-state) = device -o $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do + until [ $(adb get-state) = device -o $(adb shell 'test -e /sbin/recovery 2> /dev/null; echo $?') = 0 ];do sleep 1 done echo "Device Found.." @@ -782,7 +782,7 @@ function repodiff() { function _adb_connected { { if [[ "$(adb get-state)" == device && - "$(adb shell test -e /sbin/recovery; echo $?)" != 0 ]] + "$(adb shell 'test -e /sbin/recovery; echo $?')" != 0 ]] then return 0 fi