Last active
June 4, 2021 23:52
-
-
Save tytydraco/7a3f01c6b9c836958ff1be955152960b to your computer and use it in GitHub Desktop.
Clear data and cache of disabled pacakges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
disabled_pks="$(pm list packages -d | sed 's/package://')" | |
for pkg in $disabled_pks | |
do | |
echo "----- $pkg -----" | |
pm uninstall "$pkg" &> /dev/null | |
echo "- UNINSTALLED UPDATES" | |
pm disable-user "$pkg" &> /dev/null | |
echo "- DISABLED AGAIN" | |
pm clear "$pkg" &> /dev/null | |
echo "- CLEARED DATA" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that pm uninstall won't uninstall the app since it's a system app; it'll just uninstall updates for the app. It will spit errors if there are no updates to be uninstalled so everything is silenced. Disabling certain packages will error if they are not allowed to be enabled / disabled, so that is silenced too. We disable the packages after uninstalling them because they will become re-enabled afterwards. Then we clear all the user data.
RUN THIS SCRIPT ON THE DEVICE ITSELF. Push the script to the device, then run it.