blob: 1a68748e3cabead32f5e8a167d262be3d906113e (
plain)
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
|
#!/system/xbin/bash
#
# Copyright (C) 2017 Jeremy Rand <jeremy@veclabs.net>
# Partially based on code by Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> and Filippo Fil Bergamo
#
# This file is part of "SlightlyBetterAirplaneMode", a set of shell scripts to shut off
# the Samsung phone modem without trusting the non-free modem firmware.
#
# SlightlyBetterAirplaneMode is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SlightlyBetterAirplaneMode is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -euf -o pipefail
usage()
{
echo "Usage: modem.sh [on|off]"
echo "Examples:"
echo "modem.sh off"
echo "|-> disable the modem"
echo " and reboot"
echo "modem.sh on"
echo "|-> enable the modem"
echo " and reboot"
exit 1
}
check_permissions()
{
modem_command="$1"
root_access="$(getprop persist.sys.root_access)"
uid="$(id -u)"
# 0: Root access: Disabled, 2: Root access: ADB only
# For both the terminal application and ADB we have something
# like that:
# shell@i9100:/ $ su
# 255|shell@i9100:/ $
# 1: Root access: Apps only
# From ADB:
# shell@i9100:/ $ su
# Permission denied
# 1|shell@i9100:/ $
# From the terminal application
# u0_a51@i9100:/ $ su
# root@i9100:/ #
if [ "${uid}" != "0" ] ; then
echo ""
echo "This script requires root."
echo "To give it root:"
case "${root_access}" in
"0"|"1"|"2")
echo "- Go in Settings"
echo "- Go in Developer options"
echo "- Select Root access"
echo "- Set it to \"Apps and ADB\""
;;
esac
echo "- Run these 2 commands:"
echo " su"
echo " modem.sh ${modem_command}"
exit 1
fi
}
modem()
{
command="$1"
check_permissions "${command}"
echo "Remounting system partition as writable..."
mount -o rw,remount /system
if [ "${command}" = "on" ] ; then
echo "Enabling RIL..."
mv /system/lib/libsamsung-ril.so.disabled \
/system/lib/libsamsung-ril.so || \
echo 'RIL was already enabled.'
elif [ "${command}" = "off" ] ; then
echo "Disabling RIL..."
mv /system/lib/libsamsung-ril.so \
/system/lib/libsamsung-ril.so.disabled || \
echo 'RIL was already disabled.'
fi
echo "Syncing filesystem..."
sync
sync
echo "Remounting system partition as read-only..."
mount -o ro,remount /system
echo "Syncing filesystem..."
sync
sync
am force-stop org.smssecure.smssecure
# https://android.stackexchange.com/a/139139
echo "Modem will be disabled after we reboot now..."
am start -a android.intent.action.REBOOT
}
if [ $# -ne 1 ] ; then
usage
fi
if [ "$1" = "on" -o "$1" = "off" ] ;then
modem "$1"
else
usage
fi
|