[Replicant] [vendor_replicant-scripts] [PATCH v2][ 1/8] modem: rework script user interface
Denis 'GNUtoo' Carikli
GNUtoo at cyberdimension.org
Fri Jun 26 00:05:29 UTC 2020
The current interface has various issues that are fixed by
this new interface. Here's the design decisions that went
into the new interface:
- On various computer formfactors, like desktops, laptops
and servers, people running commands in them typically use
a complete hardware keyboard to type them.
Tab is typically available for command completion which
makes commands like disable_modem.sh way less common than
modem_disable.sh.
The result is that modem_disable feels more intuitive to
people that are already used to type commands.
- On Replicant 6.0, on the Galaxy SII which has a small
screen, the underscore (_) key is not immediately
available on the default keyboard, and to get it,
you need to press the "?123" key and press longer on the
minus key (-) to finally have 3 choices where the
underscore displayed in the middle and selected by
default.
However the spacebar ( ) is available.
- On Replicant 6.0, on the Galaxy SII, with the default
keyboard, the Tab key is also not available at all, so
it's best if the commands are as short as possible to
type, as any mistake requires the user to restart typing
it from scratch as there are no arrow keys that could
enable them to correct the previous command (assuming they
know that arrows can do that, which is typically not the
case for many people new to the command line).
'on' and 'off' are way shorter and less error prone than
'enable' and 'disable'.
- Using modem.sh is longer than modem, however the dot (.)
is available on the default keyboard, including on the
Galaxy SII, and to many people that know a bit about the
shell, it will not hide the fact that it is a shell
script, which can empower them to modify it.
- For the usage message the text has been made in a way that
can fit the Galaxy SII small screen. It also been made to
enable users to just type again 'modem.sh off' without
necessarily understanding the shell semantics like # or $.
- Finally the commands need to be easy enough to remember
or to find as people might be in a hurry and need to
enable or disable the modem fast, while being far away
from any computer or Internet connection. While
'modem.sh enable' is probably easier to remember,
'modem.sh on' is good enough, while being shorted to type.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
networking/modem/Android.mk | 11 +--
.../modem/device-files/disable_modem.sh | 44 ----------
networking/modem/device-files/enable_modem.sh | 44 ----------
networking/modem/device-files/modem.sh | 81 +++++++++++++++++++
4 files changed, 83 insertions(+), 97 deletions(-)
delete mode 100755 networking/modem/device-files/disable_modem.sh
delete mode 100755 networking/modem/device-files/enable_modem.sh
create mode 100755 networking/modem/device-files/modem.sh
diff --git a/networking/modem/Android.mk b/networking/modem/Android.mk
index 1305786..84bbb47 100644
--- a/networking/modem/Android.mk
+++ b/networking/modem/Android.mk
@@ -2,14 +2,7 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE := enable_modem.sh
-LOCAL_SRC_FILES := device-files/enable_modem.sh
+LOCAL_MODULE := modem.sh
+LOCAL_SRC_FILES := device-files/modem.sh
LOCAL_MODULE_CLASS := EXECUTABLES
include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := disable_modem.sh
-LOCAL_SRC_FILES := device-files/disable_modem.sh
-LOCAL_MODULE_CLASS := EXECUTABLES
-
-include $(BUILD_PREBUILT)
diff --git a/networking/modem/device-files/disable_modem.sh b/networking/modem/device-files/disable_modem.sh
deleted file mode 100755
index 5650656..0000000
--- a/networking/modem/device-files/disable_modem.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/system/xbin/bash
-#
-# Copyright (C) 2017 Jeremy Rand <jeremy at veclabs.net>
-# Partially based on code by Wolfgang Wiedmeyer <wolfgit at 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
-
-echo "Remounting system partition as writable..."
-mount -o rw,remount /system
-
-echo "Disabling RIL..."
-mv /system/lib/libsamsung-ril.so /system/lib/libsamsung-ril.so.disabled || echo 'RIL was already disabled.'
-
-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
diff --git a/networking/modem/device-files/enable_modem.sh b/networking/modem/device-files/enable_modem.sh
deleted file mode 100755
index 4b78089..0000000
--- a/networking/modem/device-files/enable_modem.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/system/xbin/bash
-#
-# Copyright (C) 2017 Jeremy Rand <jeremy at veclabs.net>
-# Partially based on code by Wolfgang Wiedmeyer <wolfgit at 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
-
-echo "Remounting system partition as writable..."
-mount -o rw,remount /system
-
-echo "Enabling RIL..."
-mv /system/lib/libsamsung-ril.so.disabled /system/lib/libsamsung-ril.so || echo 'RIL was already enabled.'
-
-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 enabled after we reboot now..."
-am start -a android.intent.action.REBOOT
diff --git a/networking/modem/device-files/modem.sh b/networking/modem/device-files/modem.sh
new file mode 100755
index 0000000..626593b
--- /dev/null
+++ b/networking/modem/device-files/modem.sh
@@ -0,0 +1,81 @@
+#!/system/xbin/bash
+#
+# Copyright (C) 2017 Jeremy Rand <jeremy at veclabs.net>
+# Partially based on code by Wolfgang Wiedmeyer <wolfgit at 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
+}
+
+modem()
+{
+ command="$1"
+
+ echo "Remounting system partition as writable..."
+ mount -o rw,remount /system
+
+ if [ "${command}" = "enable" ] ; then
+ echo "Enabling RIL..."
+ mv /system/lib/libsamsung-ril.so.disabled \
+ /system/lib/libsamsung-ril.so || \
+ echo 'RIL was already enabled.'
+ elif [ "${command}" = "disable" ] ; 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
--
2.27.0
More information about the Replicant
mailing list