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:
@@ -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()
|
||||
Reference in New Issue
Block a user