-
Notifications
You must be signed in to change notification settings - Fork 0
/
countrycode.sh
executable file
·71 lines (55 loc) · 1.55 KB
/
countrycode.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
#!/system/bin/sh
#
# 20160901
#
# Nicholas Caito
# http://xenomorph.net/
#
# this is used to change the SIM card locale.
# it can help with Hangouts adding the wrong country prefix.
#
# this is designed to run on startup, using sysinit / init.d
#
# us = +1
# gb = +44
#
# setting it in /system/build.prop is over written during SIM init after boot
#
# i found this script when looking for ways of doing this:
# https://gist.github.com/hexchain/f4c8a3583abe0214922a
#
# root check
if [[ $EUID -ne 0 ]]; then
echo "This script needs root access."
exit 1
fi
# set some variables:
# what country code do you wish to use?
COUNTRY="us"
# how many minutes should this run before giving up?
MINUTES=5
# --------------------
# where to log
LOG=/data/local/tmp/sim.log
# calculate loops, based on number of minutes with a 5-second pause between attempts
LOOPS=$(expr $MINUTES \* 60 / 5)
# debug / logging:
echo "CURRENT COUNTRY CODE: $(/system/bin/getprop gsm.sim.operator.iso-country)" > $LOG
echo "Desired country code: $COUNTRY" >> $LOG
echo "Minutes to run: $MINUTES" >> $LOG
echo "Loops to run: $LOOPS" >> $LOG
# loop and delay until the SIM is ready
for i in `seq $LOOPS`; do
# read SIM info
SIM=$(/system/bin/getprop gsm.sim.state)
echo "Current SIM status: $SIM" >> $LOG
if [ "$SIM" == "READY" ]; then
echo "The SIM is ready. Ending loop." >> $LOG
break;
fi
sleep 5
done
# make the actual change
/system/bin/setprop gsm.sim.operator.iso-country $COUNTRY
echo "CURRENT COUNTRY CODE: $(/system/bin/getprop gsm.sim.operator.iso-country)" >> $LOG
# EoF