Restore 72h DSDS + Wi-Fi standby battery optimizations across all targets

- Fix Combined EPS/IMSI (cs_attach=1) false 4G-only IMS activation in
  ims_qrtr.h, close idle QRTR sockets, bound child/baseband retries, and
  deduplicate state.env writes in bananarchy-imsd.c
- Skip inactive DHCP/connectivity IMS notifications in 40-bananarchy-ims.sh
  and add capped exponential registration backoff (5s-300s) plus
  openCtlSocket() rebind guard in bananarchy-vowifi
- Sync CPU scaling_governor and idempotent screenoff/screenon policy across
  bananarchy-display-power-sync, locker.so, and bananarchy-power-policy.sh
  (standby.mode + rat_timer.pid), and gate noisy change events when dark in
  30-bananarchy-network-status.sh
- Fix bananarchy-dsds --sig-hysteresis QMI NAS wire opcodes to 0x0045
  (1-byte sub bind) and 0x0050 (RSSI/RSCP/RSRP/LTE report threshold config)
- Remove static 200 mA regulator-system-load on PM8909 l11 across all 6
  DTS files and recompile all 5 shipping DTBs
- Extend test-imsd-volte.py, test-standby-power-policy.py, check-rebuild.sh,
  BATTERY-OPTIMIZATION-ANALYSIS.md (Section 24), AGENTS.md, and Unreleased
  CHANGELOG.md notes + rebuilt image SHA-256 checksums (--mkinitfs)
This commit is contained in:
Luxferre committed 2026-11-21 11:05:22 +02:00
1 parent c40ec932de
commit c9eb28b891
42 files changed
+751 -91

No files matched your search

+49 -4
View File
@@ -74,6 +74,8 @@ class MockQrtrRouter:
# Configurable modem simulation state
self.lte_only = False
self.serving_mode = "mixed"
self.qrtr_rx_pkts = 0
self.has_ims_qmi = True
self.imsa_reg = True
self.pdc_chunks = bytearray()
@@ -111,14 +113,20 @@ class MockQrtrRouter:
if svc_port == 100 + SVC_NAS:
if msg_id == 0x0024:
# Serving system
if self.lte_only:
srv = struct.pack("<BBBBBB", 1, 0, 1, 0, 1, 0x08) # LTE only, no CS
mode = "lte_only" if self.lte_only else self.serving_mode
if mode == "lte_only":
srv = struct.pack("<BBBBBB", 1, 2, 1, 0, 1, 0x08) # LTE PS-only, no CS
elif mode == "combined_lte":
srv = struct.pack("<BBBBBB", 1, 1, 1, 0, 1, 0x08) # Combined EPS/IMSI
elif mode == "searching_lte":
srv = struct.pack("<BBBBBB", 2, 2, 2, 0, 1, 0x08) # Searching LTE
else:
srv = struct.pack("<BBBBBBB", 1, 1, 1, 0, 2, 0x08, 0x05) # LTE + UMTS
plmn = struct.pack("<HHB", 240, 1, 0)
return pack_qmi_rsp(txn_id, msg_id, tlv(0x01, srv) + tlv(0x12, plmn))
if msg_id == 0x0034:
mask = 0x0010 if self.lte_only else 0x001F
mode = "lte_only" if self.lte_only else self.serving_mode
mask = 0x0010 if mode == "lte_only" else (0x001C if mode == "combined_lte" else 0x001F)
return pack_qmi_rsp(txn_id, msg_id, tlv(0x11, struct.pack("<H", mask)))
elif svc_port == 100 + SVC_DSD:
if msg_id == 0x0051:
@@ -233,6 +241,10 @@ class MockQrtrRouter:
else:
sn, sp = self.clients[conn]
if mtype in (MSG_LOOKUP, MSG_REGISTER, MSG_DATA):
with self.lock:
self.qrtr_rx_pkts += 1
if mtype == MSG_LOOKUP:
rn, rp = self._lookup_addr(svc)
self._send_mock_pkt(conn, MSG_LOOKUP, 0, 0, rn, rp, svc, inst)
@@ -413,7 +425,33 @@ fi
if vowifi_log.exists():
return fail("vowifi must not start when network is not 4G-only")
# 2) Switch mock NAS to 4G-only -> both VoLTE and VoWiFi auto-activate!
# 1b) Combined EPS/IMSI attach (cs_attach=1, single LTE radio) -> DISABLED and 0 QRTR idle wakeups
with router.lock:
router.serving_mode = "combined_lte"
subprocess.run([str(ctl_bin), "notify", "wwan0", "up"], env=env, check=True)
time.sleep(0.25)
st = read_state_dict(st_path)
if st.get("NETWORK_4G_ONLY") != "0" or st.get("VOLTE_ACTIVE") != "0" or \
st.get("VOWIFI_ACTIVE") != "0":
return fail(f"Combined EPS/IMSI attach falsely triggered 4G-only IMS: {st}")
with router.lock:
router.qrtr_rx_pkts = 0
time.sleep(2.2)
with router.lock:
idle_pkts = router.qrtr_rx_pkts
if idle_pkts != 0:
return fail(f"bananarchy-imsd sent {idle_pkts} QRTR packets over 2.2s idle in Combined EPS/IMSI")
# 1c) Searching LTE (reg_state=2, cs_attach=2) -> must stay disabled
with router.lock:
router.serving_mode = "searching_lte"
subprocess.run([str(ctl_bin), "notify", "wwan0", "up"], env=env, check=True)
time.sleep(0.25)
st = read_state_dict(st_path)
if st.get("NETWORK_4G_ONLY") != "0":
return fail(f"searching LTE falsely triggered NETWORK_4G_ONLY=1: {st}")
# 2) Switch mock NAS to true PS-only 4G -> both VoLTE and VoWiFi auto-activate!
with router.lock:
router.lte_only = True
subprocess.run([str(ctl_bin), "notify", "wwan0", "up"], env=env, check=True)
@@ -427,6 +465,13 @@ fi
return fail(f"expected 4G-only auto-activation, got {st}")
if not router.dsd_ims_apn_set or (1, 0) not in router.ims_set_calls:
return fail(f"expected QMI_DSD ims APN & QMI_IMS enable, calls={router.ims_set_calls}")
with router.lock:
router.qrtr_rx_pkts = 0
time.sleep(2.2)
with router.lock:
reg_idle_pkts = router.qrtr_rx_pkts
if reg_idle_pkts != 0:
return fail(f"bananarchy-imsd polled QRTR {reg_idle_pkts} times while already registered")
# 3) Install + activate SW MBN through imsctl -> chunked QMI_PDC upload!
sw_bytes = test_mbn_mod.build_synthetic_mbn(desc="MockCarrier-4G")