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
diff --git a/build/envsetup.sh b/build/envsetup.sh
index 6118156..3132a65 100644
--- a/build/envsetup.sh
+++ b/build/envsetup.sh
@@ -108,10 +108,10 @@
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 _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