Last active
June 1, 2022 03:46
-
-
Save voor/33140a59bed9ab545fc564193d28b794 to your computer and use it in GitHub Desktop.
Remove Samsung Bloatware or other Malware baked into Android phones
This file contains 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
#!/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 |
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
Removed packages: