feat: add WCN3990 Wi-Fi bringup service, battery protection, and bringup automation
Offline project checks / check (push) Canceled after 0s
Offline project checks / check (push) Canceled after 0s
- Add phone-dsp.openrc to initialize Hexagon DSP, rmtfs, pd-mapper, and ath10k_snoc - Update phone-battery-guard threshold to 80% with power supply node fallbacks - Enhance phone-cellular-setup with battery gate checks, RF locks, and unit tests - Include bringup, flashing, and inspection automation scripts for platina - Update candidate IPA v2.6 patches and package locks
This commit is contained in:
@@ -242,6 +242,88 @@ class CellularSetupTests(unittest.TestCase):
|
||||
self.assertEqual(recorded_calls, [])
|
||||
self.assertTrue(any('dialing skipped' in log for log in logs))
|
||||
|
||||
def test_check_battery_gate(self):
|
||||
import tempfile
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
base = Path(tmpdir)
|
||||
bat_dir = base / 'class/power_supply/qcom-battery'
|
||||
bat_dir.mkdir(parents=True)
|
||||
|
||||
# Case 1: Healthy battery (50%, 3.9V) -> Passes
|
||||
(bat_dir / 'capacity').write_text('50\n')
|
||||
(bat_dir / 'voltage_now').write_text('3900000\n')
|
||||
ok, msg = cellular.check_battery_gate(min_capacity=15, min_voltage_uv=3700000, sys_path=tmpdir)
|
||||
self.assertTrue(ok)
|
||||
self.assertIn('passed', msg.lower())
|
||||
|
||||
# Case 2: Low capacity (10%) -> Fails
|
||||
(bat_dir / 'capacity').write_text('10\n')
|
||||
ok, msg = cellular.check_battery_gate(min_capacity=15, min_voltage_uv=3700000, sys_path=tmpdir)
|
||||
self.assertFalse(ok)
|
||||
self.assertIn('capacity 10%', msg)
|
||||
|
||||
# Case 3: Low voltage (3.5V) -> Fails
|
||||
(bat_dir / 'capacity').write_text('25\n')
|
||||
(bat_dir / 'voltage_now').write_text('3500000\n')
|
||||
ok, msg = cellular.check_battery_gate(min_capacity=15, min_voltage_uv=3700000, sys_path=tmpdir)
|
||||
self.assertFalse(ok)
|
||||
self.assertIn('voltage', msg)
|
||||
|
||||
def test_configure_radio_bands(self):
|
||||
recorded_cmds = []
|
||||
|
||||
def mock_executor(cmd, **kwargs):
|
||||
recorded_cmds.append(cmd)
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout='', stderr='')
|
||||
|
||||
results = cellular.configure_radio_bands(rat='lte', bands='1,3', executor=mock_executor)
|
||||
self.assertTrue(all(ok for _, ok, _ in results))
|
||||
|
||||
# Check qmicli call
|
||||
qmi_call = next(c for c in recorded_cmds if 'qmicli' in c)
|
||||
self.assertTrue(any('mode-pref=lte' in arg and 'lte-band-preference=1,3' in arg for arg in qmi_call))
|
||||
|
||||
# Check mmcli call
|
||||
mm_call = next(c for c in recorded_cmds if 'mmcli' in c)
|
||||
self.assertIn('--set-allowed-modes=4g', mm_call)
|
||||
self.assertIn('--set-preferred-mode=4g', mm_call)
|
||||
|
||||
def test_run_auto_connect_enforces_battery_gate(self):
|
||||
logs = []
|
||||
recorded_cmds = []
|
||||
|
||||
def mock_executor(cmd, **kwargs):
|
||||
recorded_cmds.append(cmd)
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout='', stderr='')
|
||||
|
||||
res = cellular.run_auto_connect(
|
||||
daemon=False,
|
||||
poll_interval=1,
|
||||
max_attempts=1,
|
||||
executor=mock_executor,
|
||||
sleeper=lambda s: None,
|
||||
logger=logs.append,
|
||||
datapath_checker=lambda: True,
|
||||
battery_checker=lambda: (False, "Battery gate failed: capacity 10% < 15%"),
|
||||
)
|
||||
self.assertFalse(res)
|
||||
self.assertTrue(any('Battery gate failed' in log for log in logs))
|
||||
# Verify modem was kept/set to low-power
|
||||
self.assertTrue(any('--dms-set-operating-mode=low-power' in ' '.join(c) for c in recorded_cmds))
|
||||
|
||||
def test_load_modem_modules(self):
|
||||
recorded = []
|
||||
|
||||
def mock_executor(cmd, **kwargs):
|
||||
recorded.append(cmd)
|
||||
return subprocess.CompletedProcess(args=cmd, returncode=0, stdout='loaded', stderr='')
|
||||
|
||||
results = cellular.load_modem_modules(executor=mock_executor)
|
||||
self.assertEqual(len(results), 2)
|
||||
self.assertTrue(all(ok for _, ok, _ in results))
|
||||
self.assertEqual(recorded[0], ['modprobe', '--ignore-install', 'qcom_q6v5_mss'])
|
||||
self.assertEqual(recorded[1], ['modprobe', '--ignore-install', 'ipa'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user