2019-03-31 02:55:40 +13:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-03-31 04:54:13 +13:00
|
|
|
source debloat_lists.sh
|
|
|
|
|
2019-12-16 11:21:39 +13:00
|
|
|
# Colors used for printing
|
2019-03-31 02:55:40 +13:00
|
|
|
RED='\033[0;31m'
|
2019-12-16 11:21:39 +13:00
|
|
|
BLUE='\033[0;34m'
|
|
|
|
BBLUE='\033[1;34m'
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
ORANGE='\033[0;33m'
|
|
|
|
CYAN='\033[0;36m'
|
2019-03-31 02:55:40 +13:00
|
|
|
NC='\033[0m' # No Color
|
2019-12-16 11:21:39 +13:00
|
|
|
Bold=$(tput B)
|
|
|
|
nBold=$(tput sgr0)
|
|
|
|
|
2019-03-31 02:55:40 +13:00
|
|
|
|
|
|
|
function debloat {
|
|
|
|
name=$1[@]
|
2019-12-27 12:57:33 +13:00
|
|
|
bloat=("${!name}")
|
|
|
|
printf "${RED}${bold}=== $1 debloat list ===${normal}${NC}\n"
|
|
|
|
for i in "${bloat[@]}"; do
|
|
|
|
printf "${RED}$i${NC} -->"
|
|
|
|
adb shell "pm uninstall --user 0 $i"
|
2019-03-31 02:55:40 +13:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-12-27 12:57:33 +13:00
|
|
|
function carrier_choice {
|
|
|
|
clear
|
|
|
|
echo "1 - US_carriers"
|
|
|
|
echo "2 - French carriers"
|
|
|
|
read -r
|
|
|
|
case $REPLY in
|
|
|
|
1) clear;debloat US_carrier_bloat ;;
|
|
|
|
2) clear;debloat French_carrier_bloat ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2019-03-31 02:55:40 +13:00
|
|
|
function list {
|
2019-12-27 12:57:33 +13:00
|
|
|
clear
|
|
|
|
printf "\n${RED}${Bold}Search for packages (grep used):${nBold}${NC} "
|
|
|
|
read -r
|
2019-03-31 02:55:40 +13:00
|
|
|
printf "\n"
|
2019-12-27 12:57:33 +13:00
|
|
|
adb shell "pm list packages | grep -i $REPLY"
|
|
|
|
echo
|
|
|
|
read -n 1 -s -r -p "Press any key to continue"
|
2019-03-31 02:55:40 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
function remove {
|
2019-12-27 12:57:33 +13:00
|
|
|
clear
|
|
|
|
printf "\n${RED}${Bold}package name to remove : ${nBold}${NC} "
|
|
|
|
read -r
|
2019-12-16 11:21:39 +13:00
|
|
|
adb shell "pm uninstall --user 0 $REPLY"
|
2019-03-31 02:55:40 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
function install {
|
2019-12-27 12:57:33 +13:00
|
|
|
clear
|
|
|
|
printf "\n${RED}${Bold}package name to reinstall : ${nBold}${NC} "
|
|
|
|
read -r
|
2019-12-16 11:21:39 +13:00
|
|
|
adb shell "cmd package install-existing $REPLY"
|
2019-03-31 02:55:40 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
function restore {
|
2019-12-27 12:57:33 +13:00
|
|
|
clear
|
|
|
|
printf "${RED}${Bold}Enter the exact name of the backup to restore : ${nBold}${NC} "
|
|
|
|
read -r
|
2019-04-01 01:33:44 +13:00
|
|
|
adb restore $REPLY
|
2019-03-31 02:55:40 +13:00
|
|
|
}
|
|
|
|
|
2019-04-01 01:33:44 +13:00
|
|
|
function check_backup_integrity {
|
2019-03-31 07:39:12 +13:00
|
|
|
set -o pipefail
|
|
|
|
for a in *.adb; do
|
2019-12-27 12:57:33 +13:00
|
|
|
echo "Backup integrity checking ($a)";
|
2019-03-31 07:39:12 +13:00
|
|
|
dd if="$a" bs=24 skip=1 | zlib-flate -uncompress | tar tf - >/dev/null;
|
|
|
|
if [ $? = 0 ]; then
|
2019-12-27 12:57:33 +13:00
|
|
|
printf "${RED}${Bold}Bakcup integrity check : OK${nBold}\n"
|
|
|
|
else printf "${GREEN}${Bold}Backup integrity check : FAILED${nBold}\n"
|
2019-04-01 01:33:44 +13:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-04-14 10:00:29 +12:00
|
|
|
|
2019-04-01 01:33:44 +13:00
|
|
|
function brand_detection {
|
2019-12-27 12:57:33 +13:00
|
|
|
## brand = $(adb shell getprop ro.product.device) // Maybe I should have use this
|
2019-04-01 01:33:44 +13:00
|
|
|
for brand in ${brands[@]}; do
|
|
|
|
check=$(adb shell getprop | grep -c $brand)
|
|
|
|
if [[ $check>0 ]]; then
|
|
|
|
case $brand in
|
2019-04-01 01:57:00 +13:00
|
|
|
"Asus")
|
2019-04-20 11:23:48 +12:00
|
|
|
echo "asus_bloat"
|
2019-04-01 01:57:00 +13:00
|
|
|
return ;;
|
|
|
|
"Huawei")
|
|
|
|
echo "huawei_bloat"
|
|
|
|
return ;;
|
|
|
|
"LG")
|
2019-04-20 11:23:48 +12:00
|
|
|
echo "lg_bloat"
|
2019-04-01 01:57:00 +13:00
|
|
|
return ;;
|
|
|
|
"Nokia")
|
2019-04-20 11:23:48 +12:00
|
|
|
echo "nokia_bloat"
|
2019-04-01 01:57:00 +13:00
|
|
|
return ;;
|
|
|
|
"Samsung")
|
|
|
|
echo "samsung_bloat"
|
|
|
|
return ;;
|
2019-04-20 11:23:48 +12:00
|
|
|
"Sony")
|
|
|
|
echo "sony_bloat"
|
|
|
|
return ;;
|
2019-04-01 01:57:00 +13:00
|
|
|
"Xiaomi")
|
|
|
|
echo "xiaomi_bloat"
|
|
|
|
return ;;
|
2019-04-01 01:33:44 +13:00
|
|
|
esac
|
2019-03-31 07:39:12 +13:00
|
|
|
fi
|
|
|
|
done
|
2019-12-27 12:57:33 +13:00
|
|
|
echo "Brand not supported (yet)"
|
2019-03-31 07:39:12 +13:00
|
|
|
}
|
2019-03-31 02:55:40 +13:00
|
|
|
|
|
|
|
clear
|
|
|
|
printf "\n ================================================\n"
|
|
|
|
printf " # #\n"
|
|
|
|
printf " # SCRIPT ----- DEBLOAT #\n"
|
|
|
|
printf " # ALL DEVICES COMPATIBLE (WIP) #\n"
|
|
|
|
printf " # #\n"
|
2019-12-27 12:57:33 +13:00
|
|
|
printf " # %10s${RED}${Bold}v1.5 (December 30th 2019)${nBold}%10s#\n"
|
2019-03-31 02:55:40 +13:00
|
|
|
printf " # #\n"
|
|
|
|
printf " ================================================\n"
|
|
|
|
echo
|
2019-04-01 01:33:44 +13:00
|
|
|
|
2019-03-31 02:55:40 +13:00
|
|
|
adb devices
|
2019-12-27 12:57:33 +13:00
|
|
|
printf "${RED}${Bold}WARNING : Read carefully the FAQ before using this script!\n\n"
|
|
|
|
printf "Do you want to do a backup of your apps ? [Yes/No] ?\n\n${nBold}"
|
|
|
|
printf "REMINDER : It is likely that some apps wil NOT be backed up (see FAQ).\n\n"
|
|
|
|
read -r
|
2019-03-31 08:32:07 +13:00
|
|
|
if [[ $REPLY =~ [Yy]+[Ee]*[Ss]* ]]; then
|
2019-03-31 07:39:12 +13:00
|
|
|
echo
|
|
|
|
adb backup -apk -all -system -f "${PHONE:-phone}-`date +%Y%m%d-%H%M%S`.adb" # -noshare option is default
|
2019-12-27 12:57:33 +13:00
|
|
|
echo "Checking backup integrity..."
|
2019-04-01 01:33:44 +13:00
|
|
|
check_backup_integrity;
|
2019-03-31 07:39:12 +13:00
|
|
|
fi
|
2019-12-16 11:21:39 +13:00
|
|
|
|
|
|
|
brand=$(brand_detection)
|
|
|
|
|
2019-03-31 02:55:40 +13:00
|
|
|
while true; do
|
2019-12-16 11:21:39 +13:00
|
|
|
printf "\n${Bold}${ORANGE}======= MENU PRINCIPAL ======= ${NC}${nBold}\n\n"
|
2019-12-27 12:57:33 +13:00
|
|
|
printf " 1 - Find packages\n"
|
|
|
|
printf " 2 - Uninstall a specific package\n"
|
|
|
|
printf " 3 - Reinstall a package\n"
|
|
|
|
printf " 4 - Restore a backup\n"
|
2019-12-16 11:21:39 +13:00
|
|
|
printf "\n${Bold}${BBLUE}------- DEBLOAT -------${NC}${nBold}\n"
|
|
|
|
printf " 5 - ${brand}\n"
|
|
|
|
printf " 6 - Google\n"
|
2019-12-27 12:57:33 +13:00
|
|
|
printf " 7 - Carrier\n"
|
2019-12-16 11:21:39 +13:00
|
|
|
printf " 8 - Amazon\n"
|
|
|
|
printf " 9 - Facebook\n"
|
|
|
|
printf " 10 - Microsoft\n"
|
|
|
|
printf " 11 - Divers\n"
|
2019-12-27 12:57:33 +13:00
|
|
|
printf " 12 - Common Android bloat\n"
|
|
|
|
printf "\n exit\n\n"
|
2019-12-16 11:21:39 +13:00
|
|
|
printf "${Bold}${ORANGE}==============================${NC}${nBold}\n\n"
|
|
|
|
|
2019-12-27 12:57:33 +13:00
|
|
|
printf "${RED}${Bold}DON'T FORGET TO REBOOT YOUR PHONE ONCE THE DEBLOAT IS OVER. ${nBold}${NC}\n\n"
|
|
|
|
read -p "${Bold}Choose an action : ${nBold}" action
|
2019-03-31 02:55:40 +13:00
|
|
|
echo
|
|
|
|
|
2019-12-27 12:57:33 +13:00
|
|
|
case $action in
|
2019-03-31 07:39:12 +13:00
|
|
|
1) list ;;
|
|
|
|
2) remove ;;
|
|
|
|
3) install ;;
|
2019-12-16 11:21:39 +13:00
|
|
|
4) restore ;;
|
|
|
|
5) debloat $brand ;;
|
2019-04-01 01:33:44 +13:00
|
|
|
6) debloat google_bloat ;;
|
2019-12-27 12:57:33 +13:00
|
|
|
7) carrier_choice ;;
|
2019-04-01 01:33:44 +13:00
|
|
|
8) debloat amazon_bloat ;;
|
|
|
|
9) debloat facebook_bloat ;;
|
|
|
|
10) debloat microsoft_bloat ;;
|
|
|
|
11) debloat misc_bloat ;;
|
2019-03-31 07:39:12 +13:00
|
|
|
12) debloat generic_bloat ;;
|
|
|
|
"exit") break ;;
|
2019-03-31 02:55:40 +13:00
|
|
|
esac
|
2019-04-14 10:00:29 +12:00
|
|
|
done
|