fix(cellular, touch): prevent baseband crash loop, add touch NULL guard, and safe SIM info queries
Offline project checks / check (push) Canceled after 0s
Offline project checks / check (push) Canceled after 0s
- Guard cellular auto-dialing: check for active IPA/rmnet hardware datapath before connecting, avoiding Hexagon modem DSP assert panics. - Disable connection.autoconnect on cellular network profiles to prevent NetworkManager auto-dial loops. - Add QMI fallback for modem/SIM status queries when ModemManager lacks netdev port. - Fix Novatek touchscreen driver NULL pointer dereference on panel unprepare/suspend (0041 patch). - Bump candidate kernel release to 7.2.12-r14 with updated checksums and DT binding supplies. - Add comprehensive test coverage for cellular datapath detection and connection guards.
This commit is contained in:
@@ -74,6 +74,10 @@ class CellularSetupTests(unittest.TestCase):
|
||||
self.assertIn('add', cmds[0])
|
||||
self.assertIn('cmnet', cmds[0])
|
||||
self.assertIn('platina-cellular', cmds[0])
|
||||
# Ensure autoconnect is disabled to prevent NetworkManager dialing without IPA
|
||||
self.assertIn('connection.autoconnect', cmds[0])
|
||||
idx = cmds[0].index('connection.autoconnect')
|
||||
self.assertEqual(cmds[0][idx + 1], 'no')
|
||||
|
||||
def test_build_nmcli_setup_commands_existing(self):
|
||||
cmds = cellular.build_nmcli_setup_commands(
|
||||
@@ -86,6 +90,9 @@ class CellularSetupTests(unittest.TestCase):
|
||||
self.assertIn('modify', cmds[0])
|
||||
self.assertIn('3gnet', cmds[0])
|
||||
self.assertIn('platina-cellular', cmds[0])
|
||||
self.assertIn('connection.autoconnect', cmds[0])
|
||||
idx = cmds[0].index('connection.autoconnect')
|
||||
self.assertEqual(cmds[0][idx + 1], 'no')
|
||||
|
||||
def test_configure_cellular_invokes_executor(self):
|
||||
recorded_calls = []
|
||||
@@ -112,12 +119,129 @@ class CellularSetupTests(unittest.TestCase):
|
||||
recorded_calls.append(cmd)
|
||||
return subprocess.CompletedProcess(cmd, 0)
|
||||
|
||||
cellular.toggle_cellular(activate=True, executor=mock_executor)
|
||||
cellular.toggle_cellular(activate=True, executor=mock_executor, datapath_checker=lambda: True)
|
||||
self.assertEqual(recorded_calls[-1], ['nmcli', 'connection', 'up', 'platina-cellular'])
|
||||
|
||||
cellular.toggle_cellular(activate=False, executor=mock_executor)
|
||||
cellular.toggle_cellular(activate=False, executor=mock_executor, datapath_checker=lambda: True)
|
||||
self.assertEqual(recorded_calls[-1], ['nmcli', 'connection', 'down', 'platina-cellular'])
|
||||
|
||||
# Without datapath, activating must raise RuntimeError
|
||||
with self.assertRaises(RuntimeError):
|
||||
cellular.toggle_cellular(activate=True, executor=mock_executor, datapath_checker=lambda: False)
|
||||
|
||||
def test_is_cellular_active(self):
|
||||
def mock_active(cmd, **kwargs):
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout='platina-usb\nplatina-cellular\n', stderr='')
|
||||
|
||||
def mock_inactive(cmd, **kwargs):
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout='platina-usb\n', stderr='')
|
||||
|
||||
def mock_error(cmd, **kwargs):
|
||||
raise subprocess.CalledProcessError(1, cmd)
|
||||
|
||||
self.assertTrue(cellular.is_cellular_active(executor=mock_active))
|
||||
self.assertFalse(cellular.is_cellular_active(executor=mock_inactive))
|
||||
self.assertFalse(cellular.is_cellular_active(executor=mock_error))
|
||||
|
||||
def test_enable_modem(self):
|
||||
recorded_calls = []
|
||||
|
||||
def mock_executor(cmd, **kwargs):
|
||||
recorded_calls.append(cmd)
|
||||
return subprocess.CompletedProcess(cmd, 0)
|
||||
|
||||
res = cellular.enable_modem(modem_index=0, executor=mock_executor)
|
||||
self.assertTrue(res)
|
||||
self.assertEqual(recorded_calls[-1], ['mmcli', '-m', '0', '-e'])
|
||||
|
||||
def test_run_auto_connect(self):
|
||||
recorded_calls = []
|
||||
logs = []
|
||||
|
||||
active_state = [False]
|
||||
|
||||
def mock_executor(cmd, **kwargs):
|
||||
recorded_calls.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:
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout=SAMPLE_MMCLI_OUTPUT, 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='')
|
||||
|
||||
# Run with max_attempts=1, daemon=False, with hardware datapath present
|
||||
res = cellular.run_auto_connect(
|
||||
daemon=False,
|
||||
poll_interval=1,
|
||||
max_attempts=2,
|
||||
executor=mock_executor,
|
||||
sleeper=lambda s: None,
|
||||
logger=logs.append,
|
||||
datapath_checker=lambda: True,
|
||||
)
|
||||
self.assertTrue(res)
|
||||
self.assertTrue(active_state[0])
|
||||
self.assertTrue(any('Detected carrier' in log for log in logs))
|
||||
self.assertTrue(any('Connection platina-cellular activated' in log for log in logs))
|
||||
|
||||
def test_has_cellular_datapath(self):
|
||||
import tempfile
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
base = Path(tmpdir)
|
||||
# Case 1: Empty sysfs -> False
|
||||
self.assertFalse(cellular.has_cellular_datapath(tmpdir))
|
||||
|
||||
# Case 2: Driver dir exists with only control files -> False
|
||||
driver_dir = base / 'bus/platform/drivers/ipa'
|
||||
driver_dir.mkdir(parents=True)
|
||||
for f in ('bind', 'unbind', 'uevent', 'module'):
|
||||
(driver_dir / f).touch()
|
||||
self.assertFalse(cellular.has_cellular_datapath(tmpdir))
|
||||
|
||||
# Case 3: Driver dir has bound device symlink/dir -> True
|
||||
(driver_dir / '1e40000.ipa').mkdir()
|
||||
self.assertTrue(cellular.has_cellular_datapath(tmpdir))
|
||||
(driver_dir / '1e40000.ipa').rmdir()
|
||||
|
||||
# Case 4: Network interface rmnet0 exists -> True
|
||||
net_dir = base / 'class/net'
|
||||
net_dir.mkdir(parents=True)
|
||||
(net_dir / 'lo').mkdir()
|
||||
(net_dir / 'usb0').mkdir()
|
||||
self.assertFalse(cellular.has_cellular_datapath(tmpdir))
|
||||
(net_dir / 'rmnet0').mkdir()
|
||||
self.assertTrue(cellular.has_cellular_datapath(tmpdir))
|
||||
|
||||
def test_run_auto_connect_no_datapath_skips_dialing(self):
|
||||
recorded_calls = []
|
||||
logs = []
|
||||
|
||||
def mock_executor(cmd, **kwargs):
|
||||
recorded_calls.append(cmd)
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout='', stderr='')
|
||||
|
||||
res = cellular.run_auto_connect(
|
||||
daemon=False,
|
||||
poll_interval=1,
|
||||
max_attempts=2,
|
||||
executor=mock_executor,
|
||||
sleeper=lambda s: None,
|
||||
logger=logs.append,
|
||||
datapath_checker=lambda: False,
|
||||
)
|
||||
self.assertFalse(res)
|
||||
self.assertEqual(recorded_calls, [])
|
||||
self.assertTrue(any('dialing skipped' in log for log in logs))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user