Skip to content

Instantly share code, notes, and snippets.

@voor
Last active June 1, 2022 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voor/33140a59bed9ab545fc564193d28b794 to your computer and use it in GitHub Desktop.
Save voor/33140a59bed9ab545fc564193d28b794 to your computer and use it in GitHub Desktop.
Remove Samsung Bloatware or other Malware baked into Android phones
#!/bin/bash
set -euo pipefail
# Remove whitespace
function remWS {
if [ -z "${1}" ]; then
cat | tr -d '[:space:]'
else
echo "${1}" | tr -d '[:space:]'
fi
}
for pkg in $(adb shell pm list packages | grep samsung | cut -d':' -f2); do
ws_apk_loc="$(adb shell pm path $(remWS $pkg) | cut -d':' -f2)"
apk_loc="$(remWS $ws_apk_loc)"
set +e
ws_apk_name="$(adb shell /data/local/tmp/aapt-arm-pie dump badging $apk_loc | pcregrep -o1 $'application-label:\'(.+)\'')"
set -e
if [ ! -z "${ws_apk_name}" ]; then
apk_name="$(remWS $ws_apk_name)"
apk_info="$(adb shell /data/local/tmp/aapt-arm-pie dump badging $apk_loc | pcregrep -o1 '\b(package: .+)')"
echo "$pkg:$apk_name:v$(echo $apk_info | pcregrep -io1 -e $'\\bversionName=\'(.+?)\'')" | column -c 40 -t -s ':'
else
echo "$pkg has no label"
fi
done
@voor
Copy link
Author

voor commented Feb 8, 2021

If you accidentally remove something you shouldn't (i.e. the phone is broken) you do not need to factory reset, just run this:

adb shell cmd package install-existing com.samsung.android.providers.contacts

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