-
Notifications
You must be signed in to change notification settings - Fork 0
/
customize.sh
executable file
·152 lines (119 loc) · 4.91 KB
/
customize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# ╭─────────────────────────────────────────╮
# │ Kill GMS Font Module. | @MrCarb0n │
# ├─────────────────────────────────────────┤
# │ Give proper credit before doing any │
# │ distribution or modification. │
# │ All files licensed under │
# │ GNU General Public License v3.0 │
# ├─────────────────────────────────────────┤
# │ https://github.com/MrCarb0n/killgmsfont │
# ╰─────────────────────────────────────────╯
# set -x
ui_print ' _____ _ _ _ _____ _____ _____ _____ _ '
ui_print '| | |_| | | __| | __| __|___ ___| |_ '
ui_print '| -| | | | | | | | |__ | __| . | | _|'
ui_print '|__|__|_|_|_|_____|_|_|_|_____|__| |___|_|_|_| '
ui_print ''
ui_print '- Installing'
ui_print ''
# Check GMS's components state
ui_print '- Checking Components'
local GMS="com.google.android.gms"
local GMFP="$GMS.fonts.provider.FontsProvider"
local GMFS="$GMS.fonts.update.UpdateSchedulerService"
local DCL="disabledComponents:"
local ECL="enabledComponents:"
local HSP="Hidden[[:space:]]system[[:space:]]packages:"
local DATA="dumpsys package $GMS"
CHECK() { $DATA | sed -n "/$1/,/$2/{/$3/p}" | xargs; }
for g in $GMFP $GMFS; do
case $g in
$(CHECK $DCL $ECL $g))
case $g in
$GMFP) ui_print " Provider: Disabled" ;;
$GMFS) ui_print " Service: Disabled" ;;
esac
;;
$(CHECK $ECL $HSP $g))
case $g in
$GMFP) ui_print " Provider: Enabled" ;;
$GMFS) ui_print " Service: Enabled" ;;
esac
;;
esac
done
ui_print ''
# Find GMS' generated fonts
ui_print '- Finding GMS Fonts'
local GMSFD=com.google.android.gms/files/fonts
for d in /data/fonts /data/data/$GMSFD /data/user/*/$GMSFD; do
[ -d $d ] && ui_print " Found: $d"
done
ui_print ''
# Generating supporting files
ui_print '- Generating Supporting Files'
cat << 'EOF' > $MODPATH/service.sh
# ╭────────────────────────────────────────────╮
# │ Kill GMS Font Module. | @MrCarb0n │
# ├────────────────────────────────────────────┤
# │ Give proper credit before distribution │
# │ or modification. All files licensed │
# │ under GNU General Public License v3.0 │
# ├────────────────────────────────────────────┤
# │ https://github.com/MrCarb0n/killgmsfont │
# ╰────────────────────────────────────────────╯
# set -x
while true; do
(
# Wait until proper boot up
until [ "$(resetprop sys.boot_completed)" = "1" -a -d "/data" ]; do
sleep 1
done
# Disable GMS' font service
STATE_GMSF() {
PM="$(command -v pm)"
GMSF="com.google.android.gms/com.google.android.gms.fonts"
UPS=$(ls -d /data/user/*) # Dynamically get user profiles
for UP in $UPS; do
"$PM" "$@" --user "${UP##*/}" "$GMSF.update.UpdateSchedulerService"
"$PM" "$@" --user "${UP##*/}" "$GMSF.provider.FontsProvider"
done
}
# Delete GMS' generated fonts
DEL_GMSF() {
local GMSFD=com.google.android.gms/files/fonts
[ -d /data/fonts ] && rm -r /data/fonts
find /data \
-type d \
-path "*$GMSFD*" \
-exec test -d {} \; -exec rm -r {} \;
}
# Run primary tasks
STATE_GMSF disable >/dev/null 2>&1
DEL_GMSF
)
# Sleep for 3 hours before running again
sleep 10800 # 3 hours in seconds
done
EOF
ui_print " Generated: service.sh"
ui_print ''
# Remove unnecessary files and print only the filenames
ui_print '- Cleaning up'
EXCEPTIONS="module.prop service.sh uninstall.sh"
for file in $MODPATH/*; do
[ -e "$file" ] && [[ ! " $EXCEPTIONS " =~ " $(basename "$file") " ]] && {
rm -f "$file"
ui_print " Removed: $(basename "$file")"
}
done
ui_print ''
# Set permissions individually for each file and print only the filenames
ui_print '- Setting permissions'
for PERM in $MODPATH/*; do
if [ -e "$PERM" ]; then
set_perm "$PERM" 0 0 0755 u:object_r:system_file:s0
ui_print " Granted: $(basename "$PERM")"
fi
done
ui_print ''