fix(platina): resolve touchscreen, dual panel, charging reboot, battery guard, camera auth, and internal SIM cellular data
- Add patch 0040: cut panel VSP/VSN always-on rails, attach panel follower to Synaptics TCM touch, add Novatek NT36672A touch node, add BOE panel DTS, and extend DVFS up to 1.84/2.2 GHz. - Prevent Qualcomm ABL infinite reboot loop on poweroff while charger connected via standby detection in phone-poweroff.py. - Implement HTTP Basic Auth in camera web preview server with secure digest verification. - Add battery guard daemon and unit tests to maintain SoC between 50% and 65%. - Implement Option 2 for cellular data: disable ZRAM swap to prevent Hexagon DMA fragmentation crash, add modem modules to initfs, enable ModemManager/NetworkManager WWAN packages and services, and add phone-cellular-setup.py CLI utility with unit tests. - Update recipe checksums and verify 109 unit tests and public index boundaries.
This commit is contained in:
@@ -23,6 +23,10 @@ depends="
|
||||
networkmanager-openrc
|
||||
networkmanager-cli
|
||||
networkmanager-wifi
|
||||
networkmanager-wwan
|
||||
modemmanager
|
||||
modemmanager-openrc
|
||||
libqmi
|
||||
wireless-regdb
|
||||
dbus-openrc
|
||||
postmarketos-usb-moded-openrc
|
||||
@@ -47,9 +51,9 @@ package() {
|
||||
install -Dm644 "$srcdir/platina-avahi.conf" "$pkgdir/usr/share/platina/avahi-daemon.conf"
|
||||
}
|
||||
sha512sums="
|
||||
c692b8c5935011955892071ab52b468c17ef186f21a5c2c7927453b2ae2ab8e80bb9d433c96a4e309a1bcec644c86adb9f0781c3fa02a39979d5880af464fb3d deviceinfo
|
||||
b1dec076f65dc1d7b0497aa858c12c520dc92ec53e6df15a4d9bed4b84f16ece639a42d5dfc4f4d0dc98feb390ea882bec3146ab00a10714e393f68174a19adb deviceinfo
|
||||
3221917497d75c8ee6c151f2ed01a4dfdd3fe4e6a691b693b963bfb57fda9e1b482c50b77efa55a6dc4145ba08e9685e23482ddd488128983d79924f677f4eeb kernel-cmdline.conf
|
||||
3901ca92054e15136091e5111feb5a33ca4fb7544020b9df421974409cab0d04989054c209215cb5e4a58da3ac142ebd47049fa75eb922ca6630e6b8297e0bad modules-initfs
|
||||
5095c7617c6fd84a6d29275c01d72b4b0e4196ff2efed7071741845e11cf18be54561c434f323ad449877731c7408e55631c9bab64b58ab0d827ec18f953d290 modules-initfs
|
||||
53d9813f7537bc7d6f2ff7a623ed36c6f1243f3b66bbbc1ac2ebd55897a638e7867e447bea3b0353500d6b1a9a0142e18c1a708f3ff968f8970beedc1175279a disable-suspend.start
|
||||
afc76d9275689bfa47065a14a2f9b0322576d5c269fa46663f4dab5b7299707450f4bbd7e0e6ea926b6afc7b73642dd33bed449d7c0999de53f48d2300d75f8c gpu-firmware.files
|
||||
29dacca516ae2a0aea7e1c523131e120a13dca330af7f52b210971cf3613fe8a9267fd100499df8cf64478228f383c69f915092930468e2b3fb95271aa3512c2 platina-networkmanager.conf
|
||||
|
||||
@@ -7,7 +7,7 @@ if [ -f /usr/share/platina/avahi-daemon.conf ]; then
|
||||
fi
|
||||
# Headless/OpenRC image: enable network and time services without the UI meta package.
|
||||
if command -v rc-update >/dev/null 2>&1; then
|
||||
for service in local networkmanager usb-moded chronyd avahi-daemon; do
|
||||
for service in local networkmanager modemmanager usb-moded chronyd avahi-daemon; do
|
||||
rc-update add "$service" default
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -34,3 +34,6 @@ deviceinfo_flash_offset_tags="0x00000100"
|
||||
deviceinfo_usb_idVendor="0x2717"
|
||||
# Mi/Redmi series (RNDIS)
|
||||
deviceinfo_usb_idProduct="0xff80"
|
||||
|
||||
# Disable ZRAM swap to prevent CMA/DMA fragmentation crashing Hexagon DSP modem on 4GB RAM
|
||||
deviceinfo_zram_swap_pct="0"
|
||||
|
||||
@@ -12,3 +12,9 @@ qcom_q6v5
|
||||
qcom_common
|
||||
snd_soc_qcom_sdw
|
||||
btrtl
|
||||
synaptics_tcm
|
||||
novatek_nvt_ts
|
||||
qcom_ipa
|
||||
rmnet
|
||||
qrtr
|
||||
qrtr-smd
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
From: Platina Linux contributors
|
||||
Subject: [PATCH] arm64: dts: qcom: platina: add dual touch, BOE panel, cut VSP/VSN rail power, and full DVFS
|
||||
|
||||
1. Cut display power: remove forced always-on from panel_vsp/panel_vsn so rails turn off when display is blanked.
|
||||
2. Dual touchscreen: attach panel follower to Synaptics TCM touch (fixing probe timeouts) and add Novatek NT36672A touch node for Tianma panels.
|
||||
3. BOE panel support: add sdm660-xiaomi-platina-boe.dts and build both DTBs.
|
||||
4. Full DVFS: extend cpu0 and cpu4 OPP tables to maximum LUT frequencies (1.84 GHz Little, 2.2 GHz Big).
|
||||
|
||||
--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
|
||||
+++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
|
||||
@@ -1182,3 +1182,53 @@
|
||||
&pm660_haptics {
|
||||
status = "okay";
|
||||
};
|
||||
+
|
||||
+/* Dynamic VSP/VSN rail control: allow regulators to disable when display blanks */
|
||||
+&panel_vsp {
|
||||
+ /delete-property/ regulator-always-on;
|
||||
+};
|
||||
+
|
||||
+&panel_vsn {
|
||||
+ /delete-property/ regulator-always-on;
|
||||
+};
|
||||
+
|
||||
+/* Touchscreen: panel follower synchronization and multi-panel (Synaptics + Novatek) support */
|
||||
+&blsp_i2c4 {
|
||||
+ touchscreen@20 {
|
||||
+ panel = <&panel>;
|
||||
+ };
|
||||
+
|
||||
+ touchscreen@62 {
|
||||
+ compatible = "novatek,NVT-ts", "novatek,nt36672a-ts";
|
||||
+ reg = <0x62>;
|
||||
+
|
||||
+ vddio-supply = <&vreg_l11a_1p8>;
|
||||
+ panel = <&panel>;
|
||||
+
|
||||
+ pinctrl-0 = <&ts_int_active &ts_rst_n>;
|
||||
+ pinctrl-names = "default";
|
||||
+ interrupts-extended = <&tlmm 67 IRQ_TYPE_EDGE_FALLING>;
|
||||
+ reset-gpios = <&tlmm 66 GPIO_ACTIVE_LOW>;
|
||||
+
|
||||
+ touchscreen-size-x = <1080>;
|
||||
+ touchscreen-size-y = <2280>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+/* Extended CPU DVFS operating points up to maximum hardware capabilities */
|
||||
+&cpu0_opp_table {
|
||||
+ opp-1401600000 { opp-hz = /bits/ 64 <1401600000>; };
|
||||
+ opp-1536000000 { opp-hz = /bits/ 64 <1536000000>; };
|
||||
+ opp-1747200000 { opp-hz = /bits/ 64 <1747200000>; };
|
||||
+ opp-1843200000 { opp-hz = /bits/ 64 <1843200000>; };
|
||||
+};
|
||||
+
|
||||
+&cpu4_opp_table {
|
||||
+ opp-1747200000 { opp-hz = /bits/ 64 <1747200000>; };
|
||||
+ opp-1958400000 { opp-hz = /bits/ 64 <1958400000>; };
|
||||
+ opp-2150400000 { opp-hz = /bits/ 64 <2150400000>; };
|
||||
+ opp-2208000000 { opp-hz = /bits/ 64 <2208000000>; };
|
||||
+};
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina-boe.dts
|
||||
@@ -0,0 +1,14 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-only
|
||||
+/dts-v1/;
|
||||
+#include "sdm660-xiaomi-platina.dts"
|
||||
+
|
||||
+&panel {
|
||||
+ compatible = "xiaomi,platina-td4320", "boe,td4320";
|
||||
+ iovcc-supply = <&vreg_l11a_1p8>;
|
||||
+ vsp-supply = <&panel_vsp>;
|
||||
+ vsn-supply = <&panel_vsn>;
|
||||
+ reset-gpios = <&tlmm 53 GPIO_ACTIVE_LOW>;
|
||||
+};
|
||||
--- a/arch/arm64/boot/dts/qcom/Makefile
|
||||
+++ b/arch/arm64/boot/dts/qcom/Makefile
|
||||
@@ -95,3 +95,4 @@
|
||||
dtb-$(CONFIG_ARCH_QCOM) += sdm660-xiaomi-platina.dtb
|
||||
+dtb-$(CONFIG_ARCH_QCOM) += sdm660-xiaomi-platina-boe.dtb
|
||||
@@ -67,6 +67,7 @@ source="
|
||||
0037-imx363-full-field-binning.patch
|
||||
0038-imx363-platina-legacy-frequency.patch
|
||||
0039-venus-legacy-h264-transform.patch
|
||||
0040-platina-touch-dual-panel-vsp-power-dvfs.patch
|
||||
stable-7.2.3-4.patch
|
||||
stable-7.2.4-5.patch
|
||||
stable-7.2.5-6.patch
|
||||
@@ -129,7 +130,7 @@ package() {
|
||||
}
|
||||
sha512sums="
|
||||
b56636f4d7429e971a70c1b7237fda4d5795fbe422c01f6fc6038220c2e831bf4479bd411b5e04e4db45de4fb8ec15a9e0e312b6479e2067709062af3dfd6997 linux-dd1ed52c8ceef4f16715118ed0252fe75adbe71d.tar.gz
|
||||
25f1d9cd84243a011d14a25b55f76857522ebc2b7c4ccea36dea59e8f8aa36d27069daf6ee57292c9800fb4eabcfc0c8767fb0c98f045b40dd2f81ace632e859 config-postmarketos-qcom-sdm660.aarch64
|
||||
80c5d3021180c970201f1ecd46f0f6e3a954ccd83a2656d4fa216c8bec73a04c43214309813baf61e23624d61bc195268b824e811d5cc6cbea0ba6c6773bc8d6 config-postmarketos-qcom-sdm660.aarch64
|
||||
0ed47ad2e1cf773a49ab542b4f6ccc2baf61a4186e51cda8f70bacce6c30c687305f8c7f327cdd9b3919358ca18eaac28c7c9b82bfec73e5fe492663afdec825 0001-platina-enable-display.patch
|
||||
83b9efa9b1a46499d1936f9e3f90b832458ace687a5ad3892ae1787a09997491efb9cc1bb0db44007adda97900ae2e3ce1b7dafa28ecb4cd84a95ade8667f05b 0002-panel-simple-td4320.patch
|
||||
2ff1034abfbaf3c5bf56233b46a6c5a066015a982d4e55e5fd34c5d908d145305c7a99fd7731057b8fd5b9afc3e595b60856f6e0a0af921cfbff068eb744757b 0004-synaptics-tcm-driver.patch
|
||||
@@ -162,6 +163,7 @@ ecfee5c3fde9c5342195d5e25f7103d909144d9602497aa4de713fc55d9c03f89601081535d43da7
|
||||
62031fc20f13bec1bc9a0a67134a2967acbf76cd2d9d3eea9cf5d8176d5bbe61e0063b165b9caf959ec8d923fbb8897cb7421c723d38d695da51a2cb3eddf6c2 0037-imx363-full-field-binning.patch
|
||||
b1094708de883b3aecaf52ddc7f9315c150f6234165ab02ef7a021bc18da4d56cc5eab0f9239583a3b596c307ef71b891f0d735d889156e783b7bb21ba26b448 0038-imx363-platina-legacy-frequency.patch
|
||||
61a598e63d83c0489ba130231cd0a4c2dc4351de5c122cef9b7170f7f516bae7573c744535035c53e2642a96d13fe5048c07e4c908de8f64c90a3cd8809ee84c 0039-venus-legacy-h264-transform.patch
|
||||
cc1ea90682e52f9b381cab306705672b0e223e7f486790d9f8c8736b41fd4bb49527330242a95a55fdf10a3fad4d9e626e2af5f5afbc5edd2a9e50219114a213 0040-platina-touch-dual-panel-vsp-power-dvfs.patch
|
||||
1a7f9cf2443c0f059ac64a78dddee77fca584288edeea943aa45db05fb5e3b7b2930dab595f6c0911671bf5517bd64550a65b097f47d5179cc7454ec90db56cd stable-7.2.3-4.patch
|
||||
303d4a717c67d5dbb5d17c37882b3ef1b6b44b3cf9b17723a611efe1f028019d5ef53c0e3595ed79f5468a46ede2d640171b9dd97ce2dd99b487d0406ef79f16 stable-7.2.4-5.patch
|
||||
b09a94d0eb3c0382ad8998843019ea0d52ae5a89ad7ba54072b21eeea2c7ee602c57a32a0d9b99a2c5ae1f581dadc4d4395096e905b54678affc18125d9b8cba stable-7.2.5-6.patch
|
||||
|
||||
+1
-1
@@ -2299,7 +2299,7 @@ CONFIG_ATH10K_SPECTRAL=y
|
||||
#
|
||||
# Wireless WAN
|
||||
#
|
||||
# CONFIG_WWAN is not set
|
||||
CONFIG_WWAN=m
|
||||
# end of Wireless WAN
|
||||
|
||||
# CONFIG_NETDEVSIM is not set
|
||||
|
||||
@@ -320,7 +320,25 @@ class Audio:
|
||||
self.released.wait(timeout=8)
|
||||
|
||||
|
||||
def make_handler(camera, shutdown, audio=None):
|
||||
def load_auth(path):
|
||||
if not path or not path.exists():
|
||||
return None
|
||||
try:
|
||||
data = json.loads(path.read_text())
|
||||
if not isinstance(data, dict):
|
||||
return None
|
||||
if not data.get('enabled', True):
|
||||
return None
|
||||
user = data.get('username')
|
||||
pwd = data.get('password')
|
||||
if user and pwd:
|
||||
return {'username': str(user), 'password': str(pwd)}
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
def make_handler(camera, shutdown, audio=None, auth=None):
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def setup(self):
|
||||
super().setup()
|
||||
@@ -331,6 +349,22 @@ def make_handler(camera, shutdown, audio=None):
|
||||
def log_message(self, *_):
|
||||
pass
|
||||
|
||||
def check_auth(self):
|
||||
if not auth:
|
||||
return True
|
||||
auth_header = self.headers.get('Authorization')
|
||||
if not auth_header or not auth_header.startswith('Basic '):
|
||||
return False
|
||||
try:
|
||||
import base64
|
||||
encoded = auth_header.split(' ', 1)[1].strip()
|
||||
decoded = base64.b64decode(encoded).decode('utf-8')
|
||||
user, pwd = decoded.split(':', 1)
|
||||
return (secrets.compare_digest(user, auth['username']) and
|
||||
secrets.compare_digest(pwd, auth['password']))
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def reply(self, status, content_type, payload):
|
||||
self.send_response(status)
|
||||
self.send_header('Content-Type', content_type)
|
||||
@@ -344,6 +378,14 @@ def make_handler(camera, shutdown, audio=None):
|
||||
self.reply(status, 'application/json', json.dumps(value).encode())
|
||||
|
||||
def do_GET(self):
|
||||
if not self.check_auth():
|
||||
self.send_response(401)
|
||||
self.send_header('WWW-Authenticate', 'Basic realm="Platina Camera"')
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.send_header('Cache-Control', 'no-store')
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps(dict(error='Authentication required')).encode())
|
||||
return
|
||||
path = urlsplit(self.path).path
|
||||
try:
|
||||
if path == '/':
|
||||
@@ -410,6 +452,14 @@ def make_handler(camera, shutdown, audio=None):
|
||||
self.close_connection = True
|
||||
|
||||
def do_POST(self):
|
||||
if not self.check_auth():
|
||||
self.send_response(401)
|
||||
self.send_header('WWW-Authenticate', 'Basic realm="Platina Camera"')
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.send_header('Cache-Control', 'no-store')
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps(dict(error='Authentication required')).encode())
|
||||
return
|
||||
path = urlsplit(self.path).path
|
||||
if path not in ('/settings', '/save', '/restore', '/camera', '/audio'):
|
||||
self.json(404, dict(error='Not found'))
|
||||
@@ -458,6 +508,7 @@ def main():
|
||||
parser.add_argument('--frame', type=Path, default=Path('/run/platina-camera/latest.jpg'))
|
||||
parser.add_argument('--capture', default='/usr/lib/platina-camera/bin/platina-camera-capture')
|
||||
parser.add_argument('--config', type=Path, default=Path('/etc/platina-camera/preview.json'))
|
||||
parser.add_argument('--auth-config', type=Path, default=Path('/etc/platina-camera/auth.json'))
|
||||
parser.add_argument('--mqtt-config', type=Path, default=Path('/etc/platina-camera/mqtt.json'))
|
||||
parser.add_argument('--seconds', type=float)
|
||||
args = parser.parse_args()
|
||||
@@ -468,7 +519,8 @@ def main():
|
||||
camera = Camera(args)
|
||||
audio = Audio()
|
||||
bridge = None
|
||||
server = ThreadingHTTPServer((args.listen, args.port), make_handler(camera, shutdown, audio))
|
||||
auth = load_auth(args.auth_config)
|
||||
server = ThreadingHTTPServer((args.listen, args.port), make_handler(camera, shutdown, audio, auth=auth))
|
||||
server.daemon_threads = True
|
||||
server.timeout = .1
|
||||
try:
|
||||
|
||||
Executable
+145
@@ -0,0 +1,145 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Battery health daemon: maintains battery state of charge (SoC) between 50% and 65%
|
||||
|
||||
Prevents battery swelling, chemical degradation and overcharge heat during 24/7 server operation.
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
|
||||
BATTERY_PATHS = [
|
||||
Path('/sys/class/power_supply/battery'),
|
||||
Path('/sys/class/power_supply/bms'),
|
||||
]
|
||||
CHARGER_PATHS = [
|
||||
Path('/sys/class/power_supply/pm660-charger'),
|
||||
Path('/sys/class/power_supply/qpnp-smbcharger'),
|
||||
]
|
||||
|
||||
|
||||
def find_supply(paths):
|
||||
for path in paths:
|
||||
if path.exists():
|
||||
return path
|
||||
return None
|
||||
|
||||
|
||||
class BatteryPolicy:
|
||||
def __init__(self, low=50, high=65):
|
||||
if not 10 <= low < high <= 95:
|
||||
raise ValueError('Invalid battery thresholds (expected 10 <= low < high <= 95)')
|
||||
self.low = low
|
||||
self.high = high
|
||||
self.charging_state = True
|
||||
|
||||
def evaluate(self, capacity, current_state=None):
|
||||
"""Returns True to charge, False to stop charging, or None for no change."""
|
||||
if current_state is not None:
|
||||
self.charging_state = current_state
|
||||
if capacity >= self.high:
|
||||
self.charging_state = False
|
||||
return False
|
||||
if capacity <= self.low:
|
||||
self.charging_state = True
|
||||
return True
|
||||
return self.charging_state
|
||||
|
||||
|
||||
def get_capacity(battery_dir):
|
||||
if not battery_dir:
|
||||
return None
|
||||
try:
|
||||
cap_file = battery_dir / 'capacity'
|
||||
if cap_file.exists():
|
||||
return int(cap_file.read_text().strip())
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
def set_charging(battery_dir, charger_dir, enable):
|
||||
applied = False
|
||||
val = '1' if enable else '0'
|
||||
|
||||
# 1. Try battery charging_enabled
|
||||
if battery_dir:
|
||||
for node in ('charging_enabled', 'charge_control_limit_max'):
|
||||
target = battery_dir / node
|
||||
if target.exists():
|
||||
try:
|
||||
target.write_text(val + '\n')
|
||||
applied = True
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# 2. Try charger module charging_enabled
|
||||
if charger_dir:
|
||||
for node in ('charging_enabled',):
|
||||
target = charger_dir / node
|
||||
if target.exists():
|
||||
try:
|
||||
target.write_text(val + '\n')
|
||||
applied = True
|
||||
except OSError:
|
||||
pass
|
||||
# 3. Fallback: throttle charger current to 0 on disable
|
||||
if not enable:
|
||||
cur_target = charger_dir / 'current_max'
|
||||
if cur_target.exists():
|
||||
try:
|
||||
cur_target.write_text('0\n')
|
||||
applied = True
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
cur_target = charger_dir / 'current_max'
|
||||
if cur_target.exists():
|
||||
try:
|
||||
cur_target.write_text('1500000\n')
|
||||
applied = True
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
return applied
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--low', type=int, default=50, help='Lower SoC percentage to resume charging (default: 50)')
|
||||
parser.add_argument('--high', type=int, default=65, help='Upper SoC percentage to stop charging (default: 65)')
|
||||
parser.add_argument('--interval', type=float, default=60, help='Poll interval in seconds (default: 60)')
|
||||
parser.add_argument('--once', action='store_true', help='Evaluate once and exit')
|
||||
args = parser.parse_args()
|
||||
|
||||
policy = BatteryPolicy(args.low, args.high)
|
||||
battery_dir = find_supply(BATTERY_PATHS)
|
||||
charger_dir = find_supply(CHARGER_PATHS)
|
||||
|
||||
stop_event = False
|
||||
|
||||
def on_signal(*_):
|
||||
nonlocal stop_event
|
||||
stop_event = True
|
||||
|
||||
for sig in (signal.SIGINT, signal.SIGTERM):
|
||||
signal.signal(sig, on_signal)
|
||||
|
||||
while not stop_event:
|
||||
capacity = get_capacity(battery_dir)
|
||||
if capacity is not None:
|
||||
action = policy.evaluate(capacity)
|
||||
set_charging(battery_dir, charger_dir, action)
|
||||
status_str = 'Charging enabled' if action else 'Charging paused (protective threshold reached)'
|
||||
print(f'platina-battery-guard: capacity={capacity}%, threshold=[{args.low}%-{args.high}%], state={status_str}', flush=True)
|
||||
|
||||
if args.once or stop_event:
|
||||
break
|
||||
|
||||
time.sleep(args.interval)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Executable
+212
@@ -0,0 +1,212 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
"""Platina cellular data management: internal SIM detection, APN configuration, and NetworkManager control."""
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
KNOWN_OPERATOR_APNS = {
|
||||
# China Mobile
|
||||
'46000': 'cmnet',
|
||||
'46002': 'cmnet',
|
||||
'46007': 'cmnet',
|
||||
'46008': 'cmnet',
|
||||
# China Unicom
|
||||
'46001': '3gnet',
|
||||
'46006': '3gnet',
|
||||
'46009': '3gnet',
|
||||
# China Telecom
|
||||
'46003': 'ctnet',
|
||||
'46005': 'ctnet',
|
||||
'46011': 'ctnet',
|
||||
# Common International
|
||||
'310260': 'fast.t-mobile.com', # T-Mobile US
|
||||
'310410': 'nxtgenphone', # AT&T
|
||||
'311480': 'vzwinternet', # Verizon
|
||||
'23410': 'everywhere', # EE UK
|
||||
'23415': 'vodafone', # Vodafone UK
|
||||
}
|
||||
|
||||
CONNECTION_NAME = 'platina-cellular'
|
||||
|
||||
|
||||
def detect_apn_for_operator(operator_code, fallback='internet'):
|
||||
"""Return matching APN for MCC/MNC operator code, or fallback."""
|
||||
if not operator_code:
|
||||
return fallback
|
||||
clean_code = str(operator_code).strip()
|
||||
return KNOWN_OPERATOR_APNS.get(clean_code, fallback)
|
||||
|
||||
|
||||
def parse_mmcli_modem_info(raw_text):
|
||||
"""Parse mmcli -m output into key-value dictionary."""
|
||||
info = {
|
||||
'modem_path': None,
|
||||
'state': 'unknown',
|
||||
'operator_name': None,
|
||||
'operator_code': None,
|
||||
'signal_percent': None,
|
||||
'access_tech': None,
|
||||
'equipment_id': None,
|
||||
'bearer_path': None,
|
||||
}
|
||||
for line in raw_text.splitlines():
|
||||
line = line.strip()
|
||||
if not line or line.startswith('---'):
|
||||
continue
|
||||
if '|' in line:
|
||||
line = line.split('|', 1)[1].strip()
|
||||
if ':' in line:
|
||||
k, v = line.split(':', 1)
|
||||
k = k.strip().lower()
|
||||
v = v.strip()
|
||||
if k == 'path':
|
||||
info['modem_path'] = v
|
||||
elif k == 'state':
|
||||
info['state'] = v
|
||||
elif k == 'operator name':
|
||||
info['operator_name'] = v if v != '--' else None
|
||||
elif k == 'operator id':
|
||||
info['operator_code'] = v if v != '--' else None
|
||||
elif k == 'signal quality':
|
||||
match = re.search(r'(\d+)%', v)
|
||||
if match:
|
||||
info['signal_percent'] = int(match.group(1))
|
||||
elif k == 'access tech':
|
||||
info['access_tech'] = v if v != '--' else None
|
||||
elif k == 'equipment id':
|
||||
info['equipment_id'] = v if v != '--' else None
|
||||
elif (k in ('bearer', 'paths') or 'bearer' in k) and '/Bearer/' in v:
|
||||
info['bearer_path'] = v if v != '--' else None
|
||||
return info
|
||||
|
||||
|
||||
def build_nmcli_setup_commands(con_name=CONNECTION_NAME, apn='cmnet', ifname='*', existing_connections=None):
|
||||
"""Build list of nmcli commands required to configure cellular connection."""
|
||||
existing = existing_connections or []
|
||||
commands = []
|
||||
if con_name in existing:
|
||||
commands.append(['nmcli', 'connection', 'modify', con_name,
|
||||
'gsm.apn', apn,
|
||||
'gsm.auto-config', 'yes',
|
||||
'connection.autoconnect', 'yes',
|
||||
'connection.interface-name', ifname if ifname != '*' else ''])
|
||||
else:
|
||||
cmd = ['nmcli', 'connection', 'add',
|
||||
'type', 'gsm',
|
||||
'con-name', con_name,
|
||||
'ifname', ifname,
|
||||
'apn', apn,
|
||||
'gsm.auto-config', 'yes',
|
||||
'connection.autoconnect', 'yes']
|
||||
commands.append(cmd)
|
||||
return commands
|
||||
|
||||
|
||||
def query_modem_info(executor=subprocess.run):
|
||||
"""Query primary modem info via mmcli."""
|
||||
if not shutil.which('mmcli'):
|
||||
return {'status': 'error', 'message': 'mmcli utility not found'}
|
||||
try:
|
||||
proc = executor(['mmcli', '-L'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
|
||||
modem_matches = re.findall(r'(/org/freedesktop/ModemManager1/Modem/(\d+))', proc.stdout)
|
||||
if not modem_matches:
|
||||
return {'status': 'no_modem', 'message': 'No Qualcomm modem detected by ModemManager'}
|
||||
first_modem_idx = modem_matches[0][1]
|
||||
proc_modem = executor(['mmcli', '-m', first_modem_idx], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, text=True, check=True)
|
||||
info = parse_mmcli_modem_info(proc_modem.stdout)
|
||||
info['modem_index'] = first_modem_idx
|
||||
return {'status': 'ok', 'modem': info}
|
||||
except Exception as exc:
|
||||
return {'status': 'error', 'message': str(exc)}
|
||||
|
||||
|
||||
def configure_cellular(apn=None, ifname='*', executor=subprocess.run):
|
||||
"""Configure NetworkManager cellular connection, auto-resolving APN if unspecified."""
|
||||
chosen_apn = apn
|
||||
if not chosen_apn:
|
||||
info_result = query_modem_info(executor)
|
||||
if info_result.get('status') == 'ok':
|
||||
op_code = info_result['modem'].get('operator_code')
|
||||
chosen_apn = detect_apn_for_operator(op_code, fallback='cmnet')
|
||||
else:
|
||||
chosen_apn = 'cmnet'
|
||||
|
||||
existing = []
|
||||
try:
|
||||
proc = executor(['nmcli', '-t', '-f', 'NAME', 'connection', 'show'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
|
||||
existing = [line.strip() for line in proc.stdout.splitlines() if line.strip()]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
cmds = build_nmcli_setup_commands(CONNECTION_NAME, chosen_apn, ifname, existing)
|
||||
for cmd in cmds:
|
||||
executor(cmd, check=True)
|
||||
return {'connection': CONNECTION_NAME, 'apn': chosen_apn, 'ifname': ifname}
|
||||
|
||||
|
||||
def toggle_cellular(activate=True, executor=subprocess.run):
|
||||
"""Activate or deactivate cellular data connection."""
|
||||
action = 'up' if activate else 'down'
|
||||
cmd = ['nmcli', 'connection', action, CONNECTION_NAME]
|
||||
return executor(cmd, check=True)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--status', action='store_true', help='Show cellular modem and connection status')
|
||||
parser.add_argument('--setup', action='store_true', help='Configure NetworkManager cellular connection')
|
||||
parser.add_argument('--apn', type=str, default=None, help='APN override (auto-detected if omitted)')
|
||||
parser.add_argument('--interface', type=str, default='*', help='Network interface (default: any)')
|
||||
parser.add_argument('--up', action='store_true', help='Bring up cellular data connection')
|
||||
parser.add_argument('--down', action='store_true', help='Bring down cellular data connection')
|
||||
parser.add_argument('--json', action='store_true', help='Output in JSON format')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.status:
|
||||
result = query_modem_info()
|
||||
if args.json:
|
||||
print(json.dumps(result, indent=2))
|
||||
else:
|
||||
if result.get('status') == 'ok':
|
||||
modem = result['modem']
|
||||
print(f"Modem Index: {modem.get('modem_index')}")
|
||||
print(f"State: {modem.get('state')}")
|
||||
print(f"Operator: {modem.get('operator_name')} ({modem.get('operator_code')})")
|
||||
print(f"Signal Quality: {modem.get('signal_percent')}%")
|
||||
print(f"Access Tech: {modem.get('access_tech')}")
|
||||
print(f"Recommended APN: {detect_apn_for_operator(modem.get('operator_code'))}")
|
||||
else:
|
||||
print(f"Cellular Status: {result.get('message')}")
|
||||
return 0
|
||||
|
||||
if args.setup:
|
||||
res = configure_cellular(apn=args.apn, ifname=args.interface)
|
||||
if args.json:
|
||||
print(json.dumps(res, indent=2))
|
||||
else:
|
||||
print(f"Configured {res['connection']} with APN '{res['apn']}'")
|
||||
return 0
|
||||
|
||||
if args.up:
|
||||
toggle_cellular(activate=True)
|
||||
print(f"Activated {CONNECTION_NAME}")
|
||||
return 0
|
||||
|
||||
if args.down:
|
||||
toggle_cellular(activate=False)
|
||||
print(f"Deactivated {CONNECTION_NAME}")
|
||||
return 0
|
||||
|
||||
parser.print_help()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -11,7 +11,44 @@ import sys
|
||||
import time
|
||||
|
||||
|
||||
def request_shutdown():
|
||||
def is_charger_connected():
|
||||
for name in ('pm660-charger', 'battery', 'qpnp-smbcharger', 'usb'):
|
||||
supply = Path(f'/sys/class/power_supply/{name}')
|
||||
if not supply.exists():
|
||||
continue
|
||||
try:
|
||||
online = supply / 'online'
|
||||
if online.exists() and online.read_text().strip() in ('1', 'true'):
|
||||
return True
|
||||
status = supply / 'status'
|
||||
if status.exists() and status.read_text().strip() in ('Charging', 'Full'):
|
||||
return True
|
||||
except OSError:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def enter_charger_standby():
|
||||
print('platina-poweroff: external power connected; entering low-power suspend standby', flush=True)
|
||||
state_file = Path('/sys/power/state')
|
||||
if state_file.exists():
|
||||
for mode in ('mem', 'freeze'):
|
||||
try:
|
||||
state_file.write_text(mode + '\n')
|
||||
print(f'platina-poweroff: woke from {mode} standby', flush=True)
|
||||
return
|
||||
except OSError:
|
||||
continue
|
||||
try:
|
||||
subprocess.run(['pm-suspend'], check=True, timeout=10)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
pass
|
||||
|
||||
|
||||
def request_shutdown(force=False, standby=False):
|
||||
if not force and (standby or is_charger_connected()):
|
||||
enter_charger_standby()
|
||||
return
|
||||
subprocess.run(['/usr/sbin/poweroff'], check=True, timeout=10)
|
||||
print('platina-poweroff: init accepted shutdown; keeping screen until shutdown', flush=True)
|
||||
# Shutdown should terminate this process. If it does not, restore the display
|
||||
@@ -23,6 +60,8 @@ def request_shutdown():
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--preview', action='store_true', help='Show the screen for 5s without shutting down')
|
||||
parser.add_argument('--force', action='store_true', help='Force immediate poweroff even if external charger is attached')
|
||||
parser.add_argument('--standby', action='store_true', help='Enter low-power suspend standby rather than full poweroff')
|
||||
args = parser.parse_args()
|
||||
if os.geteuid() != 0:
|
||||
raise ValueError('Run on the phone as root')
|
||||
@@ -33,7 +72,7 @@ def main():
|
||||
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
with control['device']() as fb:
|
||||
control['show'](fb, directory, 5 if args.preview else 3, 25,
|
||||
after_display=None if args.preview else request_shutdown)
|
||||
after_display=None if args.preview else lambda: request_shutdown(force=args.force, standby=args.standby))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -50,8 +50,16 @@ def build(output, release=None):
|
||||
logo.thumbnail((960, 960), Image.Resampling.LANCZOS)
|
||||
screen.paste(logo, ((width - logo.width) // 2, 410))
|
||||
draw = ImageDraw.Draw(screen)
|
||||
font_path = Path('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf')
|
||||
font = ImageFont.truetype(str(font_path), 44)
|
||||
font_candidates = [
|
||||
Path('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'),
|
||||
Path('/System/Library/Fonts/Supplemental/Arial.ttf'),
|
||||
Path('/Library/Fonts/Arial.ttf'),
|
||||
]
|
||||
font_path = next((p for p in font_candidates if p.exists()), None)
|
||||
if font_path:
|
||||
font = ImageFont.truetype(str(font_path), 44)
|
||||
else:
|
||||
font = ImageFont.load_default()
|
||||
label = 'v' + release['version']
|
||||
box = draw.textbbox((0, 0), label, font=font)
|
||||
text_width, text_height = box[2] - box[0], box[3] - box[1]
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Verify battery charging guard policy and sysfs integration."""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location('battery_guard', ROOT / 'scripts/phone-battery-guard.py')
|
||||
guard = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(guard)
|
||||
|
||||
|
||||
class BatteryGuardTests(unittest.TestCase):
|
||||
def test_policy_thresholds(self):
|
||||
policy = guard.BatteryPolicy(low=50, high=65)
|
||||
# Low capacity: should charge
|
||||
self.assertTrue(policy.evaluate(45))
|
||||
self.assertTrue(policy.evaluate(50))
|
||||
# Between 50 and 65: maintains previous state (charging)
|
||||
self.assertTrue(policy.evaluate(58))
|
||||
# High capacity reached (>= 65): should pause charging
|
||||
self.assertFalse(policy.evaluate(65))
|
||||
self.assertFalse(policy.evaluate(75))
|
||||
# Dropping between 50 and 65: maintains previous state (paused)
|
||||
self.assertFalse(policy.evaluate(55))
|
||||
# Drops to or below low (<= 50): should resume charging
|
||||
self.assertTrue(policy.evaluate(49))
|
||||
|
||||
def test_invalid_thresholds_rejected(self):
|
||||
with self.assertRaises(ValueError):
|
||||
guard.BatteryPolicy(low=70, high=50)
|
||||
with self.assertRaises(ValueError):
|
||||
guard.BatteryPolicy(low=5, high=60)
|
||||
with self.assertRaises(ValueError):
|
||||
guard.BatteryPolicy(low=50, high=99)
|
||||
|
||||
def test_set_charging_sysfs(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
battery = Path(temp) / 'battery'
|
||||
charger = Path(temp) / 'charger'
|
||||
battery.mkdir()
|
||||
charger.mkdir()
|
||||
(battery / 'charging_enabled').write_text('1\n')
|
||||
(charger / 'charging_enabled').write_text('1\n')
|
||||
(charger / 'current_max').write_text('1500000\n')
|
||||
|
||||
# Disable charging
|
||||
applied = guard.set_charging(battery, charger, False)
|
||||
self.assertTrue(applied)
|
||||
self.assertEqual((battery / 'charging_enabled').read_text().strip(), '0')
|
||||
self.assertEqual((charger / 'charging_enabled').read_text().strip(), '0')
|
||||
self.assertEqual((charger / 'current_max').read_text().strip(), '0')
|
||||
|
||||
# Enable charging
|
||||
applied = guard.set_charging(battery, charger, True)
|
||||
self.assertTrue(applied)
|
||||
self.assertEqual((battery / 'charging_enabled').read_text().strip(), '1')
|
||||
self.assertEqual((charger / 'charging_enabled').read_text().strip(), '1')
|
||||
self.assertEqual((charger / 'current_max').read_text().strip(), '1500000')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -69,6 +69,33 @@ class ControlTests(unittest.TestCase):
|
||||
with self.assertRaises(HTTPError) as error:
|
||||
self.get(endpoint)
|
||||
self.assertEqual(error.exception.code, 503)
|
||||
|
||||
def test_authentication_enforced_when_configured(self):
|
||||
auth = {'username': 'testuser', 'password': 'secretpassword'}
|
||||
stop = threading.Event()
|
||||
server = ThreadingHTTPServer(('127.0.0.1', 0), serve.make_handler(self.camera, stop, self.audio, auth=auth))
|
||||
server.daemon_threads = True
|
||||
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
thread.start()
|
||||
base = 'http://127.0.0.1:' + str(server.server_port)
|
||||
try:
|
||||
with self.assertRaises(HTTPError) as err:
|
||||
urlopen(base + '/status', timeout=3)
|
||||
self.assertEqual(err.exception.code, 401)
|
||||
self.assertIn('Basic', err.exception.headers.get('WWW-Authenticate', ''))
|
||||
|
||||
import base64
|
||||
token = base64.b64encode(b'testuser:secretpassword').decode()
|
||||
req = Request(base + '/status', headers={'Authorization': 'Basic ' + token})
|
||||
with urlopen(req, timeout=3) as resp:
|
||||
self.assertEqual(resp.status, 200)
|
||||
data = json.load(resp)
|
||||
self.assertEqual(data['state'], 'off')
|
||||
finally:
|
||||
stop.set()
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
thread.join()
|
||||
self.assertIsNone(self.camera.capture)
|
||||
|
||||
def test_settings_off_persist_but_capture_does_not(self):
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
"""Verify Platina cellular data setup, APN detection, and NetworkManager commands."""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location('cellular_setup', ROOT / 'scripts/phone-cellular-setup.py')
|
||||
cellular = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(cellular)
|
||||
|
||||
|
||||
SAMPLE_MMCLI_OUTPUT = """
|
||||
--------------------------------
|
||||
General | path: /org/freedesktop/ModemManager1/Modem/0
|
||||
| device id: d060cbb6f1837ac6
|
||||
--------------------------------
|
||||
Hardware | manufacturer: QUALCOMM INCORPORATED
|
||||
| model: SDM660
|
||||
| equipment id: 867530901234567
|
||||
--------------------------------
|
||||
Status | state: connected
|
||||
| power state: on
|
||||
| access tech: lte
|
||||
| signal quality: 84% (recent)
|
||||
--------------------------------
|
||||
3GPP | imei: 867530901234567
|
||||
| operator id: 46000
|
||||
| operator name: CMCC
|
||||
| registration: home
|
||||
--------------------------------
|
||||
Bearer | paths: /org/freedesktop/ModemManager1/Bearer/0
|
||||
"""
|
||||
|
||||
|
||||
class CellularSetupTests(unittest.TestCase):
|
||||
def test_apn_detection_known_carriers(self):
|
||||
# China Mobile
|
||||
self.assertEqual(cellular.detect_apn_for_operator('46000'), 'cmnet')
|
||||
self.assertEqual(cellular.detect_apn_for_operator('46002'), 'cmnet')
|
||||
self.assertEqual(cellular.detect_apn_for_operator('46007'), 'cmnet')
|
||||
# China Unicom
|
||||
self.assertEqual(cellular.detect_apn_for_operator('46001'), '3gnet')
|
||||
self.assertEqual(cellular.detect_apn_for_operator('46006'), '3gnet')
|
||||
# China Telecom
|
||||
self.assertEqual(cellular.detect_apn_for_operator('46003'), 'ctnet')
|
||||
self.assertEqual(cellular.detect_apn_for_operator('46011'), 'ctnet')
|
||||
# US carriers
|
||||
self.assertEqual(cellular.detect_apn_for_operator('310260'), 'fast.t-mobile.com')
|
||||
self.assertEqual(cellular.detect_apn_for_operator('310410'), 'nxtgenphone')
|
||||
# Fallback
|
||||
self.assertEqual(cellular.detect_apn_for_operator('99999', fallback='custom.apn'), 'custom.apn')
|
||||
self.assertEqual(cellular.detect_apn_for_operator(None, fallback='internet'), 'internet')
|
||||
|
||||
def test_parse_mmcli_modem_info(self):
|
||||
info = cellular.parse_mmcli_modem_info(SAMPLE_MMCLI_OUTPUT)
|
||||
self.assertEqual(info['modem_path'], '/org/freedesktop/ModemManager1/Modem/0')
|
||||
self.assertEqual(info['state'], 'connected')
|
||||
self.assertEqual(info['operator_name'], 'CMCC')
|
||||
self.assertEqual(info['operator_code'], '46000')
|
||||
self.assertEqual(info['signal_percent'], 84)
|
||||
self.assertEqual(info['access_tech'], 'lte')
|
||||
self.assertEqual(info['equipment_id'], '867530901234567')
|
||||
self.assertEqual(info['bearer_path'], '/org/freedesktop/ModemManager1/Bearer/0')
|
||||
|
||||
def test_build_nmcli_setup_commands_new(self):
|
||||
cmds = cellular.build_nmcli_setup_commands(
|
||||
con_name='platina-cellular',
|
||||
apn='cmnet',
|
||||
ifname='*',
|
||||
existing_connections=['platina-usb', 'WLAN-Home']
|
||||
)
|
||||
self.assertEqual(len(cmds), 1)
|
||||
self.assertIn('add', cmds[0])
|
||||
self.assertIn('cmnet', cmds[0])
|
||||
self.assertIn('platina-cellular', cmds[0])
|
||||
|
||||
def test_build_nmcli_setup_commands_existing(self):
|
||||
cmds = cellular.build_nmcli_setup_commands(
|
||||
con_name='platina-cellular',
|
||||
apn='3gnet',
|
||||
ifname='rmnet_data0',
|
||||
existing_connections=['platina-cellular', 'platina-usb']
|
||||
)
|
||||
self.assertEqual(len(cmds), 1)
|
||||
self.assertIn('modify', cmds[0])
|
||||
self.assertIn('3gnet', cmds[0])
|
||||
self.assertIn('platina-cellular', cmds[0])
|
||||
|
||||
def test_configure_cellular_invokes_executor(self):
|
||||
recorded_calls = []
|
||||
|
||||
def mock_executor(cmd, **kwargs):
|
||||
recorded_calls.append(cmd)
|
||||
# If asking for connection list
|
||||
if 'connection' in cmd and 'show' in cmd:
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout='platina-usb\n', stderr='')
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout='', stderr='')
|
||||
|
||||
res = cellular.configure_cellular(apn='ctnet', ifname='*', executor=mock_executor)
|
||||
self.assertEqual(res['apn'], 'ctnet')
|
||||
self.assertEqual(res['connection'], 'platina-cellular')
|
||||
# Ensure nmcli add command was executed
|
||||
add_calls = [c for c in recorded_calls if 'add' in c]
|
||||
self.assertEqual(len(add_calls), 1)
|
||||
self.assertIn('ctnet', add_calls[0])
|
||||
|
||||
def test_toggle_cellular(self):
|
||||
recorded_calls = []
|
||||
|
||||
def mock_executor(cmd, **kwargs):
|
||||
recorded_calls.append(cmd)
|
||||
return subprocess.CompletedProcess(cmd, 0)
|
||||
|
||||
cellular.toggle_cellular(activate=True, executor=mock_executor)
|
||||
self.assertEqual(recorded_calls[-1], ['nmcli', 'connection', 'up', 'platina-cellular'])
|
||||
|
||||
cellular.toggle_cellular(activate=False, executor=mock_executor)
|
||||
self.assertEqual(recorded_calls[-1], ['nmcli', 'connection', 'down', 'platina-cellular'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user