This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
gpay-gms-patch.sh
191 lines (180 loc) · 4.83 KB
/
gpay-gms-patch.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/system/bin/sh
# check magiskhide status
check_magiskhide() {
if ! /sbin/magiskhide status; then
echo "MagiskHide not found or disabled."
echo "Do you want to try enabling MagiskHide?"
select ysa in "Yes" "Skip MagiskHide" "Abort"; do
case $ysa in
"Yes")
echo ""
echo "Enabling MagiskHide..."
if /sbin/magiskhide enable; then
echo "Successfully enabled. Moving on..."
sleep 1
else
echo "Could not enable MagiskHide."
sleep 1
exit 1
fi
hide_packages
break
;;
"Skip MagiskHide")
echo ""
echo "Continuing without MagiskHide..."
sleep 1
break
;;
"Abort")
echo ""
echo "Exiting..."
sleep 1
exit 0
;;
esac
done
else
hide_packages
fi
echo ""
sleep 3
}
# enable magiskhide for relevant packages
hide_packages() {
pkgs=(com.google.android.gms com.paypal.android.p2pmobile com.google.android.apps.walletnfcrel com.google.android.ext.services com.google.android.gsf)
for i in "${pkgs[@]}"; do
/sbin/magiskhide add $i
echo "Hiding $i..."
done
echo ""
sleep 3
}
check_sqlite() {
if [ ! -f "/data/local/sqlite3" ]; then
echo "SQLite3 not found. Do you want to download it now? "
# prompt user if download is wanted
select yn in "Yes" "No"; do
case $yn in
Yes)
echo "Getting device architecture..."
abi=$(getprop ro.product.cpu.abi)
echo "Device architecture is $abi."
echo ""
sleep 1
echo "Downloading SQLite3 binary for $abi..."
# use device architecture in the download url
if ! curl -o /data/local/sqlite3 https://raw.githubusercontent.com/davidramiro/gpay-gms-patch/master/bin/"$abi"/sqlite3; then
if ! wget -P /data/local/ https://raw.githubusercontent.com/davidramiro/gpay-gms-patch/master/bin/"$abi"/sqlite3; then
echo "Neither wget nor curl are available on your phone."
echo "To fix this, do one of the following steps:"
echo " - Install Busybox for Android NDK module by osm0sis via Magisk Manager"
echo " - Download SQLite3 manually, place it into /data/local and chmod 755 it"
echo " - Install a wget or curl binary manually"
echo ""
echo "Exiting..."
exit 1
fi
fi
sleep 2
# check if download worked before continuing
if [ -f "/data/local/sqlite3" ]; then
echo "Applying permissions..."
chmod 755 /data/local/sqlite3
sleep 1
echo "SQLite3 installed in /data/local."
echo ""
sleep 1
else
echo "Download failed. Internet/permission issue?"
echo "Exiting..."
sleep 1
exit 1
fi
break
;;
No)
echo ""
echo "This script needs an SQLite3 binary to be present in /data/local."
echo "Please download it manually and use chmod 755."
echo "Exiting..."
sleep 1
exit 1
;;
esac
done
else
echo "SQLite3 binary is present. Moving on."
echo ""
sleep 1
fi
echo ""
sleep 3
}
# main
clear
echo " ** gpay-gms-patch **"
echo " by davidramiro"
echo ""
echo ""
# check for root
if [ $(id -u) = 0 ]; then
echo "We are root. Let's go!"
echo ""
sleep 1
else
echo "Script needs to be run as root. Did you use 'su'?"
exit 1
fi
# user menu
echo "Hiding the packages mentioned on the GitHub repo is recommended."
echo "This script can do this for you."
echo "If you have already done so, you can go on patching the GMS database."
echo ""
sleep 1
select psa in "Patch Database Only" "Set up MagiskHide and Patch" "Abort"; do
case $psa in
"Patch Database Only")
echo "Moving on..."
sleep 1
check_sqlite
break
;;
"Set up MagiskHide and Patch")
echo ""
sleep 1
check_magiskhide
check_sqlite
break
;;
"Abort")
echo "Exiting..."
sleep 1
exit 0
;;
esac
done
# force close gpay
echo "Stopping Google Pay..."
am force-stop com.google.android.apps.walletnfcrel
echo ""
sleep 2
# if the file was already altered before, set its original permissions
echo "Setting default permissions on database..."
chmod 660 /data/data/com.google.android.gms/databases/dg.db
echo ""
sleep 2
# set 0 on every row containing "attest" on dg.db from GMS
echo "Editing database..."
/data/local/sqlite3 /data/data/com.google.android.gms/databases/dg.db "update main set c='0' where a like '%attest%';"
echo ""
sleep 2
# make the file read-only
echo "Setting database as read-only..."
chmod 440 /data/data/com.google.android.gms/databases/dg.db
echo ""
sleep 2
echo "All done! Reboot, add your cards to Google Pay and have fun."
echo "Big thanks to BostonDan@XDA!"
echo ""
exit 0