Skip to content

Instantly share code, notes, and snippets.

@tytydraco
Last active June 4, 2021 23:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tytydraco/7a3f01c6b9c836958ff1be955152960b to your computer and use it in GitHub Desktop.
Save tytydraco/7a3f01c6b9c836958ff1be955152960b to your computer and use it in GitHub Desktop.
Clear data and cache of disabled pacakges
#!/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
@tytydraco
Copy link
Author

tytydraco commented Jun 4, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment