0

Full disclosure: I'm new to both Android development and Linux.

I have a shell script to loop through connected devices and perform ADB commands.

while read -r udid device usb product model device2; do

echo ""
echo $usb
echo ""

# REBOOT
adb -s "$usb" reboot-bootloader

# UNLOCK OEM
fastboot -s "$usb" oem unlock

# REBOOT
fastboot -s "$usb" reboot

done < <(adb devices -l | sed "1d; $ d")

This works great on one device. If I have two devices the first device will work but the second will hang at:

< waiting for usb:1-2 >

On three devices the first device will reboot to bootloader and then hang like I said above.

The endgame here is to execute this script (and several others) on as many android devices as possible at one time. This loop works great for pushing our APK to each device but to unlock the bootloader, to run this code AND for another script to boot to recovery it hangs.

I found this stackoverflow and made sure my udev rules were correct. As I said it works on one device no problem.

I also referenced this post that recommended I change my while loop to a for loop and that has the same result.

These devices are Mediatek phones running Android 6.0 Marshmallow. So all the serial number are the same (0123456789ABCDEF) if that's an issue. I'm using Ubuntu 8.10.

RbK
  • 1
  • 4

1 Answers1

0

So I ended up not using linux and the issue was with the devices all having the same serial number. What I did do was create to bash scripts to run on PC.

The first script looped through the device by the TRANSIT ID to apply the second script which was full of adb commands.

EXAMPLE:

SCRIPT 1:

@echo off
cd C:\adb
FOR /f "tokens=5 delims=:" %%G IN ('adb devices -l') DO (
    start cmd.exe /c "call c:\srcmd\esc-cmd.bat %%G"
)

Calls SCRIPT 2:

@echo off
cd C:\adb
echo ##OPEN AND INSTALL SETTINGS APP##
echo ""
echo ""
echo ""

adb -t %~1 shell input keyevent KEYCODE_WAKEUP
adb -t %~1 shell input keyevent 111

echo ""
echo ""
echo ""
echo ##DONE##

With this system I can run custom adb scripts on multiple devices at one time. I'm running up to 20 at a time at the moment. Works like a charm!

RbK
  • 1
  • 4