Skip to content

Instantly share code, notes, and snippets.

@matheuseduardo
Last active August 17, 2016 17:57
Show Gist options
  • Save matheuseduardo/8d00a0bb266728957e964dc641d07e77 to your computer and use it in GitHub Desktop.
Save matheuseduardo/8d00a0bb266728957e964dc641d07e77 to your computer and use it in GitHub Desktop.
start all packages from android via script
@echo off
:: list all packages (-3 = only thidy parts)
adb shell 'pm list packages -3 > /sdcard/packages.txt';
:: get file
adb pull -p "/sdcard/packages.txt" "packages.txt";
#!/bin/bash
# list all packages (-3 = only thidy parts)
adb shell 'pm list packages -3 > /sdcard/packages.txt';
# get file
adb pull -p "/sdcard/packages.txt" "packages.txt"; # <~ maybe not work on windows w/ cygwin
filelines=`cat packages.txt | cut -c 9-`; # removing "package:" (8 chars)
totalapps=`wc -l < packages.txt`;
countapps=0;
for line in $filelines ; do
countapps=`expr $countapps + 1`
echo "inciando pacote ($countapps/$totalapps): $line";
adb shell "monkey -p $line -c android.intent.category.LAUNCHER 1;"
sleep 4;
adb shell "input keyevent 4; input keyevent 4;" # 2 times back button
sleep 0.5;
adb shell "input keyevent 3"; # then home
sleep 0.5;
echo -e "\n"
done
#!/bin/bash
filename=$1;
filelines=`cat $filename`;
totalapps=`wc -l < $filename`;
countapps=0;
for line in $filelines ; do
countapps=`expr $countapps + 1`
echo "inciando pacote ($countapps/$totalapps): $line";
adb shell "monkey -p $line -c android.intent.category.LAUNCHER 1;"
sleep 4;
adb shell "input keyevent 4; input keyevent 4;" # 2 times back button
sleep 0.5;
adb shell "input keyevent 3"; # then home
sleep 0.5;
echo -e "\n"
done
echo -e "\n";
adb shell input keyevent 26;
echo "fim! :)";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment