feat(cellular, power): enable SDM660 IPA v2.6L 4G LTE, power-key status screen, and DVFS standby
Offline project checks / check (push) Canceled after 0s

This commit is contained in:
shenlei
2026-11-18 01:39:26 +09:00
parent 5a50a8264c
commit 8d12d341bf
43 changed files with 6850 additions and 229 deletions
+70
View File
@@ -78,6 +78,9 @@ class CellularSetupTests(unittest.TestCase):
self.assertIn('connection.autoconnect', cmds[0])
idx = cmds[0].index('connection.autoconnect')
self.assertEqual(cmds[0][idx + 1], 'no')
self.assertIn('ipv4.route-metric', cmds[0])
m_idx = cmds[0].index('ipv4.route-metric')
self.assertEqual(cmds[0][m_idx + 1], '700')
def test_build_nmcli_setup_commands_existing(self):
cmds = cellular.build_nmcli_setup_commands(
@@ -93,6 +96,9 @@ class CellularSetupTests(unittest.TestCase):
self.assertIn('connection.autoconnect', cmds[0])
idx = cmds[0].index('connection.autoconnect')
self.assertEqual(cmds[0][idx + 1], 'no')
self.assertIn('ipv4.route-metric', cmds[0])
m_idx = cmds[0].index('ipv4.route-metric')
self.assertEqual(cmds[0][m_idx + 1], '700')
def test_configure_cellular_invokes_executor(self):
recorded_calls = []
@@ -364,6 +370,70 @@ class CellularSetupTests(unittest.TestCase):
self.assertEqual(recorded[0], ['modprobe', '--ignore-install', 'qcom_q6v5_mss'])
self.assertEqual(recorded[1], ['modprobe', '--ignore-install', 'ipa'])
def test_daemon_waits_for_datapath_and_plmn_registration(self):
checks = [False, True, True]
mm_outputs = [
"General | path: /org/freedesktop/ModemManager1/Modem/0\nStatus | state: searching\n",
SAMPLE_MMCLI_OUTPUT.replace('46000', '46001').replace('CMCC', 'CHN-UNICOM'),
]
mm_idx = [0]
recorded = []
active_state = [False]
logs = []
def mock_datapath():
return checks.pop(0) if checks else True
def mock_executor(cmd, **kwargs):
recorded.append(cmd)
cmd_str = ' '.join(cmd)
if 'mmcli -L' in cmd_str:
return subprocess.CompletedProcess(cmd, 0,
stdout='/org/freedesktop/ModemManager1/Modem/0 [QUALCOMM] SDM660\n', stderr='')
if 'mmcli -m 0' in cmd_str:
out = mm_outputs[min(mm_idx[0], len(mm_outputs) - 1)]
mm_idx[0] += 1
return subprocess.CompletedProcess(cmd, 0, stdout=out, stderr='')
if 'connection show --active' in cmd_str:
out = 'platina-cellular\n' if active_state[0] else 'platina-usb\n'
return subprocess.CompletedProcess(cmd, 0, stdout=out, stderr='')
if 'connection show' in cmd_str:
return subprocess.CompletedProcess(cmd, 0, stdout='platina-usb\n', stderr='')
if 'connection up' in cmd_str:
active_state[0] = True
return subprocess.CompletedProcess(cmd, 0, stdout='', stderr='')
return subprocess.CompletedProcess(cmd, 0, stdout='', stderr='')
res = cellular.run_auto_connect(
daemon=True,
poll_interval=1,
max_attempts=3,
executor=mock_executor,
sleeper=lambda s: None,
logger=logs.append,
datapath_checker=mock_datapath,
)
self.assertFalse(res) # exits cleanly on max_attempts=3 in daemon loop
self.assertTrue(active_state[0])
add_calls = [c for c in recorded if 'add' in c]
self.assertEqual(len(add_calls), 1)
self.assertIn('3gnet', add_calls[0])
self.assertNotIn('cmnet', add_calls[0])
self.assertIn('700', add_calls[0])
self.assertTrue(any('dialing skipped' in log for log in logs))
self.assertTrue(any('waiting for registration' in log for log in logs))
def test_usb_profile_metric_yields_to_cellular_and_wifi(self):
usb_profile = (ROOT / 'ports/candidate/device-xiaomi-platina/platina-usb.nmconnection').read_text()
metric = None
for line in usb_profile.splitlines():
if line.strip().startswith('route-metric='):
metric = int(line.split('=', 1)[1].strip())
break
self.assertIsNotNone(metric)
self.assertEqual(metric, 2000)
self.assertGreater(metric, 700)
if __name__ == '__main__':
unittest.main()