I had written some scripts using Ubuntu 14.04 and adb
to automatically configure 100´s of Android smartphones.
To achieve that I used an udev
rule to identify if an USB device is attached to the pc and if that's the case I call my scripts to install some apps onto the devices.
So far, so good but there are some problems. At the moment we are connecting 5 devices at the same time, but it happens quite often that on one of the devices one ore more apps are not being installed. It does not follow a pattern, it just happens randomly. Sometimes also the performance of the computer decreases during the day.
Here is my udev
rule:
ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}!="1d6b", ATTRS{idVendor}!="203a", ATTRS{idVendor}=="****", ATTRS{idProduct}=="****", RUN+="/usr/local/bin/selectDevices.sh"
The first script in /usr/local/bin/ to identify the devices on witch the apps should be installed
#!/bin/bash
sleep 2
Pid=/home/android/Schreibtisch/PID
for DEVICE in `adb devices | tail -n +2 | grep device | awk '{print $1}'`;
do
if [ ! -f $Pid/$DEVICE.pid ];
then
touch $Pid/$DEVICE.pid
sh /usr/local/bin/touchDevices.sh $DEVICE
fi
done
and the last script to install the apps
#!/bin/bash
cd /home/android/Desktop/Apps
for APK in $(ls *.apk);
do
adb -s $1 install $APK
done
Edit 1:
I´ve tried it like Alex P. suggested it or in my interpretation of his answer.
Pass the serial to a tmp script and the tmp script is calling the actual installation script with at now
. Before the installation script starts it sleeps 2 seconds.
But the problems still exist. Maybe I need to log what's happening during the installation but at the moment I have no clue how to do that.
Edit 2:
After some time I think I found something but I still have no idea why.
I think adb has problems when two devices want to install one app at the same time. I Managed it to receive an error message like rm failed for /data/local/tmp/foo.apk, No such file or directory
.
After that I switcht to first copy the Package to the devices and then install them with the shell package manager, but still no solution.