Skip to content

Instantly share code, notes, and snippets.

@eybisi
Created February 12, 2020 12:32
Show Gist options
  • Save eybisi/fb1a9d2ae8c171261a7a98ee2757dd43 to your computer and use it in GitHub Desktop.
Save eybisi/fb1a9d2ae8c171261a7a98ee2757dd43 to your computer and use it in GitHub Desktop.
bash script to remove apps easily
arr=($(adb shell "ls /data/app" | tr "\r\n" " " | sed 's/-[0-9]//g') "Quit")
echo "It's time to choose"
select opt in "${arr[@]}";do
case $opt in
"Quit")
break
esac
re='^[0-9]+$'
if ! [[ $REPLY =~ $re ]]; then
echo "not number"
continue
fi
if [ "$REPLY" -gt "${#arr[@]}" ];then
echo "beyond my limit"
continue
fi
r=$(adb uninstall $opt)
if [[ $r == *"Success"* ]]; then
echo "Success !"
continue
elif [[ $r == *"DEVICE_POLICY_MANAGER"* ]]; then
r1=$(adb shell pm disable-user $opt)
r2=$(adb uninstall $opt)
if [[ $r2 == *"Success"* ]]; then
echo "Success !"
continue
fi
echo "cannot uninstall because of device admin perm.. trying to remove app files"
rem=$(adb shell "rm -r /data/data/$opt;rm -r /data/app/$opt*")
if [[ -z "$rem" ]]; then
adb reboot
echo "rebooted. try to remove again"
fi
elif [[ $r == *"FAILED_INTERNAL_ERROR"* ]]; then
echo "idk what to do"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment