I need to write a script to test if a service inside of an Android emulator is ready for apk installation or not using this command
adb -s emulator-5554 shell pm list package | grep package:com.android.
If the command does not output any one of these substrings in the first line, then the avd is not ready for apk installation
Is the system running?
Can't find service
online
This is my script
if [ $(adb -s emulator-5554 shell pm list package | grep package:com.android. | head -n 1) = *"Is the system running?"* ] ||
[ $(adb -s emulator-5554 shell pm list package | grep package:com.android. | head -n 1) = *"Can't find service"* ] ||
[ $(adb -s emulator-5554 shell pm list package | grep package:com.android. | head -n 1) = *"online"* ] ; then
echo "could not find package service"
else
echo "found package service"
fi
but I get this error
./script.sh: line 4: [: =: unary operator expected
./script.sh: line 5: [: =: unary operator expected
./script.sh: line 6: [: =: unary operator expected