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:
1 parent
c40ec932de
commit
c9eb28b891
42 files changed
+751
-91
No files matched your search
@@ -92,18 +92,26 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
|||||||
`bananarchy-notifmonitor`, `bananarchy-run-aligned`, `bananarchy-session-loop`, `bananarchy-imsctl`,
|
`bananarchy-notifmonitor`, `bananarchy-run-aligned`, `bananarchy-session-loop`, `bananarchy-imsctl`,
|
||||||
`bananarchy-imsd`) alongside `bananarchy-vowifi`, not Python or `/bin/sh` loops.
|
`bananarchy-imsd`) alongside `bananarchy-vowifi`, not Python or `/bin/sh` loops.
|
||||||
Preserve `/run/bananarchy/lid-state`, the cover socket protocol, `FBIOBLANK`, cover diagnostics,
|
Preserve `/run/bananarchy/lid-state`, the cover socket protocol, `FBIOBLANK`, cover diagnostics,
|
||||||
`should_skip_while_dark()`, `bananarchy-dsds --sig-hysteresis`, `scripts/test-cover-idle.py`,
|
`should_skip_while_dark()`, `bananarchy-dsds --sig-hysteresis` (`QMI_NAS 0x0045` + `0x0050` RSSI/RSCP/RSRP/LTE report),
|
||||||
|
`bananarchy-display-power-sync` (`CPU_GOV_PATH` + `sync_standby_policy` `screenoff`/`screenon` across dark/cover-lit/open),
|
||||||
|
idempotent `standby.mode` + `rat_timer.pid` in `bananarchy-power-policy.sh`, `locker.so` `blankScreenBacklight`/`wakeScreenBacklight`
|
||||||
|
power-policy sync, `30-bananarchy-network-status.sh` dark-screen dispatcher gating, `scripts/test-cover-idle.py`,
|
||||||
`scripts/test-dsds-daemon.py`, and `scripts/test-standby-power-policy.py`.
|
`scripts/test-dsds-daemon.py`, and `scripts/test-standby-power-policy.py`.
|
||||||
- Keep IMS, VoLTE, VoWiFi, and mobile data (`wwan0`) invariants: `/etc/bananarchy/ims.conf` must ship with `volte_mode=auto` and
|
- Keep IMS, VoLTE, VoWiFi, and mobile data (`wwan0`) invariants: `/etc/bananarchy/ims.conf` must ship with `volte_mode=auto` and
|
||||||
`vowifi_mode=auto` (disabled at 0% idle CPU unless connected to a strictly **4G-only** network or explicitly
|
`vowifi_mode=auto` (disabled at 0% idle CPU unless connected to a strictly PS-only **4G-only** network excluding Combined
|
||||||
enabled by the user), `QMI_IMSDCM` (`0x0302`) must stay closed at idle (`close_imsdcm()` / `ensure_imsdcm()`) alongside dedicated QRTR socket isolation + `g_pdc_loaded_id` deduplication in
|
EPS/IMSI `cs_attach == 1`, or explicitly enabled by the user), `QMI_IMSDCM` (`0x0302`) and QRTR (`close_qrtr()`, bounded child
|
||||||
`bananarchy-imsd`, `bananarchy-ims-bearer.sh` must remain isolated from `wwan0`, `QMI_UIM` APDU lock serialization in `bananarchy-vowifi`, emergency calls (`112`/`911`) prioritizing
|
sync/check retries, parked/inactive Wi-Fi event skip, and `40-bananarchy-ims.sh` inactive DHCP/connectivity early exit) must
|
||||||
cellular CS/VoLTE before VoWiFi fallback, Duress Mode gating in `bananarchy-imsctl`/`modem.so`/`files.so`, `/etc/init.d/modemmanager` and `msm-modem-uim-selection` preloading `libmm-wds-bind.so` (`PRIMARY` `QMI_WDS` binding without calling `QMI_DSD 0x004E`), `mobile-data-prep` / `10-bananarchy-dpm.sh` `restore-dsds` handling sticky `cs-only` Dual-SIM pausing, and
|
stay closed/idle at 0% CPU alongside dedicated QRTR socket isolation + `g_pdc_loaded_id` deduplication in `bananarchy-imsd`,
|
||||||
`scripts/test-{lte-mobile-data,ims-mbn,imsd-volte,vowifi-swu-ims}.py` passing under `scripts/check-rebuild.sh`.
|
`bananarchy-ims-bearer.sh` must remain isolated from `wwan0`, `QMI_UIM` APDU lock serialization + exponential registration backoff in
|
||||||
|
`bananarchy-vowifi`, emergency calls (`112`/`911`) prioritizing cellular CS/VoLTE before VoWiFi fallback, Duress Mode gating in
|
||||||
|
`bananarchy-imsctl`/`modem.so`/`files.so`, `/etc/init.d/modemmanager` and `msm-modem-uim-selection` preloading `libmm-wds-bind.so`
|
||||||
|
(`PRIMARY` `QMI_WDS` binding without calling `QMI_DSD 0x004E`), `mobile-data-prep` / `10-bananarchy-dpm.sh` `restore-dsds` handling
|
||||||
|
sticky `cs-only` Dual-SIM pausing, and `scripts/test-{lte-mobile-data,ims-mbn,imsd-volte,vowifi-swu-ims}.py` passing under
|
||||||
|
`scripts/check-rebuild.sh`.
|
||||||
- Keep standby battery invariants from `0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch` and
|
- Keep standby battery invariants from `0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch` and
|
||||||
`bananarchy-power-policy.conf`: `CPU_RPM_SLEEP=0`, `CPU_L2_SLEEP=0`, `MODEM_DRX_MODE=0`, `WIFI_LISTEN_INTERVAL=8`,
|
`bananarchy-power-policy.conf`: `CPU_RPM_SLEEP=0`, `CPU_L2_SLEEP=0`, `MODEM_DRX_MODE=0`, `WIFI_LISTEN_INTERVAL=8`,
|
||||||
`WIFI_STANDBY_RAT=gsm`, `msm8916-wcd-analog` `s2` gating, `pm8916_bms_vm` `screen_off` S3 OCV mode, `sdhci-msm`
|
`WIFI_STANDBY_RAT=gsm`, `msm8916-wcd-analog` `s2` gating, `pm8916_bms_vm` `screen_off` S3 OCV mode, `sdhci-msm`
|
||||||
`vmmc`/`vqmmc` `set_load` (`regulator-allow-set-load;` on `l8`/`l12` across DTS), and `msm8905-cam.c` RPM `l6`/`l17`
|
`vmmc`/`vqmmc` `set_load` (`regulator-allow-set-load;` on `l8`/`l11`/`l12` across DTS/DTBs with no static `regulator-system-load` on `l11`), and `msm8905-cam.c` RPM `l6`/`l17`
|
||||||
regulator consumer voting (`regulator_get_optional`, never raw APSS SPMI writes on RPM LDOs).
|
regulator consumer voting (`regulator_get_optional`, never raw APSS SPMI writes on RPM LDOs).
|
||||||
- Keep the zero-lag plugin model: preloaded resident daemons guarded by lock/FIFO, `poll()` at 0% CPU, offscreen
|
- Keep the zero-lag plugin model: preloaded resident daemons guarded by lock/FIFO, `poll()` at 0% CPU, offscreen
|
||||||
`240x296` Pixmaps at `Y=24`, `PluginTheme`, `RELOAD_THEME`, idle blank/lock helpers, the 350 ms `dwm` wake guard, and
|
`240x296` Pixmaps at `Y=24`, `PluginTheme`, `RELOAD_THEME`, idle blank/lock helpers, the 350 ms `dwm` wake guard, and
|
||||||
|
|||||||
@@ -1613,3 +1613,24 @@ standby baseline (`<= 20.8 mA` on the 1,500 mAh cell) without re-enabling
|
|||||||
`scripts/check-rebuild.sh` zero-regression checks.
|
`scripts/check-rebuild.sh` zero-regression checks.
|
||||||
- Physical 24h and 72h unplugged discharge measurements (without and with a
|
- Physical 24h and 72h unplugged discharge measurements (without and with a
|
||||||
microSD card installed) remain to be measured against the rebuilt image.
|
microSD card installed) remain to be measured against the rebuilt image.
|
||||||
|
|
||||||
|
## 24. Post-IMS/SMP Standby Audit & ~72h DSDS + Wi-Fi ON Restoration (2026-11-21)
|
||||||
|
|
||||||
|
After integrating the `a1120` 4-core SMP/cpufreq patch (`0013`), IMS/VoLTE/VoWiFi stack, and Dual-SIM mobile data fixes, an end-to-end audit identified five regressions pulling DSDS + Wi-Fi standby far below the 72-hour (`<= 20.8 mA` average on the `1,500 mAh` battery) budget:
|
||||||
|
|
||||||
|
1. **IMS false 4G-only detection, QRTR wakeups, and `bananarchy-vowifi` poll storm**:
|
||||||
|
- `ims_qmi_nas_get_serving()` in `src/bananarchy-daemons/ims_qrtr.h` inspected `n_rad` (`1`) and `rad[0] == 0x08` (LTE) without inspecting `cs_attach` (`srv[1]`) or registration/PS-attach state. Standard LTE+CSFB cells using Combined EPS/IMSI attach report a single `0x08` LTE radio with `cs_attach == 1`, causing `bananarchy-imsd` in `volte_mode=auto` / `vowifi_mode=auto` to falsely latch `NETWORK_4G_ONLY=1`, start `QMI_IMSDCM`, and block GSM Wi-Fi standby RAT parking (`WIFI_STANDBY_RAT=gsm`).
|
||||||
|
- Additionally, `bananarchy-imsd` held its `AF_QIPCRTR` socket open even when completely idle, looped indefinitely on a `2,000 ms` `poll()` timeout, re-wrote `state.env` unconditionally, and probed NAS QRTR on `wlan0` / `epdg` events even when `auto` was inactive and Wi-Fi was parked; `40-bananarchy-ims.sh` also invoked `bananarchy-imsctl` on every `dhcp4-change` / `dhcp6-change` / `connectivity-change` even when IMS was inactive; and `bananarchy_vowifi.cpp` leaked/rebound its Unix control socket and retried SIP/IKEv2 registration on a `1,500 ms` / `10 s` loop.
|
||||||
|
- **Fix**: Updated `ims_qmi_nas_get_serving()` to treat `cs_attach == 1` as CS-capable and require registered PS-only LTE (`reg_state == 1 && ps_attach == 1 && has_lte && !has_cs`, or explicit `pref_lte_only`); added `close_qrtr()`, `ims_state_equal()`, `is_wifi_rat_parked()`, bounded child/baseband retries (`500 ms` x4 / `3,000 ms` x3, otherwise `poll(..., -1)`), `40-bananarchy-ims.sh` inactive-event early exit, and `5 s` -> `300 s` exponential backoff in `bananarchy_vowifi.cpp`.
|
||||||
|
2. **Unsynchronized / non-idempotent display power sync (`bananarchy-display-power-sync`, `locker.so`, `bananarchy-power-policy.sh`)**:
|
||||||
|
- Under `0013` 4-core SMP (`1.267 GHz`), `bananarchy-display-power-sync` never synced CPU `scaling_governor` or triggered `bananarchy-power-policy.sh screenoff|screenon`, while `locker_plugin.cpp` blanked/woke the backlight without calling `bananarchy-power-policy.sh`. Meanwhile, `bananarchy-power-policy.sh` lacked `screenoff` / `screenon` idempotency and could spawn duplicate `arm_rat_park_timer()` subshells.
|
||||||
|
- **Fix**: Added `CPU_GOV_PATH`, `sync_cpu_governor()`, and `sync_standby_policy()` to `bananarchy-display-power-sync` across flip and non-flip paths (preserving `powersave` and idempotent `screenoff` through closed-flip cover-display wakes); wired `locker_plugin.cpp` `blankScreenBacklight()` / `wakeScreenBacklight()` to `/usr/bin/bananarchy-power-policy.sh`; and made `screenoff()`, `screenon()`, and `arm_rat_park_timer()` idempotent via `$RUNDIR/standby.mode` and `$RUNDIR/rat_timer.pid`.
|
||||||
|
3. **Broken QMI NAS signal hysteresis opcodes in `bananarchy-dsds.c`**:
|
||||||
|
- Disassembly of `qmi_client_nas_config_signal_info` in `rootfs/usr/lib/libqmi-glib.so.5.12.0` confirmed that `apply_sig_hysteresis()` sent wrong message IDs `0x006F` (with 4-byte sub) and `0x004F` (`GET_SIGNAL_INFO`) + wrong TLV `0x13` (`LTE_SNR`) instead of `0x0045` (`QMI_NAS_BIND_SUBSCRIPTION`, 1-byte TLV `0x01`) and `0x0050` (`QMI_NAS_CONFIG_SIGNAL_INFO`) with TLVs `0x10` (`RSSI`), `0x18` (`RSCP`), `0x16` (`RSRP` 16-bit LE), and `0x17` (`lte_report` `rate=0`, `avg=5 s` dark / `1 s` wake).
|
||||||
|
- **Fix**: Corrected `apply_sig_hysteresis()` to use `0x0045` + `0x0050` with all four threshold/report TLVs and added `BANANARCHY_DSDS_SIG_MOCK_SOCK` for host wire-level testing.
|
||||||
|
4. **Static `200 mA` `l11` regulator load on microSD in DTS/DTBs**:
|
||||||
|
- All 6 DTS files still set static `regulator-system-load = <0x30d40>;` (`200 mA`) on PM8909 `l11` (`sdhci@7864000` `vmmc-supply`), preventing LPM when a microSD card is inserted.
|
||||||
|
- **Fix**: Removed `regulator-system-load = <0x30d40>;` from all 6 DTS files (keeping `regulator-allow-set-load;`), recompiled all 5 shipping DTBs, and guarded against regression in `scripts/check-rebuild.sh`.
|
||||||
|
5. **Dark-screen NetworkManager status spawner (`30-bananarchy-network-status.sh`)**:
|
||||||
|
- Every `dhcp4-change`, `dhcp6-change`, `dns-change`, or `connectivity-change` event spawned `su user -s /bin/sh -c /usr/bin/bananarchy-network-event.sh` even when dark.
|
||||||
|
- **Fix**: Gated noisy change events in `30-bananarchy-network-status.sh` behind `is_screen_dark()` while keeping `up`/`down`/`vpn-*` transitions unconditional.
|
||||||
+15
-7
@@ -27,14 +27,22 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
|||||||
- **Qualcomm MCFG `.mbn` ELF32 parser, profile store, and `QMI_PDC` loader (`src/bananarchy-daemons/ims_mbn.h`, `ims_qrtr.h`, `bananarchy-imsctl.c`, `bananarchy-imsd.c`)**: implemented pure-C Qualcomm MCFG `.mbn` ELF32 LE validation (enforcing `config_type == 1` software configs, parsing `MCFG_TRL` carrier/MCC-MNC/version trailers, scanning `NV 67218` / EFS IMS flags, and computing pure-C SHA-1 `ba_<16hex>` IDs without external tools), persistent storage under `/var/lib/bananarchy/ims/profiles/`, `QMI_PDC` chunked `.mbn` loading/activation over `AF_QIPCRTR` (deduplicated via `g_pdc_loaded_id` / `pdc_select_only`), `QMI_DSD` `"ims"` APN tagging, dedicated-socket `QMI_IMSDCM` (`0x0302`) bearer activate/deactivate server, `QMI_IMS`/`QMI_IMSA` baseband VoLTE control with userspace fallback (`userspace`), and full Duress Mode mutation/exposure guards (`kDuressModeFlagPath`).
|
- **Qualcomm MCFG `.mbn` ELF32 parser, profile store, and `QMI_PDC` loader (`src/bananarchy-daemons/ims_mbn.h`, `ims_qrtr.h`, `bananarchy-imsctl.c`, `bananarchy-imsd.c`)**: implemented pure-C Qualcomm MCFG `.mbn` ELF32 LE validation (enforcing `config_type == 1` software configs, parsing `MCFG_TRL` carrier/MCC-MNC/version trailers, scanning `NV 67218` / EFS IMS flags, and computing pure-C SHA-1 `ba_<16hex>` IDs without external tools), persistent storage under `/var/lib/bananarchy/ims/profiles/`, `QMI_PDC` chunked `.mbn` loading/activation over `AF_QIPCRTR` (deduplicated via `g_pdc_loaded_id` / `pdc_select_only`), `QMI_DSD` `"ims"` APN tagging, dedicated-socket `QMI_IMSDCM` (`0x0302`) bearer activate/deactivate server, `QMI_IMS`/`QMI_IMSA` baseband VoLTE control with userspace fallback (`userspace`), and full Duress Mode mutation/exposure guards (`kDuressModeFlagPath`).
|
||||||
- **VoWiFi (`SWu` IKEv2 + `EAP-AKA`/`EAP-AKA'` + UDP/4500 ESP + 3GPP SIP + `SMS-over-IP`) and AMR-WB/AMR-NB codec support (`src/dwm-plugins/bananarchy_vowifi.cpp`, `vowifi_ikev2.h`, `vowifi_aka.h`, `amr_rtp.h`, `sip_plugin.cpp`)**: added an event-driven C++20 `SWu`/`IMS` userland engine implementing RFC 7296 IKEv2 (`COOKIE`, OpenSSL 3 `BN_get_rfc3526_prime_2048()` DH Group 14 with Group 2 fallback, `CFG_REQUEST` `P_CSCF_IP4/6`), RFC 4187/5448 `EAP-AKA` / `EAP-AKA'` via locked `QMI_UIM` `ISIM`/`USIM` `OPEN_LOGICAL_CHANNEL` + `SEND_APDU` (plus offline Milenage support), RFC 3948 UDP/4500 ESP over `tun_ims`, 3GPP SIP `REGISTER` (`AKAv1-MD5` with `AUTS` resync & instant `REFRESH` triggers), `INVITE` / `183 Session Progress` / `PRACK` / `UPDATE` / RTP / DTMF / `BYE`, `SMS-over-IP` (`RP-DATA` GSM-7/UCS-2 logging cleanly without `[SIM n]` tags), anti-spam `block.tsv` filtering, runtime-`dlopen`ed `AMR-WB` (`16 kHz`) / `AMR-NB` (`8 kHz`) octet-aligned and bandwidth-efficient RFC 4867 codecs (shared with `xsip` / `sip.so`), and cellular-first `112`/`911` emergency call routing (`sxmo_modemdial.sh`, `sxmo_modemcall.sh`, `sxmo_modemsendsms.sh`).
|
- **VoWiFi (`SWu` IKEv2 + `EAP-AKA`/`EAP-AKA'` + UDP/4500 ESP + 3GPP SIP + `SMS-over-IP`) and AMR-WB/AMR-NB codec support (`src/dwm-plugins/bananarchy_vowifi.cpp`, `vowifi_ikev2.h`, `vowifi_aka.h`, `amr_rtp.h`, `sip_plugin.cpp`)**: added an event-driven C++20 `SWu`/`IMS` userland engine implementing RFC 7296 IKEv2 (`COOKIE`, OpenSSL 3 `BN_get_rfc3526_prime_2048()` DH Group 14 with Group 2 fallback, `CFG_REQUEST` `P_CSCF_IP4/6`), RFC 4187/5448 `EAP-AKA` / `EAP-AKA'` via locked `QMI_UIM` `ISIM`/`USIM` `OPEN_LOGICAL_CHANNEL` + `SEND_APDU` (plus offline Milenage support), RFC 3948 UDP/4500 ESP over `tun_ims`, 3GPP SIP `REGISTER` (`AKAv1-MD5` with `AUTS` resync & instant `REFRESH` triggers), `INVITE` / `183 Session Progress` / `PRACK` / `UPDATE` / RTP / DTMF / `BYE`, `SMS-over-IP` (`RP-DATA` GSM-7/UCS-2 logging cleanly without `[SIM n]` tags), anti-spam `block.tsv` filtering, runtime-`dlopen`ed `AMR-WB` (`16 kHz`) / `AMR-NB` (`8 kHz`) octet-aligned and bandwidth-efficient RFC 4867 codecs (shared with `xsip` / `sip.so`), and cellular-first `112`/`911` emergency call routing (`sxmo_modemdial.sh`, `sxmo_modemcall.sh`, `sxmo_modemsendsms.sh`).
|
||||||
- **NeoUI control, CallScreen, power policy, and offline verification (`modem_plugin.cpp`, `files_plugin.cpp`, `callscreen_plugin.cpp`, `bananarchy-power-policy.sh`, `scripts/test-{ims-mbn,imsd-volte,vowifi-swu-ims,standby-power-policy}.py`)**: expanded `xmodem` to 5 tabs (`1:SIM 2:Rad 3:IMS 4:AT 5:Log`) with interactive `.mbn` install/select/remove and ePDG modals, added `.mbn` inspect/install actions to `xfiles`, wired `[SIM n VoWiFi]` / `[SIM n VoLTE]` badges and 425 Hz ringback into `xcallscreen`, updated `sxmo_hook_statusbar.sh`, `sxmo_hook_modem.sh`, `bananarchy-cover-status.sh`, `bananarchy-power-policy.sh` (preventing GSM parking during active cellular-preferred VoLTE and preserving IPv6 RA when `VOWIFI_IPV6_EPDG=1`), and added offline mock-QRTR / mock-TUN / Milenage host test suites (`test-ims-mbn.py`, `test-imsd-volte.py`, `test-vowifi-swu-ims.py`, and case 6 in `test-standby-power-policy.py`) wired into `scripts/check-rebuild.sh`.
|
- **NeoUI control, CallScreen, power policy, and offline verification (`modem_plugin.cpp`, `files_plugin.cpp`, `callscreen_plugin.cpp`, `bananarchy-power-policy.sh`, `scripts/test-{ims-mbn,imsd-volte,vowifi-swu-ims,standby-power-policy}.py`)**: expanded `xmodem` to 5 tabs (`1:SIM 2:Rad 3:IMS 4:AT 5:Log`) with interactive `.mbn` install/select/remove and ePDG modals, added `.mbn` inspect/install actions to `xfiles`, wired `[SIM n VoWiFi]` / `[SIM n VoLTE]` badges and 425 Hz ringback into `xcallscreen`, updated `sxmo_hook_statusbar.sh`, `sxmo_hook_modem.sh`, `bananarchy-cover-status.sh`, `bananarchy-power-policy.sh` (preventing GSM parking during active cellular-preferred VoLTE and preserving IPv6 RA when `VOWIFI_IPV6_EPDG=1`), and added offline mock-QRTR / mock-TUN / Milenage host test suites (`test-ims-mbn.py`, `test-imsd-volte.py`, `test-vowifi-swu-ims.py`, and case 6 in `test-standby-power-policy.py`) wired into `scripts/check-rebuild.sh`.
|
||||||
|
|
||||||
|
### Standby battery life restoration (~72h DSDS + Wi-Fi ON target) across all targets
|
||||||
|
|
||||||
|
- **IMS Combined EPS/IMSI detection, QRTR idle sleep, and VoWiFi backoff (`src/bananarchy-daemons/ims_qrtr.h`, `bananarchy-imsd.c`, `src/dwm-plugins/bananarchy_vowifi.cpp`, `overlay/rootfs/etc/NetworkManager/dispatcher.d/40-bananarchy-ims.sh`)**: inspected TLV `0x01` `cs_attach` in `ims_qmi_nas_get_serving()` (plus PS-attach/registered checks) so standard Combined EPS/IMSI (`cs_attach == 1`) LTE+CSFB cells stay `NETWORK_4G_ONLY=0` under `volte_mode=auto` / `vowifi_mode=auto` rather than keeping VoLTE/VoWiFi active and blocking GSM Wi-Fi standby RAT parking; added `close_qrtr()` when idle, deduplicated `ims_state_write()` updates via `ims_state_equal()`, bounded child sync/check retries so `bananarchy-imsd` returns to `poll(..., -1)` instead of waking every `2,000 ms`, skipped NAS QRTR probes on Wi-Fi events while parked or inactive, skipped `40-bananarchy-ims.sh` `dhcp4-change` / `dhcp6-change` / `connectivity-change` notifications when both `VOLTE_ACTIVE` and `VOWIFI_ACTIVE` are `0`, guarded `openCtlSocket()` rebinds in `bananarchy-vowifi`, and replaced its `1.5 s` / `10 s` retry storm with capped exponential backoff (`5 s` to `300 s`).
|
||||||
|
- **Display/lockscreen/cover power-policy sync & idempotency (`overlay/rootfs/usr/bin/bananarchy-display-power-sync`, `bananarchy-power-policy.sh`, `src/dwm-plugins/locker_plugin.cpp`, `30-bananarchy-network-status.sh`)**: synced `CPU_GOV_PATH` (`powersave` when dark or cover-lit, `schedutil` on interactive wake) and `sync_standby_policy()` across both flip and non-flip branches of `bananarchy-display-power-sync`, wired `blankScreenBacklight()` / `wakeScreenBacklight()` in `locker.so` to `/usr/bin/bananarchy-power-policy.sh screenoff|screenon`, made `screenoff()`, `screenon()`, and `arm_rat_park_timer()` idempotent via `$RUNDIR/standby.mode` and `$RUNDIR/rat_timer.pid` across dark/cover-lit/dark cycles, and suppressed `30-bananarchy-network-status.sh` `su user` spawns for noisy `dhcp4-change` / `dhcp6-change` / `dns-change` / `connectivity-change` events while dark.
|
||||||
|
- **QMI NAS signal hysteresis wire-protocol fix (`src/bananarchy-daemons/bananarchy-dsds.c`)**: corrected `apply_sig_hysteresis()` from wrong opcodes `0x006F` (`4`-byte sub) and `0x004F` (`GET_SIGNAL_INFO`) + TLV `0x13` to `QMI_NAS_BIND_SUBSCRIPTION` (`0x0045`, `1`-byte TLV `0x01`) and `QMI_NAS_CONFIG_SIGNAL_INFO` (`0x0050`) with `RSSI` (`0x10`), WCDMA `RSCP` (`0x18`), LTE `RSRP` (`0x16`, 16-bit LE), and `lte_report` (`0x17`, `rate=0`, `avg=5 s` dark / `1 s` wake) verified against `libqmi-glib.so.5.12.0`, suppressing minor standby RF fluctuations from waking APSS over QRTR.
|
||||||
|
- **microSD PM8909 `l11` static `200 mA` load removal (`devices/*/*.dts`, `prebuilt/kernel-6.12.1-msm8916/dtbs/*.dtb`)**: removed static `regulator-system-load = <0x30d40>;` from PM8909 `l11` across all 6 DTS files and recompiled all 5 shipping DTBs so `sdhci@7864000` honors pure `regulator-allow-set-load;` Low-Power Mode when a microSD card is inserted.
|
||||||
|
- **Offline verification (`scripts/test-imsd-volte.py`, `scripts/test-standby-power-policy.py`, `scripts/check-rebuild.sh`, `BATTERY-OPTIMIZATION-ANALYSIS.md`)**: added host regression tests for Combined EPS/IMSI (`cs_attach=1`), `searching_lte`, and 0-packet `2.2 s` QRTR idle silence in `test-imsd-volte.py`; added host tests for `CPU_GOV_PATH` + idempotent `screenoff`/`screenon` across dark/cover-lit/open, `standby.mode`/`rat_timer.pid`, `bananarchy-dsds --sig-hysteresis` QMI `0x0045`/`0x0050` wire framing over `AF_UNIX` `SOCK_SEQPACKET`, and `30-bananarchy-network-status.sh` dark gating in `test-standby-power-policy.py`; guarded DTS/DTBs against `regulator-system-load` in `check-rebuild.sh`; and documented Section 24 in `BATTERY-OPTIMIZATION-ANALYSIS.md`.
|
||||||
- **Rebuilt local image SHA-256 checksums (`--mkinitfs`, no release `.zip` archives built yet)**:
|
- **Rebuilt local image SHA-256 checksums (`--mkinitfs`, no release `.zip` archives built yet)**:
|
||||||
- `images/bananarchy-nokia-argon.img`: `22014270bb62ebc825afe5ef60fe8aefa65776eb9efc511b92e834a61b59fb0e`
|
- `images/bananarchy-nokia-argon.img`: `7ed88928baf8f8926e7213919e304991cd0a30e0166c0b91da610396f606cf37`
|
||||||
- `images/bananarchy-nokia-beatles.img`: `dce127a00efcf1e19aeaa8b21e4f28b33cdd5dd0044dcea0051a2e880c021ef7`
|
- `images/bananarchy-nokia-beatles.img`: `616ef7ceaa3e49b73ff90f14c8d30e658f3e35349549414a78c1f6a15e6f75c2`
|
||||||
- `images/boot-bananarchy-nokia-beatles.img`: `480d6988f57028006ce0227092de077dffe5d6a51dadeedb0ef1f16a9a35a3e0`
|
- `images/boot-bananarchy-nokia-beatles.img`: `a51cf223d3b6231e1a00947f5a084939c54c76d10051a43d37dfd2652d88f99f`
|
||||||
- `images/bananarchy-nokia-coconut.img`: `1d5f20a0f6677748c25eedd044b23bb168ddaee0e4ae71c47ceefc0b0878c86f`
|
- `images/bananarchy-nokia-coconut.img`: `598482a219e235cc323821d8dda5c62d380ec6773b739fdf1c12cf8ad7c6648e`
|
||||||
- `images/boot-bananarchy-nokia-coconut.img`: `7f56459f258857ed0252d0cd81e8fe496e55af2cff48e3cf6defe39a341dfc4a`
|
- `images/boot-bananarchy-nokia-coconut.img`: `f6ba9567d9f57a5503751c023a606eae71a8f68047c03380f68ab488b8ab51b5`
|
||||||
- `images/bananarchy-nokia-sparkler.img`: `99d54d6bc001e97f41dc314bbf012ef266251a70b6663a82260f32b1ffeff9e5`
|
- `images/bananarchy-nokia-sparkler.img`: `d86779df5f38d0d5cd516b9123f17dfbd7ba8874435517146e281382e5998f9a`
|
||||||
- `images/boot-bananarchy-nokia-sparkler.img`: `a57973505f56754be74fdea9536e656af82a93d3d3722dcb61b3c6b6e9f6782b`
|
- `images/boot-bananarchy-nokia-sparkler.img`: `1e6a1659c4ae9a95c29c96a41edf9343535229d583dcec3d2063667c98745fbc`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -402,7 +402,6 @@
|
|||||||
l11 {
|
l11 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
regulator-system-load = <0x30d40>;
|
|
||||||
regulator-allow-set-load;
|
regulator-allow-set-load;
|
||||||
phandle = <0x50>;
|
phandle = <0x50>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -403,7 +403,6 @@
|
|||||||
l11 {
|
l11 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
regulator-system-load = <0x30d40>;
|
|
||||||
regulator-allow-set-load;
|
regulator-allow-set-load;
|
||||||
phandle = <0x50>;
|
phandle = <0x50>;
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
@@ -403,7 +403,6 @@
|
|||||||
l11 {
|
l11 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
regulator-system-load = <0x30d40>;
|
|
||||||
regulator-allow-set-load;
|
regulator-allow-set-load;
|
||||||
phandle = <0x50>;
|
phandle = <0x50>;
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
@@ -405,7 +405,6 @@
|
|||||||
l11 {
|
l11 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
regulator-system-load = <0x30d40>;
|
|
||||||
regulator-allow-set-load;
|
regulator-allow-set-load;
|
||||||
phandle = <0x50>;
|
phandle = <0x50>;
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
@@ -411,7 +411,6 @@
|
|||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
regulator-allow-set-load;
|
regulator-allow-set-load;
|
||||||
regulator-system-load = <0x30d40>;
|
|
||||||
phandle = <0x44>;
|
phandle = <0x44>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -414,7 +414,6 @@
|
|||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
regulator-allow-set-load;
|
regulator-allow-set-load;
|
||||||
regulator-system-load = <0x30d40>;
|
|
||||||
phandle = <0x44>;
|
phandle = <0x44>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -3,9 +3,33 @@
|
|||||||
# "nmcli device monitor" with event-driven Sxmo network/statusbar hooks.
|
# "nmcli device monitor" with event-driven Sxmo network/statusbar hooks.
|
||||||
# The helper re-executes as the X session user so status files stay owned by
|
# The helper re-executes as the X session user so status files stay owned by
|
||||||
# user:user. Double-fork so NetworkManager never waits for shell hooks.
|
# user:user. Double-fork so NetworkManager never waits for shell hooks.
|
||||||
|
is_screen_dark() {
|
||||||
|
_lid="${BANANARCHY_LID_STATE:-/run/bananarchy/lid-state}"
|
||||||
|
_blp="${BANANARCHY_BL_POWER_PATH:-/sys/class/backlight/backlight/bl_power}"
|
||||||
|
_br="${BANANARCHY_BR_PATH:-/sys/class/backlight/backlight/brightness}"
|
||||||
|
if [ -r "$_lid" ]; then
|
||||||
|
_ls=""
|
||||||
|
read -r _ls < "$_lid" 2>/dev/null || _ls=""
|
||||||
|
[ "$_ls" = "closed" ] && return 0
|
||||||
|
fi
|
||||||
|
if [ -r "$_blp" ]; then
|
||||||
|
_bp=""
|
||||||
|
read -r _bp < "$_blp" 2>/dev/null || _bp=""
|
||||||
|
[ -n "$_bp" ] && [ "$_bp" -ne 0 ] 2>/dev/null && return 0
|
||||||
|
fi
|
||||||
|
if [ -r "$_br" ]; then
|
||||||
|
_bv=""
|
||||||
|
read -r _bv < "$_br" 2>/dev/null || _bv=""
|
||||||
|
[ -n "$_bv" ] && [ "$_bv" -le 0 ] 2>/dev/null && return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
case "${2:-}" in
|
case "${2:-}" in
|
||||||
up|down|pre-up|pre-down|vpn-up|vpn-down|vpn-pre-up|vpn-pre-down|\
|
up|down|pre-up|pre-down|vpn-up|vpn-down|vpn-pre-up|vpn-pre-down) ;;
|
||||||
connectivity-change|dhcp4-change|dhcp6-change|dns-change) ;;
|
connectivity-change|dhcp4-change|dhcp6-change|dns-change)
|
||||||
|
is_screen_dark && exit 0
|
||||||
|
;;
|
||||||
*) exit 0 ;;
|
*) exit 0 ;;
|
||||||
esac
|
esac
|
||||||
( su user -s /bin/sh -c \
|
( su user -s /bin/sh -c \
|
||||||
|
|||||||
@@ -2,6 +2,17 @@
|
|||||||
# Notify bananarchy-imsd on interface up/down/connectivity changes without blocking NM.
|
# Notify bananarchy-imsd on interface up/down/connectivity changes without blocking NM.
|
||||||
IFACE="${1:-any}"
|
IFACE="${1:-any}"
|
||||||
EVENT="${2:-change}"
|
EVENT="${2:-change}"
|
||||||
|
IMS_STATE="${BANANARCHY_IMS_STATE_PATH:-/run/bananarchy/ims/state.env}"
|
||||||
|
|
||||||
|
case "$EVENT" in
|
||||||
|
dhcp4-change|dhcp6-change|connectivity-change)
|
||||||
|
if [ -r "$IMS_STATE" ] && \
|
||||||
|
grep -q '^VOLTE_ACTIVE=0$' "$IMS_STATE" 2>/dev/null && \
|
||||||
|
grep -q '^VOWIFI_ACTIVE=0$' "$IMS_STATE" 2>/dev/null; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
case "$EVENT" in
|
case "$EVENT" in
|
||||||
up|down|connectivity-change|dhcp4-change|dhcp6-change)
|
up|down|connectivity-change|dhcp4-change|dhcp6-change)
|
||||||
|
|||||||
@@ -13,12 +13,15 @@ set -u
|
|||||||
BR_PATH=/sys/class/backlight/backlight/brightness
|
BR_PATH=/sys/class/backlight/backlight/brightness
|
||||||
BL_POWER_PATH=/sys/class/backlight/backlight/bl_power
|
BL_POWER_PATH=/sys/class/backlight/backlight/bl_power
|
||||||
KBD_PATH=/sys/class/leds/white:kbd_backlight/brightness
|
KBD_PATH=/sys/class/leds/white:kbd_backlight/brightness
|
||||||
|
CPU_GOV_PATH=/sys/devices/system/cpu/cpufreq/policy0/scaling_governor
|
||||||
RL_PATH=/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us
|
RL_PATH=/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us
|
||||||
GPU_GOV_PATH=/sys/class/devfreq/1c00000.gpu/governor
|
GPU_GOV_PATH=/sys/class/devfreq/1c00000.gpu/governor
|
||||||
WIFI_OFFLOAD_PATH=/sys/module/wcn36xx/parameters/screen_off_offload
|
WIFI_OFFLOAD_PATH=/sys/module/wcn36xx/parameters/screen_off_offload
|
||||||
SPM_SCREEN_OFF_PATH=/sys/module/cpuidle_qcom_spm/parameters/screen_off
|
SPM_SCREEN_OFF_PATH=/sys/module/cpuidle_qcom_spm/parameters/screen_off
|
||||||
SPM_RPM_SLEEP_PATH=/sys/module/cpuidle_qcom_spm/parameters/rpm_sleep
|
SPM_RPM_SLEEP_PATH=/sys/module/cpuidle_qcom_spm/parameters/rpm_sleep
|
||||||
BMS_SCREEN_OFF_PATH=/sys/module/pm8916_bms_vm/parameters/screen_off
|
BMS_SCREEN_OFF_PATH=/sys/module/pm8916_bms_vm/parameters/screen_off
|
||||||
|
POWER_POLICY_SH=/usr/bin/bananarchy-power-policy.sh
|
||||||
|
STANDBY_STATE_FILE=/run/bananarchy/display-standby-state
|
||||||
COVER_MARKER=/run/bananarchy/cover-backlight
|
COVER_MARKER=/run/bananarchy/cover-backlight
|
||||||
FORCE_MARKER=/run/bananarchy/cover-bl-force
|
FORCE_MARKER=/run/bananarchy/cover-bl-force
|
||||||
STATE_CACHE=/run/bananarchy/cover-power-state
|
STATE_CACHE=/run/bananarchy/cover-power-state
|
||||||
@@ -54,12 +57,15 @@ done
|
|||||||
[ -n "${BANANARCHY_BR_PATH:-}" ] && BR_PATH="$BANANARCHY_BR_PATH"
|
[ -n "${BANANARCHY_BR_PATH:-}" ] && BR_PATH="$BANANARCHY_BR_PATH"
|
||||||
[ -n "${BANANARCHY_BL_POWER_PATH:-}" ] && BL_POWER_PATH="$BANANARCHY_BL_POWER_PATH"
|
[ -n "${BANANARCHY_BL_POWER_PATH:-}" ] && BL_POWER_PATH="$BANANARCHY_BL_POWER_PATH"
|
||||||
[ -n "${BANANARCHY_KBD_PATH:-}" ] && KBD_PATH="$BANANARCHY_KBD_PATH"
|
[ -n "${BANANARCHY_KBD_PATH:-}" ] && KBD_PATH="$BANANARCHY_KBD_PATH"
|
||||||
|
[ -n "${BANANARCHY_CPU_GOV_PATH:-}" ] && CPU_GOV_PATH="$BANANARCHY_CPU_GOV_PATH"
|
||||||
[ -n "${BANANARCHY_RL_PATH:-}" ] && RL_PATH="$BANANARCHY_RL_PATH"
|
[ -n "${BANANARCHY_RL_PATH:-}" ] && RL_PATH="$BANANARCHY_RL_PATH"
|
||||||
[ -n "${BANANARCHY_GPU_GOV_PATH:-}" ] && GPU_GOV_PATH="$BANANARCHY_GPU_GOV_PATH"
|
[ -n "${BANANARCHY_GPU_GOV_PATH:-}" ] && GPU_GOV_PATH="$BANANARCHY_GPU_GOV_PATH"
|
||||||
[ -n "${BANANARCHY_WIFI_OFFLOAD_PATH:-}" ] && WIFI_OFFLOAD_PATH="$BANANARCHY_WIFI_OFFLOAD_PATH"
|
[ -n "${BANANARCHY_WIFI_OFFLOAD_PATH:-}" ] && WIFI_OFFLOAD_PATH="$BANANARCHY_WIFI_OFFLOAD_PATH"
|
||||||
[ -n "${BANANARCHY_SPM_SCREEN_OFF_PATH:-}" ] && SPM_SCREEN_OFF_PATH="$BANANARCHY_SPM_SCREEN_OFF_PATH"
|
[ -n "${BANANARCHY_SPM_SCREEN_OFF_PATH:-}" ] && SPM_SCREEN_OFF_PATH="$BANANARCHY_SPM_SCREEN_OFF_PATH"
|
||||||
[ -n "${BANANARCHY_SPM_RPM_SLEEP_PATH:-}" ] && SPM_RPM_SLEEP_PATH="$BANANARCHY_SPM_RPM_SLEEP_PATH"
|
[ -n "${BANANARCHY_SPM_RPM_SLEEP_PATH:-}" ] && SPM_RPM_SLEEP_PATH="$BANANARCHY_SPM_RPM_SLEEP_PATH"
|
||||||
[ -n "${BANANARCHY_BMS_SCREEN_OFF_PATH:-}" ] && BMS_SCREEN_OFF_PATH="$BANANARCHY_BMS_SCREEN_OFF_PATH"
|
[ -n "${BANANARCHY_BMS_SCREEN_OFF_PATH:-}" ] && BMS_SCREEN_OFF_PATH="$BANANARCHY_BMS_SCREEN_OFF_PATH"
|
||||||
|
[ -n "${BANANARCHY_POWER_POLICY_SH:-}" ] && POWER_POLICY_SH="$BANANARCHY_POWER_POLICY_SH"
|
||||||
|
[ -n "${BANANARCHY_STANDBY_STATE_FILE:-}" ] && STANDBY_STATE_FILE="$BANANARCHY_STANDBY_STATE_FILE"
|
||||||
[ -n "${BANANARCHY_LID_STATE:-}" ] && LID_STATE="$BANANARCHY_LID_STATE"
|
[ -n "${BANANARCHY_LID_STATE:-}" ] && LID_STATE="$BANANARCHY_LID_STATE"
|
||||||
[ -n "${BANANARCHY_COVER_MARKER:-}" ] && COVER_MARKER="$BANANARCHY_COVER_MARKER"
|
[ -n "${BANANARCHY_COVER_MARKER:-}" ] && COVER_MARKER="$BANANARCHY_COVER_MARKER"
|
||||||
[ -n "${BANANARCHY_FORCE_MARKER:-}" ] && FORCE_MARKER="$BANANARCHY_FORCE_MARKER"
|
[ -n "${BANANARCHY_FORCE_MARKER:-}" ] && FORCE_MARKER="$BANANARCHY_FORCE_MARKER"
|
||||||
@@ -90,6 +96,27 @@ sync_schedutil_rate_limit() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sync_cpu_governor() {
|
||||||
|
_want="$1"
|
||||||
|
[ -w "$CPU_GOV_PATH" ] && set_if_changed "$CPU_GOV_PATH" "$_want"
|
||||||
|
if [ -z "${BANANARCHY_CPU_GOV_PATH:-}" ]; then
|
||||||
|
for _gov in /sys/devices/system/cpu/cpufreq/policy*/scaling_governor; do
|
||||||
|
[ -w "$_gov" ] && set_if_changed "$_gov" "$_want"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_standby_policy() {
|
||||||
|
_want="$1"
|
||||||
|
[ -x "$POWER_POLICY_SH" ] || return 0
|
||||||
|
_prev=""
|
||||||
|
[ -r "$STANDBY_STATE_FILE" ] && _prev="$(read_value "$STANDBY_STATE_FILE")"
|
||||||
|
[ "$_prev" = "$_want" ] && return 0
|
||||||
|
mkdir -p "$(dirname "$STANDBY_STATE_FILE")" 2>/dev/null || true
|
||||||
|
printf '%s\n' "$_want" > "$STANDBY_STATE_FILE" 2>/dev/null || true
|
||||||
|
"$POWER_POLICY_SH" "$_want" </dev/null >/dev/null 2>&1 &
|
||||||
|
}
|
||||||
|
|
||||||
sync_spm_screen_off() {
|
sync_spm_screen_off() {
|
||||||
_want="$1"
|
_want="$1"
|
||||||
[ -w "$SPM_SCREEN_OFF_PATH" ] || return 0
|
[ -w "$SPM_SCREEN_OFF_PATH" ] || return 0
|
||||||
@@ -125,18 +152,22 @@ case "$br" in ''|*[!0-9]*) br=1 ;; esac
|
|||||||
# display or shared backlight: sync DRM DPMS, GPU devfreq and schedutil directly.
|
# display or shared backlight: sync DRM DPMS, GPU devfreq and schedutil directly.
|
||||||
if [ "$(read_value "$LID_PROFILE")" != "flip" ]; then
|
if [ "$(read_value "$LID_PROFILE")" != "flip" ]; then
|
||||||
if [ "$br" -eq 0 ]; then
|
if [ "$br" -eq 0 ]; then
|
||||||
|
sync_cpu_governor "powersave"
|
||||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
|
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
|
||||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
||||||
sync_bms_screen_off "Y"
|
sync_bms_screen_off "Y"
|
||||||
force_dpms "Off"
|
force_dpms "Off"
|
||||||
sync_spm_screen_off "Y"
|
sync_spm_screen_off "Y"
|
||||||
|
sync_standby_policy "screenoff"
|
||||||
else
|
else
|
||||||
sync_spm_screen_off "N"
|
sync_spm_screen_off "N"
|
||||||
|
sync_cpu_governor "schedutil"
|
||||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
||||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
||||||
sync_bms_screen_off "N"
|
sync_bms_screen_off "N"
|
||||||
force_dpms "On"
|
force_dpms "On"
|
||||||
sync_schedutil_rate_limit "40000"
|
sync_schedutil_rate_limit "40000"
|
||||||
|
sync_standby_policy "screenon"
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@@ -232,8 +263,10 @@ else
|
|||||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
||||||
fi
|
fi
|
||||||
if [ "$DESIRED_DPMS" = "Off" ] || [ "$marker" = "0" ] || [ "$marker" = "1" ]; then
|
if [ "$DESIRED_DPMS" = "Off" ] || [ "$marker" = "0" ] || [ "$marker" = "1" ]; then
|
||||||
|
sync_cpu_governor "powersave"
|
||||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
||||||
else
|
else
|
||||||
|
sync_cpu_governor "schedutil"
|
||||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
||||||
fi
|
fi
|
||||||
if [ "$DESIRED_DPMS" = "Off" ] && [ "$marker" != "0" ] && [ "$marker" != "1" ]; then
|
if [ "$DESIRED_DPMS" = "Off" ] && [ "$marker" != "0" ] && [ "$marker" != "1" ]; then
|
||||||
@@ -248,7 +281,12 @@ force_dpms "$DESIRED_DPMS"
|
|||||||
if [ "$DESIRED_DPMS" = "Off" ]; then
|
if [ "$DESIRED_DPMS" = "Off" ]; then
|
||||||
sync_spm_screen_off "Y"
|
sync_spm_screen_off "Y"
|
||||||
fi
|
fi
|
||||||
sync_schedutil_rate_limit "40000"
|
if [ "$DESIRED_DPMS" = "Off" ] || [ "$marker" = "0" ] || [ "$marker" = "1" ]; then
|
||||||
|
sync_standby_policy "screenoff"
|
||||||
|
else
|
||||||
|
sync_schedutil_rate_limit "40000"
|
||||||
|
sync_standby_policy "screenon"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$FORCE" -eq 1 ]; then
|
if [ "$FORCE" -eq 1 ]; then
|
||||||
printf '%s\n' "$DESIRED_KEY" > "$STATE_CACHE" 2>/dev/null || true
|
printf '%s\n' "$DESIRED_KEY" > "$STATE_CACHE" 2>/dev/null || true
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,6 +13,8 @@ TOKEN="$RUNDIR/token"
|
|||||||
RAT_PARKED="$RUNDIR/rat_parked"
|
RAT_PARKED="$RUNDIR/rat_parked"
|
||||||
RAT_SAVED="$RUNDIR/saved_rat"
|
RAT_SAVED="$RUNDIR/saved_rat"
|
||||||
RAT_TOKEN="$RUNDIR/rat.token"
|
RAT_TOKEN="$RUNDIR/rat.token"
|
||||||
|
RAT_PIDFILE="$RUNDIR/rat_timer.pid"
|
||||||
|
STANDBY_MODE="$RUNDIR/standby.mode"
|
||||||
GSM_UNSUPPORTED="$RUNDIR/gsm_unsupported"
|
GSM_UNSUPPORTED="$RUNDIR/gsm_unsupported"
|
||||||
IPV6_RA_SAVED="$RUNDIR/wlan0_accept_ra"
|
IPV6_RA_SAVED="$RUNDIR/wlan0_accept_ra"
|
||||||
BOOTTOKEN="$RUNDIR/boot.token"
|
BOOTTOKEN="$RUNDIR/boot.token"
|
||||||
@@ -330,6 +332,14 @@ unpark_wifi_rat() {
|
|||||||
|
|
||||||
arm_rat_park_timer() {
|
arm_rat_park_timer() {
|
||||||
if [ "$WIFI_STANDBY_RAT" = "gsm" ] && [ ! -f "$GSM_UNSUPPORTED" ] && [ ! -f "$RAT_PARKED" ]; then
|
if [ "$WIFI_STANDBY_RAT" = "gsm" ] && [ ! -f "$GSM_UNSUPPORTED" ] && [ ! -f "$RAT_PARKED" ]; then
|
||||||
|
if [ -r "$RAT_PIDFILE" ]; then
|
||||||
|
_oldpid=""
|
||||||
|
read -r _oldpid < "$RAT_PIDFILE" 2>/dev/null || _oldpid=""
|
||||||
|
if [ -n "$_oldpid" ] && kill -0 "$_oldpid" 2>/dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
rm -f "$RAT_PIDFILE" 2>/dev/null || true
|
||||||
|
fi
|
||||||
rtok="$(date +%s)-$$"
|
rtok="$(date +%s)-$$"
|
||||||
printf '%s\n' "$rtok" > "$RAT_TOKEN"
|
printf '%s\n' "$rtok" > "$RAT_TOKEN"
|
||||||
(
|
(
|
||||||
@@ -337,13 +347,19 @@ arm_rat_park_timer() {
|
|||||||
[ "$settle_sec" = "0" ] || sleep "$settle_sec"
|
[ "$settle_sec" = "0" ] || sleep "$settle_sec"
|
||||||
cur=""
|
cur=""
|
||||||
[ -r "$RAT_TOKEN" ] && { read -r cur < "$RAT_TOKEN" 2>/dev/null || cur=""; }
|
[ -r "$RAT_TOKEN" ] && { read -r cur < "$RAT_TOKEN" 2>/dev/null || cur=""; }
|
||||||
|
rm -f "$RAT_PIDFILE" 2>/dev/null || true
|
||||||
[ "$cur" = "$rtok" ] || exit 0
|
[ "$cur" = "$rtok" ] || exit 0
|
||||||
"$0" _park_rat >/dev/null 2>&1
|
"$0" _park_rat >/dev/null 2>&1
|
||||||
) </dev/null >/dev/null 2>&1 &
|
) </dev/null >/dev/null 2>&1 &
|
||||||
|
printf '%s\n' "$!" > "$RAT_PIDFILE" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
screenoff() {
|
screenoff() {
|
||||||
|
_cur_mode=""
|
||||||
|
[ -r "$STANDBY_MODE" ] && { read -r _cur_mode < "$STANDBY_MODE" 2>/dev/null || _cur_mode=""; }
|
||||||
|
[ "$_cur_mode" = "screenoff" ] && return 0
|
||||||
|
printf 'screenoff\n' > "$STANDBY_MODE" 2>/dev/null || true
|
||||||
apply_cpu_lpm
|
apply_cpu_lpm
|
||||||
mute_wifi_ipv6_ra
|
mute_wifi_ipv6_ra
|
||||||
apply_modem_drx cached || true
|
apply_modem_drx cached || true
|
||||||
@@ -368,7 +384,16 @@ wifi_up() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
screenon() {
|
screenon() {
|
||||||
rm -f "$TOKEN" "$RAT_TOKEN" 2>/dev/null || true
|
_cur_mode=""
|
||||||
|
[ -r "$STANDBY_MODE" ] && { read -r _cur_mode < "$STANDBY_MODE" 2>/dev/null || _cur_mode=""; }
|
||||||
|
[ "$_cur_mode" = "screenon" ] && return 0
|
||||||
|
printf 'screenon\n' > "$STANDBY_MODE" 2>/dev/null || true
|
||||||
|
if [ -r "$RAT_PIDFILE" ]; then
|
||||||
|
_oldpid=""
|
||||||
|
read -r _oldpid < "$RAT_PIDFILE" 2>/dev/null || _oldpid=""
|
||||||
|
[ -n "$_oldpid" ] && kill "$_oldpid" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
rm -f "$TOKEN" "$RAT_TOKEN" "$RAT_PIDFILE" 2>/dev/null || true
|
||||||
set_spm_bool "$SPM_PARAM_DIR/screen_off" 0
|
set_spm_bool "$SPM_PARAM_DIR/screen_off" 0
|
||||||
apply_cpu_lpm
|
apply_cpu_lpm
|
||||||
restore_wifi_ipv6_ra
|
restore_wifi_ipv6_ra
|
||||||
@@ -406,7 +431,7 @@ modem_ready() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boot() {
|
boot() {
|
||||||
rm -f "$TOKEN" "$RAT_TOKEN" "$PARKED" "$AIDFILE" "$SLOTFILE" "$RAT_PARKED" "$RAT_SAVED" "$GSM_UNSUPPORTED" "$IPV6_RA_SAVED" "$READYSTAMP" "$RUNDIR"/drx.wwan* 2>/dev/null || true
|
rm -f "$TOKEN" "$RAT_TOKEN" "$RAT_PIDFILE" "$STANDBY_MODE" "$PARKED" "$AIDFILE" "$SLOTFILE" "$RAT_PARKED" "$RAT_SAVED" "$GSM_UNSUPPORTED" "$IPV6_RA_SAVED" "$READYSTAMP" "$RUNDIR"/drx.wwan* 2>/dev/null || true
|
||||||
write_modprobe || true
|
write_modprobe || true
|
||||||
apply_cpu_lpm
|
apply_cpu_lpm
|
||||||
if [ "$MODEM_DRX_MODE" != "0" ]; then
|
if [ "$MODEM_DRX_MODE" != "0" ]; then
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -564,15 +564,15 @@ fi
|
|||||||
|
|
||||||
echo "[check] Known-good flashable image set..."
|
echo "[check] Known-good flashable image set..."
|
||||||
for pair in \
|
for pair in \
|
||||||
"22014270bb62ebc825afe5ef60fe8aefa65776eb9efc511b92e834a61b59fb0e images/bananarchy-nokia-argon.img" \
|
"7ed88928baf8f8926e7213919e304991cd0a30e0166c0b91da610396f606cf37 images/bananarchy-nokia-argon.img" \
|
||||||
"dce127a00efcf1e19aeaa8b21e4f28b33cdd5dd0044dcea0051a2e880c021ef7 images/bananarchy-nokia-beatles.img" \
|
"616ef7ceaa3e49b73ff90f14c8d30e658f3e35349549414a78c1f6a15e6f75c2 images/bananarchy-nokia-beatles.img" \
|
||||||
"480d6988f57028006ce0227092de077dffe5d6a51dadeedb0ef1f16a9a35a3e0 images/boot-bananarchy-nokia-beatles.img" \
|
"a51cf223d3b6231e1a00947f5a084939c54c76d10051a43d37dfd2652d88f99f images/boot-bananarchy-nokia-beatles.img" \
|
||||||
"f13db705a714aaebd2d8fcc2e0f7266d0e40268c0a276208117dfdf9d8f45351 images/boot-lk2nd-nokia-beatles-display.img" \
|
"f13db705a714aaebd2d8fcc2e0f7266d0e40268c0a276208117dfdf9d8f45351 images/boot-lk2nd-nokia-beatles-display.img" \
|
||||||
"1d5f20a0f6677748c25eedd044b23bb168ddaee0e4ae71c47ceefc0b0878c86f images/bananarchy-nokia-coconut.img" \
|
"598482a219e235cc323821d8dda5c62d380ec6773b739fdf1c12cf8ad7c6648e images/bananarchy-nokia-coconut.img" \
|
||||||
"7f56459f258857ed0252d0cd81e8fe496e55af2cff48e3cf6defe39a341dfc4a images/boot-bananarchy-nokia-coconut.img" \
|
"f6ba9567d9f57a5503751c023a606eae71a8f68047c03380f68ab488b8ab51b5 images/boot-bananarchy-nokia-coconut.img" \
|
||||||
"9a5bd2da6cfd95c745d9c1acb2e3bc61afa339824810e3d160bf079e17b23192 images/boot-lk2nd-nokia-coconut-display.img" \
|
"9a5bd2da6cfd95c745d9c1acb2e3bc61afa339824810e3d160bf079e17b23192 images/boot-lk2nd-nokia-coconut-display.img" \
|
||||||
"99d54d6bc001e97f41dc314bbf012ef266251a70b6663a82260f32b1ffeff9e5 images/bananarchy-nokia-sparkler.img" \
|
"d86779df5f38d0d5cd516b9123f17dfbd7ba8874435517146e281382e5998f9a images/bananarchy-nokia-sparkler.img" \
|
||||||
"a57973505f56754be74fdea9536e656af82a93d3d3722dcb61b3c6b6e9f6782b images/boot-bananarchy-nokia-sparkler.img" \
|
"1e6a1659c4ae9a95c29c96a41edf9343535229d583dcec3d2063667c98745fbc images/boot-bananarchy-nokia-sparkler.img" \
|
||||||
"120ade81bc5416263a1afd95a29981675358b98516e105e5ed611edf258a29f7 images/boot-lk2nd-nokia-sparkler-display.img"; do
|
"120ade81bc5416263a1afd95a29981675358b98516e105e5ed611edf258a29f7 images/boot-lk2nd-nokia-sparkler-display.img"; do
|
||||||
set -- $pair
|
set -- $pair
|
||||||
want=$1
|
want=$1
|
||||||
@@ -1630,6 +1630,8 @@ for dts in \
|
|||||||
! grep -qF 'interconnect-names = "gfx-mem";' "$dts" || \
|
! grep -qF 'interconnect-names = "gfx-mem";' "$dts" || \
|
||||||
! grep -qF 'opp-peak-kBps = <0x25800>;' "$dts"; then
|
! grep -qF 'opp-peak-kBps = <0x25800>;' "$dts"; then
|
||||||
fail "${dts#"$BASE_DIR/"} is missing MSM8909 interconnect/GPU-BIMC/OPP bandwidth nodes or 0x25800 floor"
|
fail "${dts#"$BASE_DIR/"} is missing MSM8909 interconnect/GPU-BIMC/OPP bandwidth nodes or 0x25800 floor"
|
||||||
|
elif grep -qF 'regulator-system-load' "$dts"; then
|
||||||
|
fail "${dts#"$BASE_DIR/"} still sets static regulator-system-load instead of pure set_load"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if ! grep -qxF 'MODEM_DRX_MODE=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
if ! grep -qxF 'MODEM_DRX_MODE=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
||||||
@@ -1666,6 +1668,12 @@ if ! grep -qxF 'MODEM_DRX_MODE=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power
|
|||||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
! grep -qF 'sync_spm_screen_off' \
|
! grep -qF 'sync_spm_screen_off' \
|
||||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
|
! grep -qF 'CPU_GOV_PATH=/sys/devices/system/cpu/cpufreq/policy0/scaling_governor' \
|
||||||
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
|
! grep -qF 'sync_cpu_governor' \
|
||||||
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
|
! grep -qF 'sync_standby_policy' \
|
||||||
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
! grep -qF 'sync_schedutil_rate_limit' \
|
! grep -qF 'sync_schedutil_rate_limit' \
|
||||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync"; then
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync"; then
|
||||||
fail "userspace DSDS DRX, compiled C daemons, CPU/L2/Wi-Fi power policy, or wcn36xx screen_off_offload sync is missing"
|
fail "userspace DSDS DRX, compiled C daemons, CPU/L2/Wi-Fi power policy, or wcn36xx screen_off_offload sync is missing"
|
||||||
@@ -2502,6 +2510,8 @@ if command -v dtc >/dev/null 2>&1; then
|
|||||||
fail "failed to decompile ${dtb#"$BASE_DIR/"}"
|
fail "failed to decompile ${dtb#"$BASE_DIR/"}"
|
||||||
elif printf "%s\n" "$dec_dts" | grep -qE 'cd-gpios|broken-cd'; then
|
elif printf "%s\n" "$dec_dts" | grep -qE 'cd-gpios|broken-cd'; then
|
||||||
fail "${dtb#"$BASE_DIR/"} still contains cd-gpios or broken-cd"
|
fail "${dtb#"$BASE_DIR/"} still contains cd-gpios or broken-cd"
|
||||||
|
elif printf "%s\n" "$dec_dts" | grep -qF 'regulator-system-load'; then
|
||||||
|
fail "${dtb#"$BASE_DIR/"} still contains static regulator-system-load"
|
||||||
elif [ "$(printf "%s\n" "$dec_dts" | grep -c 'non-removable;' || echo 0)" -lt 2 ]; then
|
elif [ "$(printf "%s\n" "$dec_dts" | grep -c 'non-removable;' || echo 0)" -lt 2 ]; then
|
||||||
fail "${dtb#"$BASE_DIR/"} is missing non-removable; on sdhci@7864000"
|
fail "${dtb#"$BASE_DIR/"} is missing non-removable; on sdhci@7864000"
|
||||||
fi
|
fi
|
||||||
@@ -2740,6 +2750,12 @@ if ! grep -qF 'libmm-wds-bind.so' "$BASE_DIR/overlay/rootfs/etc/init.d/modemmana
|
|||||||
! grep -qF 'close_imsdcm' "$BASE_DIR/src/bananarchy-daemons/bananarchy-imsd.c"; then
|
! grep -qF 'close_imsdcm' "$BASE_DIR/src/bananarchy-daemons/bananarchy-imsd.c"; then
|
||||||
fail "LTE mobile data WDS bind, restore-dsds, mobile-data-prep, or close_imsdcm guard missing"
|
fail "LTE mobile data WDS bind, restore-dsds, mobile-data-prep, or close_imsdcm guard missing"
|
||||||
fi
|
fi
|
||||||
|
if ! grep -qF 'cs_attach' "$BASE_DIR/src/bananarchy-daemons/ims_qrtr.h" || \
|
||||||
|
! grep -qF 'close_qrtr' "$BASE_DIR/src/bananarchy-daemons/bananarchy-imsd.c" || \
|
||||||
|
! grep -qF '0x0050' "$BASE_DIR/src/bananarchy-daemons/bananarchy-dsds.c" || \
|
||||||
|
! grep -qF 'is_screen_dark' "$BASE_DIR/overlay/rootfs/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh"; then
|
||||||
|
fail "standby battery regression guards (cs_attach, close_qrtr, QMI 0x0050, or dark dispatcher gate) missing"
|
||||||
|
fi
|
||||||
if ! grep -qF 'bananarchy-imsctl' "$BASE_DIR/overlay/rootfs/etc/doas.d/50-sxmo.conf" || \
|
if ! grep -qF 'bananarchy-imsctl' "$BASE_DIR/overlay/rootfs/etc/doas.d/50-sxmo.conf" || \
|
||||||
! grep -qF 'bananarchy-ims-bearer.sh' "$BASE_DIR/overlay/rootfs/etc/doas.d/50-sxmo.conf" || \
|
! grep -qF 'bananarchy-ims-bearer.sh' "$BASE_DIR/overlay/rootfs/etc/doas.d/50-sxmo.conf" || \
|
||||||
! grep -qF 'isMbnExt' "$BASE_DIR/src/dwm-plugins/files_plugin.cpp" || \
|
! grep -qF 'isMbnExt' "$BASE_DIR/src/dwm-plugins/files_plugin.cpp" || \
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ class MockQrtrRouter:
|
|||||||
|
|
||||||
# Configurable modem simulation state
|
# Configurable modem simulation state
|
||||||
self.lte_only = False
|
self.lte_only = False
|
||||||
|
self.serving_mode = "mixed"
|
||||||
|
self.qrtr_rx_pkts = 0
|
||||||
self.has_ims_qmi = True
|
self.has_ims_qmi = True
|
||||||
self.imsa_reg = True
|
self.imsa_reg = True
|
||||||
self.pdc_chunks = bytearray()
|
self.pdc_chunks = bytearray()
|
||||||
@@ -111,14 +113,20 @@ class MockQrtrRouter:
|
|||||||
if svc_port == 100 + SVC_NAS:
|
if svc_port == 100 + SVC_NAS:
|
||||||
if msg_id == 0x0024:
|
if msg_id == 0x0024:
|
||||||
# Serving system
|
# Serving system
|
||||||
if self.lte_only:
|
mode = "lte_only" if self.lte_only else self.serving_mode
|
||||||
srv = struct.pack("<BBBBBB", 1, 0, 1, 0, 1, 0x08) # LTE only, no CS
|
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:
|
else:
|
||||||
srv = struct.pack("<BBBBBBB", 1, 1, 1, 0, 2, 0x08, 0x05) # LTE + UMTS
|
srv = struct.pack("<BBBBBBB", 1, 1, 1, 0, 2, 0x08, 0x05) # LTE + UMTS
|
||||||
plmn = struct.pack("<HHB", 240, 1, 0)
|
plmn = struct.pack("<HHB", 240, 1, 0)
|
||||||
return pack_qmi_rsp(txn_id, msg_id, tlv(0x01, srv) + tlv(0x12, plmn))
|
return pack_qmi_rsp(txn_id, msg_id, tlv(0x01, srv) + tlv(0x12, plmn))
|
||||||
if msg_id == 0x0034:
|
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)))
|
return pack_qmi_rsp(txn_id, msg_id, tlv(0x11, struct.pack("<H", mask)))
|
||||||
elif svc_port == 100 + SVC_DSD:
|
elif svc_port == 100 + SVC_DSD:
|
||||||
if msg_id == 0x0051:
|
if msg_id == 0x0051:
|
||||||
@@ -233,6 +241,10 @@ class MockQrtrRouter:
|
|||||||
else:
|
else:
|
||||||
sn, sp = self.clients[conn]
|
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:
|
if mtype == MSG_LOOKUP:
|
||||||
rn, rp = self._lookup_addr(svc)
|
rn, rp = self._lookup_addr(svc)
|
||||||
self._send_mock_pkt(conn, MSG_LOOKUP, 0, 0, rn, rp, svc, inst)
|
self._send_mock_pkt(conn, MSG_LOOKUP, 0, 0, rn, rp, svc, inst)
|
||||||
@@ -413,7 +425,33 @@ fi
|
|||||||
if vowifi_log.exists():
|
if vowifi_log.exists():
|
||||||
return fail("vowifi must not start when network is not 4G-only")
|
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:
|
with router.lock:
|
||||||
router.lte_only = True
|
router.lte_only = True
|
||||||
subprocess.run([str(ctl_bin), "notify", "wwan0", "up"], env=env, check=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}")
|
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:
|
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}")
|
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!
|
# 3) Install + activate SW MBN through imsctl -> chunked QMI_PDC upload!
|
||||||
sw_bytes = test_mbn_mod.build_synthetic_mbn(desc="MockCarrier-4G")
|
sw_bytes = test_mbn_mod.build_synthetic_mbn(desc="MockCarrier-4G")
|
||||||
|
|||||||
@@ -404,10 +404,315 @@ def test_bms_screen_off_sync(tmp):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_display_power_sync_standby(tmp):
|
||||||
|
work = tmp / "sync_standby"
|
||||||
|
work.mkdir()
|
||||||
|
prof = work / "lid-profile"
|
||||||
|
lid = work / "lid-state"
|
||||||
|
br = work / "brightness"
|
||||||
|
blp = work / "bl_power"
|
||||||
|
kbd = work / "kbd"
|
||||||
|
dpms = work / "dpms"
|
||||||
|
gpu = work / "gpu"
|
||||||
|
cpu_gov = work / "cpu_gov"
|
||||||
|
offload = work / "offload"
|
||||||
|
spm_screen = work / "spm_screen"
|
||||||
|
spm_rpm = work / "spm_rpm"
|
||||||
|
bms = work / "bms"
|
||||||
|
marker = work / "cover-backlight"
|
||||||
|
force = work / "cover-bl-force"
|
||||||
|
cache = work / "cover-power-state"
|
||||||
|
standby_state = work / "display-standby-state"
|
||||||
|
policy_log = work / "policy.log"
|
||||||
|
mock_policy = work / "mock-policy.sh"
|
||||||
|
write_text(mock_policy, f"#!/bin/sh\nprintf '%s\\n' \"$1\" >> \"{policy_log}\"\n")
|
||||||
|
mock_policy.chmod(0o755)
|
||||||
|
|
||||||
|
write_text(prof, "flip\n")
|
||||||
|
write_text(lid, "closed\n")
|
||||||
|
write_text(br, "0\n")
|
||||||
|
write_text(blp, "4\n")
|
||||||
|
write_text(kbd, "0\n")
|
||||||
|
write_text(dpms, "Off\n")
|
||||||
|
write_text(gpu, "simple_ondemand\n")
|
||||||
|
write_text(cpu_gov, "schedutil\n")
|
||||||
|
write_text(offload, "N\n")
|
||||||
|
write_text(spm_screen, "N\n")
|
||||||
|
write_text(spm_rpm, "Y\n")
|
||||||
|
write_text(bms, "N\n")
|
||||||
|
|
||||||
|
env = dict(os.environ)
|
||||||
|
env.update({
|
||||||
|
"BANANARCHY_LID_PROFILE": str(prof),
|
||||||
|
"BANANARCHY_LID_STATE": str(lid),
|
||||||
|
"BANANARCHY_LID_GATE": "/bin/false",
|
||||||
|
"BANANARCHY_BR_PATH": str(br),
|
||||||
|
"BANANARCHY_BL_POWER_PATH": str(blp),
|
||||||
|
"BANANARCHY_KBD_PATH": str(kbd),
|
||||||
|
"BANANARCHY_DPMS_PATH": str(dpms),
|
||||||
|
"BANANARCHY_GPU_GOV_PATH": str(gpu),
|
||||||
|
"BANANARCHY_CPU_GOV_PATH": str(cpu_gov),
|
||||||
|
"BANANARCHY_WIFI_OFFLOAD_PATH": str(offload),
|
||||||
|
"BANANARCHY_SPM_SCREEN_OFF_PATH": str(spm_screen),
|
||||||
|
"BANANARCHY_SPM_RPM_SLEEP_PATH": str(spm_rpm),
|
||||||
|
"BANANARCHY_BMS_SCREEN_OFF_PATH": str(bms),
|
||||||
|
"BANANARCHY_POWER_POLICY_SH": str(mock_policy),
|
||||||
|
"BANANARCHY_STANDBY_STATE_FILE": str(standby_state),
|
||||||
|
"BANANARCHY_COVER_MARKER": str(marker),
|
||||||
|
"BANANARCHY_FORCE_MARKER": str(force),
|
||||||
|
"BANANARCHY_STATE_CACHE": str(cache),
|
||||||
|
"BANANARCHY_DPMS_FORCE_BIN": "/bin/true",
|
||||||
|
})
|
||||||
|
|
||||||
|
def wait_log_len(n):
|
||||||
|
deadline = time.time() + 1.5
|
||||||
|
while time.time() < deadline:
|
||||||
|
if len(read_lines(policy_log)) >= n:
|
||||||
|
return True
|
||||||
|
time.sleep(0.02)
|
||||||
|
return len(read_lines(policy_log)) >= n
|
||||||
|
|
||||||
|
# 1) Dark closed flip -> powersave + screenoff once.
|
||||||
|
res = subprocess.run(["sh", str(DISPLAY_SYNC_SH)], env=env, capture_output=True, text=True)
|
||||||
|
if res.returncode != 0 or cpu_gov.read_text().strip() != "powersave":
|
||||||
|
return fail(f"display-power-sync dark failed: rc={res.returncode} gov={cpu_gov.read_text()!r}")
|
||||||
|
if not wait_log_len(1) or read_lines(policy_log) != ["screenoff"]:
|
||||||
|
return fail(f"expected single screenoff on dark, got {read_lines(policy_log)}")
|
||||||
|
|
||||||
|
# 2) Cover-lit while closed -> stay powersave & idempotent screenoff (no re-call).
|
||||||
|
write_text(marker, "1\n")
|
||||||
|
res = subprocess.run(["sh", str(DISPLAY_SYNC_SH)], env=env, capture_output=True, text=True)
|
||||||
|
time.sleep(0.15)
|
||||||
|
if res.returncode != 0 or cpu_gov.read_text().strip() != "powersave" or offload.read_text().strip() != "Y":
|
||||||
|
return fail(f"cover-lit regressed cpu_gov={cpu_gov.read_text()!r} offload={offload.read_text()!r}")
|
||||||
|
if read_lines(policy_log) != ["screenoff"]:
|
||||||
|
return fail(f"cover-lit must keep screenoff idempotent, got {read_lines(policy_log)}")
|
||||||
|
|
||||||
|
# 3) Back to dark while closed -> still no duplicate screenoff.
|
||||||
|
marker.unlink()
|
||||||
|
subprocess.run(["sh", str(DISPLAY_SYNC_SH)], env=env, capture_output=True, text=True)
|
||||||
|
time.sleep(0.15)
|
||||||
|
if read_lines(policy_log) != ["screenoff"]:
|
||||||
|
return fail(f"cover->dark must not re-fire screenoff, got {read_lines(policy_log)}")
|
||||||
|
|
||||||
|
# 4) Open flip -> schedutil + screenon once.
|
||||||
|
write_text(lid, "open\n")
|
||||||
|
write_text(br, "100\n")
|
||||||
|
write_text(blp, "0\n")
|
||||||
|
env["BANANARCHY_LID_GATE"] = "/bin/true"
|
||||||
|
res = subprocess.run(["sh", str(DISPLAY_SYNC_SH)], env=env, capture_output=True, text=True)
|
||||||
|
if res.returncode != 0 or cpu_gov.read_text().strip() != "schedutil":
|
||||||
|
return fail(f"open wake failed: rc={res.returncode} gov={cpu_gov.read_text()!r}")
|
||||||
|
if not wait_log_len(2) or read_lines(policy_log) != ["screenoff", "screenon"]:
|
||||||
|
return fail(f"expected ['screenoff', 'screenon'], got {read_lines(policy_log)}")
|
||||||
|
|
||||||
|
print("[ok] bananarchy-display-power-sync enforces CPU_GOV_PATH and idempotent screenoff/screenon across dark/cover-lit/open")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_power_policy_idempotent_screen(tmp):
|
||||||
|
work = tmp / "idem"
|
||||||
|
work.mkdir()
|
||||||
|
conf = work / "power.conf"
|
||||||
|
rundir = work / "run"
|
||||||
|
sysfs = work / "sys"
|
||||||
|
spm = sysfs / "spm"
|
||||||
|
lpm = sysfs / "lpm"
|
||||||
|
net_ra = work / "accept_ra"
|
||||||
|
reg_file = work / "reg"
|
||||||
|
write_text(reg_file, "registered\n")
|
||||||
|
mock_qmi, qmi_log, pref_file = make_mock_qmicli(work, reg_file)
|
||||||
|
write_text(pref_file, "gsm, umts, lte\n")
|
||||||
|
write_text(conf, (
|
||||||
|
"MODEM_DRX_MODE=0\nDSDS_SECONDARY_MODE=active\nDSDS_PARK_DELAY=30\n"
|
||||||
|
"CPU_RPM_SLEEP=0\nCPU_L2_SLEEP=0\nWIFI_LISTEN_INTERVAL=8\n"
|
||||||
|
"WIFI_SCREEN_OFF_IPV6_MUTE=1\nWIFI_STANDBY_RAT=gsm\n"
|
||||||
|
))
|
||||||
|
mock_dsds = work / "mock_dsds"
|
||||||
|
dsds_log = work / "dsds.log"
|
||||||
|
write_text(mock_dsds, f"#!/bin/sh\nprintf '%s\\n' \"$*\" >> \"{dsds_log}\"\n")
|
||||||
|
mock_dsds.chmod(0o755)
|
||||||
|
spm.mkdir(parents=True)
|
||||||
|
lpm.mkdir(parents=True)
|
||||||
|
write_text(spm / "screen_off", "N\n")
|
||||||
|
write_text(spm / "rpm_sleep", "N\n")
|
||||||
|
write_text(lpm / "sleep_disabled", "0\n")
|
||||||
|
write_text(net_ra, "1\n")
|
||||||
|
env = dict(os.environ)
|
||||||
|
env.update({
|
||||||
|
"BANANARCHY_POWER_NO_ROOT": "1",
|
||||||
|
"BANANARCHY_POWER_CONF": str(conf),
|
||||||
|
"BANANARCHY_POWER_RUNDIR": str(rundir),
|
||||||
|
"BANANARCHY_SPM_PARAM_DIR": str(spm),
|
||||||
|
"BANANARCHY_ACCEPT_RA_PATH": str(net_ra),
|
||||||
|
"BANANARCHY_WIFI_OFFLOAD_PATH": str(work / "offload"),
|
||||||
|
"BANANARCHY_WIFI_LISTEN_SYSFS": str(work / "listen"),
|
||||||
|
"BANANARCHY_CALLS_DIR": str(work / "calls"),
|
||||||
|
"BANANARCHY_DSDS_BIN": str(mock_dsds),
|
||||||
|
"BANANARCHY_QMICLI_BIN": str(mock_qmi),
|
||||||
|
"BANANARCHY_RAT_SETTLE_SEC": "10",
|
||||||
|
"BANANARCHY_SCREEN_OFF_FILE": str(work / "dark"),
|
||||||
|
"BANANARCHY_WLAN_OPERSTATE_PATH": str(work / "wlan_up"),
|
||||||
|
})
|
||||||
|
write_text(work / "dark", "screenoff\n")
|
||||||
|
write_text(work / "wlan_up", "up\n")
|
||||||
|
res = run_policy(env, "screenoff")
|
||||||
|
if res.returncode != 0 or (rundir / "standby.mode").read_text().strip() != "screenoff":
|
||||||
|
return fail(f"screenoff failed: rc={res.returncode} err={res.stderr}")
|
||||||
|
pidfile = rundir / "rat_timer.pid"
|
||||||
|
if not pidfile.is_file():
|
||||||
|
return fail("missing rat_timer.pid after screenoff")
|
||||||
|
first_pid = pidfile.read_text().strip()
|
||||||
|
dsds_cnt = len(read_lines(dsds_log))
|
||||||
|
if dsds_cnt != 1:
|
||||||
|
return fail(f"expected 1 dsds call on first screenoff, got {dsds_cnt}")
|
||||||
|
res2 = run_policy(env, "screenoff")
|
||||||
|
if res2.returncode != 0 or pidfile.read_text().strip() != first_pid or len(read_lines(dsds_log)) != 1:
|
||||||
|
return fail("duplicate screenoff respawned rat timer or dsds call")
|
||||||
|
res3 = run_policy(env, "screenon")
|
||||||
|
if res3.returncode != 0 or (rundir / "standby.mode").read_text().strip() != "screenon" or pidfile.exists():
|
||||||
|
return fail("screenon did not clear standby.mode or rat_timer.pid")
|
||||||
|
print("[ok] bananarchy-power-policy.sh screenoff/screenon and rat_timer.pid are idempotent")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_dsds_sig_hysteresis_qmi(tmp):
|
||||||
|
import socket
|
||||||
|
import struct
|
||||||
|
import threading
|
||||||
|
|
||||||
|
work = tmp / "dsds_sig"
|
||||||
|
work.mkdir()
|
||||||
|
exe = work / "bananarchy-dsds"
|
||||||
|
src = BASE / "src/bananarchy-daemons/bananarchy-dsds.c"
|
||||||
|
bld = subprocess.run(
|
||||||
|
["gcc", "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror", "-I" + str(src.parent), str(src), "-o", str(exe)],
|
||||||
|
capture_output=True, text=True,
|
||||||
|
)
|
||||||
|
if bld.returncode != 0:
|
||||||
|
return fail(f"host gcc build of bananarchy-dsds failed: {bld.stderr}")
|
||||||
|
|
||||||
|
sock_path = work / "sig.sock"
|
||||||
|
captured = []
|
||||||
|
stop = threading.Event()
|
||||||
|
srv = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
|
||||||
|
srv.bind(str(sock_path))
|
||||||
|
srv.listen(4)
|
||||||
|
srv.settimeout(0.1)
|
||||||
|
|
||||||
|
def serve():
|
||||||
|
while not stop.is_set():
|
||||||
|
try:
|
||||||
|
conn, _ = srv.accept()
|
||||||
|
except TimeoutError:
|
||||||
|
continue
|
||||||
|
except OSError:
|
||||||
|
break
|
||||||
|
with conn:
|
||||||
|
while True:
|
||||||
|
pkt = conn.recv(4096)
|
||||||
|
if not pkt:
|
||||||
|
break
|
||||||
|
captured.append(pkt)
|
||||||
|
txn, msg_id = struct.unpack_from("<HH", pkt, 1)
|
||||||
|
rsp_tlv = struct.pack("<BH", 0x02, 4) + struct.pack("<HH", 0, 0)
|
||||||
|
conn.send(struct.pack("<BHHH", 0x02, txn, msg_id, len(rsp_tlv)) + rsp_tlv)
|
||||||
|
|
||||||
|
th = threading.Thread(target=serve, daemon=True)
|
||||||
|
th.start()
|
||||||
|
try:
|
||||||
|
env = dict(os.environ, BANANARCHY_DSDS_SIG_MOCK_SOCK=str(sock_path))
|
||||||
|
for mode in ("dark", "wake"):
|
||||||
|
res = subprocess.run([str(exe), "--sig-hysteresis", mode], env=env, capture_output=True, text=True)
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"bananarchy-dsds --sig-hysteresis {mode} failed: {res.stderr}")
|
||||||
|
finally:
|
||||||
|
stop.set()
|
||||||
|
th.join(timeout=2)
|
||||||
|
srv.close()
|
||||||
|
|
||||||
|
if len(captured) != 8:
|
||||||
|
return fail(f"expected 8 QMI packets (dark+wake x 2 subs), got {len(captured)}")
|
||||||
|
|
||||||
|
def parse_tlvs(buf):
|
||||||
|
out = {}
|
||||||
|
off = 7
|
||||||
|
while off + 3 <= len(buf):
|
||||||
|
t, l = struct.unpack_from("<BH", buf, off)
|
||||||
|
off += 3
|
||||||
|
out[t] = buf[off:off + l]
|
||||||
|
off += l
|
||||||
|
return out
|
||||||
|
|
||||||
|
for idx, expected_sub in ((0, 0), (2, 1), (4, 0), (6, 1)):
|
||||||
|
msg_id = struct.unpack_from("<H", captured[idx], 3)[0]
|
||||||
|
tlvs = parse_tlvs(captured[idx])
|
||||||
|
if msg_id != 0x0045 or tlvs.get(0x01) != bytes([expected_sub]):
|
||||||
|
return fail(f"pkt {idx} expected QMI_NAS_BIND_SUBSCRIPTION(0x0045, sub={expected_sub}), got msg={msg_id:#x} tlv={tlvs}")
|
||||||
|
cfg_msg = struct.unpack_from("<H", captured[idx + 1], 3)[0]
|
||||||
|
ctlvs = parse_tlvs(captured[idx + 1])
|
||||||
|
if cfg_msg != 0x0050 or not all(k in ctlvs for k in (0x10, 0x16, 0x17, 0x18)):
|
||||||
|
return fail(f"pkt {idx+1} expected QMI_NAS_CONFIG_SIGNAL_INFO(0x0050) with TLVs 0x10/0x16/0x17/0x18, got msg={cfg_msg:#x} keys={list(ctlvs)}")
|
||||||
|
expected_avg = 5 if idx < 4 else 1
|
||||||
|
if ctlvs[0x17] != bytes([0, expected_avg]):
|
||||||
|
return fail(f"pkt {idx+1} expected lte_report=(0,{expected_avg}), got {ctlvs[0x17].hex()}")
|
||||||
|
|
||||||
|
print("[ok] bananarchy-dsds --sig-hysteresis uses QMI 0x0045 + 0x0050 (RSSI/RSCP/RSRP/LTE report)")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_dispatcher_dark_gate(tmp):
|
||||||
|
work = tmp / "nm_gate"
|
||||||
|
work.mkdir()
|
||||||
|
bindir = work / "bin"
|
||||||
|
bindir.mkdir()
|
||||||
|
su_log = work / "su.log"
|
||||||
|
mock_su = bindir / "su"
|
||||||
|
write_text(mock_su, f"#!/bin/sh\nprintf '%s\\n' \"$*\" >> \"{su_log}\"\n")
|
||||||
|
mock_su.chmod(0o755)
|
||||||
|
lid = work / "lid-state"
|
||||||
|
blp = work / "bl_power"
|
||||||
|
br = work / "brightness"
|
||||||
|
disp = BASE / "overlay/rootfs/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh"
|
||||||
|
env = dict(os.environ)
|
||||||
|
env.update({
|
||||||
|
"PATH": f"{bindir}:{env.get('PATH', '')}",
|
||||||
|
"BANANARCHY_LID_STATE": str(lid),
|
||||||
|
"BANANARCHY_BL_POWER_PATH": str(blp),
|
||||||
|
"BANANARCHY_BR_PATH": str(br),
|
||||||
|
})
|
||||||
|
write_text(lid, "open\n")
|
||||||
|
write_text(blp, "4\n")
|
||||||
|
write_text(br, "0\n")
|
||||||
|
subprocess.run(["sh", str(disp), "wlan0", "dhcp4-change"], env=env, check=True)
|
||||||
|
time.sleep(0.15)
|
||||||
|
if su_log.exists():
|
||||||
|
return fail(f"dhcp4-change fired while dark: {su_log.read_text()}")
|
||||||
|
subprocess.run(["sh", str(disp), "wlan0", "up"], env=env, check=True)
|
||||||
|
deadline = time.time() + 1.0
|
||||||
|
while time.time() < deadline and not su_log.exists():
|
||||||
|
time.sleep(0.02)
|
||||||
|
if not su_log.exists():
|
||||||
|
return fail("up event was blocked while dark")
|
||||||
|
su_log.unlink()
|
||||||
|
write_text(blp, "0\n")
|
||||||
|
write_text(br, "100\n")
|
||||||
|
subprocess.run(["sh", str(disp), "wlan0", "dhcp4-change"], env=env, check=True)
|
||||||
|
deadline = time.time() + 1.0
|
||||||
|
while time.time() < deadline and not su_log.exists():
|
||||||
|
time.sleep(0.02)
|
||||||
|
if not su_log.exists():
|
||||||
|
return fail("dhcp4-change was blocked while screen lit")
|
||||||
|
print("[ok] 30-bananarchy-network-status.sh skips noisy change events when screen is dark")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with tempfile.TemporaryDirectory(prefix="bananarchy-standby-test-") as td:
|
with tempfile.TemporaryDirectory(prefix="bananarchy-standby-test-") as td:
|
||||||
tmp = Path(td)
|
tmp = Path(td)
|
||||||
for fn in (test_run_aligned, test_power_policy_rat, test_bms_screen_off_sync):
|
for fn in (test_run_aligned, test_power_policy_rat, test_bms_screen_off_sync,
|
||||||
|
test_display_power_sync_standby, test_power_policy_idempotent_screen,
|
||||||
|
test_dsds_sig_hysteresis_qmi, test_dispatcher_dark_gate):
|
||||||
rc = fn(tmp)
|
rc = fn(tmp)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
return rc
|
return rc
|
||||||
|
|||||||
@@ -1145,8 +1145,9 @@ static int qmi_req(int sock, const struct sockaddr_qrtr *addr, uint16_t txn,
|
|||||||
put_le16(req + 5, (uint16_t)tlvs_len);
|
put_le16(req + 5, (uint16_t)tlvs_len);
|
||||||
if(tlvs_len > 0)
|
if(tlvs_len > 0)
|
||||||
memcpy(req + 7, tlvs, tlvs_len);
|
memcpy(req + 7, tlvs, tlvs_len);
|
||||||
if(sendto(sock, req, 7 + tlvs_len, 0, (const struct sockaddr *)addr,
|
if(sendto(sock, req, 7 + tlvs_len, 0,
|
||||||
sizeof(*addr)) < 0) {
|
addr ? (const struct sockaddr *)addr : NULL,
|
||||||
|
addr ? (socklen_t)sizeof(*addr) : 0) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1952,7 +1953,9 @@ int main(int argc, char **argv)
|
|||||||
#else
|
#else
|
||||||
static int apply_sig_hysteresis(const char *mode)
|
static int apply_sig_hysteresis(const char *mode)
|
||||||
{
|
{
|
||||||
|
const char *mock_path = getenv("BANANARCHY_DSDS_SIG_MOCK_SOCK");
|
||||||
struct sockaddr_qrtr nas_addr;
|
struct sockaddr_qrtr nas_addr;
|
||||||
|
const struct sockaddr_qrtr *target = NULL;
|
||||||
int dark, ns, sub;
|
int dark, ns, sub;
|
||||||
uint16_t txn = 1;
|
uint16_t txn = 1;
|
||||||
|
|
||||||
@@ -1963,39 +1966,62 @@ static int apply_sig_hysteresis(const char *mode)
|
|||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if(lookup_srv(3, &nas_addr) < 0)
|
if(mock_path && *mock_path) {
|
||||||
return 0;
|
struct sockaddr_un sun;
|
||||||
|
size_t mlen = strlen(mock_path);
|
||||||
ns = socket(AF_QIPCRTR, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
if(mlen >= sizeof(sun.sun_path))
|
||||||
if(ns < 0)
|
return 1;
|
||||||
return 0;
|
ns = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
|
||||||
|
if(ns < 0)
|
||||||
|
return 0;
|
||||||
|
memset(&sun, 0, sizeof(sun));
|
||||||
|
sun.sun_family = AF_UNIX;
|
||||||
|
memcpy(sun.sun_path, mock_path, mlen + 1);
|
||||||
|
if(connect(ns, (const struct sockaddr *)&sun, sizeof(sun)) < 0) {
|
||||||
|
close(ns);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(lookup_srv(3, &nas_addr) < 0)
|
||||||
|
return 0;
|
||||||
|
ns = socket(AF_QIPCRTR, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||||
|
if(ns < 0)
|
||||||
|
return 0;
|
||||||
|
target = &nas_addr;
|
||||||
|
}
|
||||||
|
|
||||||
for(sub = 0; sub <= 1; sub++) {
|
for(sub = 0; sub <= 1; sub++) {
|
||||||
uint8_t bind_tlv[7] = { 0x01, 0x04, 0x00, (uint8_t)sub, 0x00, 0x00, 0x00 };
|
uint8_t bind_tlv[4] = { 0x01, 0x01, 0x00, (uint8_t)sub };
|
||||||
uint8_t resp[256];
|
uint8_t resp[256];
|
||||||
size_t rlen = 0;
|
size_t rlen = 0;
|
||||||
|
|
||||||
qmi_req(ns, &nas_addr, txn++, 0x006F, bind_tlv, sizeof(bind_tlv), 150,
|
qmi_req(ns, target, txn++, 0x0045, bind_tlv, sizeof(bind_tlv), 150,
|
||||||
resp, sizeof(resp), &rlen);
|
resp, sizeof(resp), &rlen);
|
||||||
|
|
||||||
if(dark) {
|
if(dark) {
|
||||||
/* Thresholds: RSSI (-105, -75 dBm), LTE RSRP (-120, -90 dBm) to suppress
|
/* Coarse thresholds + rate=0 (threshold-only, avg=5 s) over RSSI, WCDMA
|
||||||
* minor standby radio fluctuations from waking APSS over QRTR. */
|
* RSCP, and LTE RSRP so minor standby fluctuations do not wake APSS. */
|
||||||
uint8_t sig_tlvs[] = {
|
uint8_t sig_tlvs[] = {
|
||||||
0x10, 0x03, 0x00, 0x02, (uint8_t)(int8_t)-105, (uint8_t)(int8_t)-75,
|
0x10, 0x03, 0x00, 0x02, (uint8_t)(int8_t)-105, (uint8_t)(int8_t)-75,
|
||||||
0x13, 0x05, 0x00, 0x02, 0x88, 0xff, 0xa6, 0xff
|
0x18, 0x03, 0x00, 0x02, (uint8_t)(int8_t)-110, (uint8_t)(int8_t)-80,
|
||||||
|
0x16, 0x05, 0x00, 0x02, 0x88, 0xff, 0xa6, 0xff,
|
||||||
|
0x17, 0x02, 0x00, 0x00, 0x05
|
||||||
};
|
};
|
||||||
qmi_req(ns, &nas_addr, txn++, 0x004F, sig_tlvs, sizeof(sig_tlvs), 150,
|
qmi_req(ns, target, txn++, 0x0050, sig_tlvs, sizeof(sig_tlvs), 150,
|
||||||
resp, sizeof(resp), &rlen);
|
resp, sizeof(resp), &rlen);
|
||||||
} else {
|
} else {
|
||||||
uint8_t sig_tlvs[] = {
|
uint8_t sig_tlvs[] = {
|
||||||
0x10, 0x06, 0x00, 0x05,
|
0x10, 0x06, 0x00, 0x05,
|
||||||
(uint8_t)(int8_t)-108, (uint8_t)(int8_t)-98, (uint8_t)(int8_t)-88,
|
(uint8_t)(int8_t)-108, (uint8_t)(int8_t)-98, (uint8_t)(int8_t)-88,
|
||||||
(uint8_t)(int8_t)-78, (uint8_t)(int8_t)-68,
|
(uint8_t)(int8_t)-78, (uint8_t)(int8_t)-68,
|
||||||
0x13, 0x0b, 0x00, 0x05,
|
0x18, 0x06, 0x00, 0x05,
|
||||||
0x88, 0xff, 0x92, 0xff, 0x9c, 0xff, 0xa6, 0xff, 0xb0, 0xff
|
(uint8_t)(int8_t)-112, (uint8_t)(int8_t)-102, (uint8_t)(int8_t)-92,
|
||||||
|
(uint8_t)(int8_t)-82, (uint8_t)(int8_t)-72,
|
||||||
|
0x16, 0x0b, 0x00, 0x05,
|
||||||
|
0x88, 0xff, 0x92, 0xff, 0x9c, 0xff, 0xa6, 0xff, 0xb0, 0xff,
|
||||||
|
0x17, 0x02, 0x00, 0x00, 0x01
|
||||||
};
|
};
|
||||||
qmi_req(ns, &nas_addr, txn++, 0x004F, sig_tlvs, sizeof(sig_tlvs), 150,
|
qmi_req(ns, target, txn++, 0x0050, sig_tlvs, sizeof(sig_tlvs), 150,
|
||||||
resp, sizeof(resp), &rlen);
|
resp, sizeof(resp), &rlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ static int g_bearer_up = 0;
|
|||||||
static int g_baseband_ims_set = 0;
|
static int g_baseband_ims_set = 0;
|
||||||
static int64_t g_baseband_try_since_ms = 0;
|
static int64_t g_baseband_try_since_ms = 0;
|
||||||
static char g_pdc_loaded_id[64] = "";
|
static char g_pdc_loaded_id[64] = "";
|
||||||
|
static char g_dsd_apn_applied[64] = "";
|
||||||
|
static int g_volte_check_retries = 0;
|
||||||
|
static int g_vowifi_sync_retries = 0;
|
||||||
|
static int g_state_written_once = 0;
|
||||||
|
|
||||||
static void wake_sig_pipe(void) {
|
static void wake_sig_pipe(void) {
|
||||||
if (g_sig_pipe[1] >= 0) {
|
if (g_sig_pipe[1] >= 0) {
|
||||||
@@ -227,6 +231,7 @@ static int start_vowifi_child(const char *mode, const char *iface, const char *l
|
|||||||
_exit(127);
|
_exit(127);
|
||||||
}
|
}
|
||||||
g_vowifi_pid = pid;
|
g_vowifi_pid = pid;
|
||||||
|
g_vowifi_sync_retries = 0;
|
||||||
ims_str_copy(g_vowifi_running_mode, sizeof(g_vowifi_running_mode), mode);
|
ims_str_copy(g_vowifi_running_mode, sizeof(g_vowifi_running_mode), mode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -326,6 +331,49 @@ static int ensure_qrtr(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void close_qrtr(void) {
|
||||||
|
if (g_qrtr_ready || g_qrtr.fd >= 0) {
|
||||||
|
ims_qrtr_close(&g_qrtr);
|
||||||
|
g_qrtr_ready = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int is_wifi_rat_parked(void) {
|
||||||
|
const char *rdir = getenv("BANANARCHY_POWER_RUNDIR");
|
||||||
|
char path[PATH_MAX];
|
||||||
|
snprintf(path, sizeof(path), "%s/rat_parked",
|
||||||
|
(rdir && *rdir) ? rdir : "/run/bananarchy-power-policy");
|
||||||
|
return access(path, F_OK) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ims_state_equal(const struct ims_runtime_state *a,
|
||||||
|
const struct ims_runtime_state *b) {
|
||||||
|
return strcmp(a->volte_mode, b->volte_mode) == 0 &&
|
||||||
|
strcmp(a->volte_backend, b->volte_backend) == 0 &&
|
||||||
|
a->volte_active == b->volte_active &&
|
||||||
|
a->volte_registered == b->volte_registered &&
|
||||||
|
a->volte_capable == b->volte_capable &&
|
||||||
|
a->network_4g_only == b->network_4g_only &&
|
||||||
|
strcmp(a->access_tech, b->access_tech) == 0 &&
|
||||||
|
strcmp(a->vowifi_mode, b->vowifi_mode) == 0 &&
|
||||||
|
a->vowifi_active == b->vowifi_active &&
|
||||||
|
a->vowifi_registered == b->vowifi_registered &&
|
||||||
|
a->vowifi_ipv6_epdg == b->vowifi_ipv6_epdg &&
|
||||||
|
a->vowifi_sim == b->vowifi_sim &&
|
||||||
|
strcmp(a->active_mbn, b->active_mbn) == 0 &&
|
||||||
|
strcmp(a->mbn_description, b->mbn_description) == 0 &&
|
||||||
|
strcmp(a->mbn_version, b->mbn_version) == 0 &&
|
||||||
|
strcmp(a->epdg_host, b->epdg_host) == 0 &&
|
||||||
|
strcmp(a->pcscf_addr, b->pcscf_addr) == 0 &&
|
||||||
|
strcmp(a->tun_ip, b->tun_ip) == 0 &&
|
||||||
|
strcmp(a->tun_iface, b->tun_iface) == 0 &&
|
||||||
|
strcmp(a->ims_apn_iface, b->ims_apn_iface) == 0 &&
|
||||||
|
strcmp(a->ims_apn_ip, b->ims_apn_ip) == 0 &&
|
||||||
|
strcmp(a->mcc, b->mcc) == 0 &&
|
||||||
|
strcmp(a->mnc, b->mnc) == 0 &&
|
||||||
|
strcmp(a->last_error, b->last_error) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void ensure_imsdcm(void) {
|
static void ensure_imsdcm(void) {
|
||||||
if (!g_imsdcm_ready || g_imsdcm.fd < 0) {
|
if (!g_imsdcm_ready || g_imsdcm.fd < 0) {
|
||||||
if (ims_qrtr_open(&g_imsdcm) == 0) {
|
if (ims_qrtr_open(&g_imsdcm) == 0) {
|
||||||
@@ -583,16 +631,37 @@ static void sync_mbn_metadata(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reconcile_all(void) {
|
static void reconcile_all(int is_wlan_net_event) {
|
||||||
struct ims_runtime_state prev = g_state;
|
struct ims_runtime_state prev = g_state;
|
||||||
ims_config_load(&g_cfg, NULL);
|
ims_config_load(&g_cfg, NULL);
|
||||||
ims_str_copy(g_state.volte_mode, sizeof(g_state.volte_mode), g_cfg.volte_mode);
|
ims_str_copy(g_state.volte_mode, sizeof(g_state.volte_mode), g_cfg.volte_mode);
|
||||||
ims_str_copy(g_state.vowifi_mode, sizeof(g_state.vowifi_mode), g_cfg.vowifi_mode);
|
ims_str_copy(g_state.vowifi_mode, sizeof(g_state.vowifi_mode), g_cfg.vowifi_mode);
|
||||||
g_state.vowifi_sim = g_cfg.ims_sim_slot;
|
g_state.vowifi_sim = g_cfg.ims_sim_slot;
|
||||||
|
|
||||||
|
int both_off = (strcmp(g_cfg.volte_mode, "off") == 0 &&
|
||||||
|
strcmp(g_cfg.vowifi_mode, "off") == 0);
|
||||||
|
int both_auto_idle = (strcmp(g_cfg.volte_mode, "auto") == 0 &&
|
||||||
|
strcmp(g_cfg.vowifi_mode, "auto") == 0 &&
|
||||||
|
!g_state.volte_active && !g_state.vowifi_active &&
|
||||||
|
(is_wlan_net_event || is_wifi_rat_parked()));
|
||||||
|
|
||||||
int network_4g_only = 0;
|
int network_4g_only = 0;
|
||||||
char tech[32], mcc[8], mnc[8];
|
char tech[32], mcc[8], mnc[8];
|
||||||
detect_network_state(&network_4g_only, tech, sizeof(tech), mcc, mnc);
|
mcc[0] = '\0';
|
||||||
|
mnc[0] = '\0';
|
||||||
|
if (both_off) {
|
||||||
|
ims_str_copy(tech, sizeof(tech), "idle");
|
||||||
|
} else if (both_auto_idle) {
|
||||||
|
if (is_wifi_rat_parked()) {
|
||||||
|
ims_str_copy(tech, sizeof(tech), "gsm");
|
||||||
|
} else if (g_state.access_tech[0]) {
|
||||||
|
ims_str_copy(tech, sizeof(tech), g_state.access_tech);
|
||||||
|
} else {
|
||||||
|
ims_str_copy(tech, sizeof(tech), "unknown");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
detect_network_state(&network_4g_only, tech, sizeof(tech), mcc, mnc);
|
||||||
|
}
|
||||||
g_state.network_4g_only = network_4g_only;
|
g_state.network_4g_only = network_4g_only;
|
||||||
ims_str_copy(g_state.access_tech, sizeof(g_state.access_tech), tech);
|
ims_str_copy(g_state.access_tech, sizeof(g_state.access_tech), tech);
|
||||||
if (mcc[0]) ims_str_copy(g_state.mcc, sizeof(g_state.mcc), mcc);
|
if (mcc[0]) ims_str_copy(g_state.mcc, sizeof(g_state.mcc), mcc);
|
||||||
@@ -619,14 +688,20 @@ static void reconcile_all(void) {
|
|||||||
int effective_vowifi = (strcmp(g_cfg.vowifi_mode, "on") == 0) ||
|
int effective_vowifi = (strcmp(g_cfg.vowifi_mode, "on") == 0) ||
|
||||||
(strcmp(g_cfg.vowifi_mode, "auto") == 0 && network_4g_only == 1);
|
(strcmp(g_cfg.vowifi_mode, "auto") == 0 && network_4g_only == 1);
|
||||||
|
|
||||||
int qrtr_ok = (ensure_qrtr() == 0);
|
int qrtr_ok = 0;
|
||||||
struct ims_qrtr_addr tmp_addr;
|
int has_ims = 0;
|
||||||
int has_ims = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_IMS, 0, 200, &tmp_addr) == 0);
|
int has_imsa = 0;
|
||||||
int has_imsa = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_IMSA, 0, 200, &tmp_addr) == 0);
|
int has_dsd = 0;
|
||||||
int has_dsd = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_DSD, 0, 200, &tmp_addr) == 0);
|
if (effective_volte || effective_vowifi) {
|
||||||
|
qrtr_ok = (ensure_qrtr() == 0);
|
||||||
|
struct ims_qrtr_addr tmp_addr;
|
||||||
|
has_ims = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_IMS, 0, 200, &tmp_addr) == 0);
|
||||||
|
has_imsa = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_IMSA, 0, 200, &tmp_addr) == 0);
|
||||||
|
has_dsd = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_DSD, 0, 200, &tmp_addr) == 0);
|
||||||
|
}
|
||||||
g_state.volte_capable = (has_ims || has_imsa || access(ims_vowifi_bin(), X_OK) == 0) ? 1 : 0;
|
g_state.volte_capable = (has_ims || has_imsa || access(ims_vowifi_bin(), X_OK) == 0) ? 1 : 0;
|
||||||
|
|
||||||
int wifi_up = is_wifi_connected();
|
int wifi_up = (effective_volte || effective_vowifi) ? is_wifi_connected() : 0;
|
||||||
int want_vowifi = (effective_vowifi && wifi_up) ? 1 : 0;
|
int want_vowifi = (effective_vowifi && wifi_up) ? 1 : 0;
|
||||||
int want_userspace_volte = 0;
|
int want_userspace_volte = 0;
|
||||||
|
|
||||||
@@ -636,8 +711,11 @@ static void reconcile_all(void) {
|
|||||||
if (strcmp(g_vowifi_running_mode, "volte") == 0) {
|
if (strcmp(g_vowifi_running_mode, "volte") == 0) {
|
||||||
stop_vowifi_child();
|
stop_vowifi_child();
|
||||||
}
|
}
|
||||||
if (g_baseband_ims_set && has_ims) {
|
if (g_baseband_ims_set && ensure_qrtr() == 0) {
|
||||||
(void)ims_qmi_ims_set_services(&g_qrtr, next_txn(), 0, 0, 0);
|
struct ims_qrtr_addr ims_addr;
|
||||||
|
if (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_IMS, 0, 200, &ims_addr) == 0) {
|
||||||
|
(void)ims_qmi_ims_set_services(&g_qrtr, next_txn(), 0, 0, 0);
|
||||||
|
}
|
||||||
g_baseband_ims_set = 0;
|
g_baseband_ims_set = 0;
|
||||||
}
|
}
|
||||||
if (g_bearer_up) {
|
if (g_bearer_up) {
|
||||||
@@ -649,6 +727,8 @@ static void reconcile_all(void) {
|
|||||||
g_state.ims_apn_ip[0] = '\0';
|
g_state.ims_apn_ip[0] = '\0';
|
||||||
}
|
}
|
||||||
close_imsdcm();
|
close_imsdcm();
|
||||||
|
g_dsd_apn_applied[0] = '\0';
|
||||||
|
g_volte_check_retries = 0;
|
||||||
g_state.volte_registered = 0;
|
g_state.volte_registered = 0;
|
||||||
g_baseband_try_since_ms = 0;
|
g_baseband_try_since_ms = 0;
|
||||||
ims_str_copy(g_state.volte_backend, sizeof(g_state.volte_backend), "none");
|
ims_str_copy(g_state.volte_backend, sizeof(g_state.volte_backend), "none");
|
||||||
@@ -657,8 +737,10 @@ static void reconcile_all(void) {
|
|||||||
if (qrtr_ok) {
|
if (qrtr_ok) {
|
||||||
ensure_imsdcm();
|
ensure_imsdcm();
|
||||||
}
|
}
|
||||||
if (has_dsd) {
|
if (has_dsd && strcmp(g_dsd_apn_applied, g_cfg.ims_apn) != 0) {
|
||||||
(void)ims_qmi_dsd_set_ims_apn(&g_qrtr, next_txn(), g_cfg.ims_apn);
|
if (ims_qmi_dsd_set_ims_apn(&g_qrtr, next_txn(), g_cfg.ims_apn) == 0) {
|
||||||
|
ims_str_copy(g_dsd_apn_applied, sizeof(g_dsd_apn_applied), g_cfg.ims_apn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int force_userspace = (strcmp(g_cfg.volte_backend, "userspace") == 0);
|
int force_userspace = (strcmp(g_cfg.volte_backend, "userspace") == 0);
|
||||||
@@ -727,12 +809,21 @@ static void reconcile_all(void) {
|
|||||||
g_state.vowifi_ipv6_epdg = 0;
|
g_state.vowifi_ipv6_epdg = 0;
|
||||||
g_state.tun_ip[0] = '\0';
|
g_state.tun_ip[0] = '\0';
|
||||||
g_state.tun_iface[0] = '\0';
|
g_state.tun_iface[0] = '\0';
|
||||||
|
g_vowifi_sync_retries = 0;
|
||||||
if (!want_userspace_volte) {
|
if (!want_userspace_volte) {
|
||||||
stop_vowifi_child();
|
stop_vowifi_child();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)ims_state_write(&g_state);
|
if (!effective_volte && !effective_vowifi) {
|
||||||
|
close_qrtr();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_state_written_once || !ims_state_equal(&prev, &g_state)) {
|
||||||
|
if (ims_state_write(&g_state) == 0) {
|
||||||
|
g_state_written_once = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (prev.volte_active != g_state.volte_active ||
|
if (prev.volte_active != g_state.volte_active ||
|
||||||
prev.volte_registered != g_state.volte_registered ||
|
prev.volte_registered != g_state.volte_registered ||
|
||||||
@@ -760,7 +851,8 @@ static void handle_imsdcm_qrtr_packet(void) {
|
|||||||
|
|
||||||
if (flags == IMS_QMI_FLAG_IND) {
|
if (flags == IMS_QMI_FLAG_IND) {
|
||||||
/* IMSA / NAS indication: reconcile state immediately. */
|
/* IMSA / NAS indication: reconcile state immediately. */
|
||||||
reconcile_all();
|
g_volte_check_retries = 0;
|
||||||
|
reconcile_all(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (flags != IMS_QMI_FLAG_REQ) {
|
if (flags != IMS_QMI_FLAG_REQ) {
|
||||||
@@ -875,7 +967,12 @@ static void handle_ctl_client(int srv_fd) {
|
|||||||
g_state.network_4g_only, g_state.access_tech, g_state.volte_backend);
|
g_state.network_4g_only, g_state.access_tech, g_state.volte_backend);
|
||||||
reply_client(cfd, rsp);
|
reply_client(cfd, rsp);
|
||||||
} else if (strcmp(line, "REFRESH") == 0 || strncmp(line, "NET_EVENT ", 10) == 0) {
|
} else if (strcmp(line, "REFRESH") == 0 || strncmp(line, "NET_EVENT ", 10) == 0) {
|
||||||
reconcile_all();
|
int is_wlan = (strncmp(line, "NET_EVENT wlan", 14) == 0);
|
||||||
|
if (!is_wlan) {
|
||||||
|
g_volte_check_retries = 0;
|
||||||
|
g_vowifi_sync_retries = 0;
|
||||||
|
}
|
||||||
|
reconcile_all(is_wlan);
|
||||||
reply_client(cfd, "OK\n");
|
reply_client(cfd, "OK\n");
|
||||||
} else if (strcmp(line, "AUTO_MATCH") == 0) {
|
} else if (strcmp(line, "AUTO_MATCH") == 0) {
|
||||||
if (!client_is_authorized_mutation(cfd)) {
|
if (!client_is_authorized_mutation(cfd)) {
|
||||||
@@ -889,7 +986,8 @@ static void handle_ctl_client(int srv_fd) {
|
|||||||
ims_str_copy(g_cfg.active_mbn, sizeof(g_cfg.active_mbn), m.id);
|
ims_str_copy(g_cfg.active_mbn, sizeof(g_cfg.active_mbn), m.id);
|
||||||
(void)ims_config_save(&g_cfg, NULL);
|
(void)ims_config_save(&g_cfg, NULL);
|
||||||
(void)pdc_send_load_and_select(&m, 1);
|
(void)pdc_send_load_and_select(&m, 1);
|
||||||
reconcile_all();
|
g_volte_check_retries = 0;
|
||||||
|
reconcile_all(0);
|
||||||
char rsp[256];
|
char rsp[256];
|
||||||
snprintf(rsp, sizeof(rsp), "OK MATCHED=%s PLMN=%s-%s\n", m.id, mcc, mnc);
|
snprintf(rsp, sizeof(rsp), "OK MATCHED=%s PLMN=%s-%s\n", m.id, mcc, mnc);
|
||||||
reply_client(cfd, rsp);
|
reply_client(cfd, rsp);
|
||||||
@@ -911,7 +1009,8 @@ static void handle_ctl_client(int srv_fd) {
|
|||||||
if (activate && rc != 0) {
|
if (activate && rc != 0) {
|
||||||
rc = pdc_send_load_and_select(&info, 1);
|
rc = pdc_send_load_and_select(&info, 1);
|
||||||
}
|
}
|
||||||
reconcile_all();
|
g_volte_check_retries = 0;
|
||||||
|
reconcile_all(0);
|
||||||
reply_client(cfd, rc == 0 ? "OK\n" : "OK stored_offline\n");
|
reply_client(cfd, rc == 0 ? "OK\n" : "OK stored_offline\n");
|
||||||
} else {
|
} else {
|
||||||
reply_client(cfd, "ERR invalid profile\n");
|
reply_client(cfd, "ERR invalid profile\n");
|
||||||
@@ -922,7 +1021,8 @@ static void handle_ctl_client(int srv_fd) {
|
|||||||
reply_client(cfd, "ERR unauthorized\n");
|
reply_client(cfd, "ERR unauthorized\n");
|
||||||
} else {
|
} else {
|
||||||
pdc_delete_or_reset(line + 11, 0);
|
pdc_delete_or_reset(line + 11, 0);
|
||||||
reconcile_all();
|
g_volte_check_retries = 0;
|
||||||
|
reconcile_all(0);
|
||||||
reply_client(cfd, "OK\n");
|
reply_client(cfd, "OK\n");
|
||||||
}
|
}
|
||||||
} else if (strcmp(line, "PDC_RESET") == 0) {
|
} else if (strcmp(line, "PDC_RESET") == 0) {
|
||||||
@@ -930,7 +1030,8 @@ static void handle_ctl_client(int srv_fd) {
|
|||||||
reply_client(cfd, "ERR unauthorized\n");
|
reply_client(cfd, "ERR unauthorized\n");
|
||||||
} else {
|
} else {
|
||||||
pdc_delete_or_reset(NULL, 1);
|
pdc_delete_or_reset(NULL, 1);
|
||||||
reconcile_all();
|
g_volte_check_retries = 0;
|
||||||
|
reconcile_all(0);
|
||||||
reply_client(cfd, "OK\n");
|
reply_client(cfd, "OK\n");
|
||||||
}
|
}
|
||||||
} else if (strcmp(line, "STOP") == 0) {
|
} else if (strcmp(line, "STOP") == 0) {
|
||||||
@@ -1010,7 +1111,7 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ims_state_defaults(&g_state);
|
ims_state_defaults(&g_state);
|
||||||
reconcile_all();
|
reconcile_all(0);
|
||||||
|
|
||||||
while (!g_stop) {
|
while (!g_stop) {
|
||||||
struct pollfd pfds[4];
|
struct pollfd pfds[4];
|
||||||
@@ -1037,10 +1138,16 @@ int main(void) {
|
|||||||
nfds++;
|
nfds++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Idle 0% CPU whenever no child registration sync is pending. */
|
int need_vowifi_sync = (g_vowifi_pid > 0) &&
|
||||||
int timeout_ms = (g_vowifi_pid > 0 || (g_state.volte_active && !g_state.volte_registered))
|
((strcmp(g_vowifi_running_mode, "vowifi") == 0 && !g_state.vowifi_registered) ||
|
||||||
? 2000
|
(strcmp(g_vowifi_running_mode, "volte") == 0 && !g_state.volte_registered)) &&
|
||||||
: -1;
|
(g_vowifi_sync_retries < 4);
|
||||||
|
int need_volte_check = (g_state.volte_active && !g_state.volte_registered &&
|
||||||
|
strcmp(g_state.volte_backend, "baseband") == 0 &&
|
||||||
|
g_volte_check_retries < 3);
|
||||||
|
|
||||||
|
/* Idle at 0% CPU (poll -1) except for bounded startup sync checks. */
|
||||||
|
int timeout_ms = need_vowifi_sync ? 500 : (need_volte_check ? 3000 : -1);
|
||||||
int prc = poll(pfds, nfds, timeout_ms);
|
int prc = poll(pfds, nfds, timeout_ms);
|
||||||
if (prc < 0) {
|
if (prc < 0) {
|
||||||
if (errno == EINTR) continue;
|
if (errno == EINTR) continue;
|
||||||
@@ -1066,16 +1173,23 @@ int main(void) {
|
|||||||
g_vowifi_running_mode[0] = '\0';
|
g_vowifi_running_mode[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reconcile_all();
|
reconcile_all(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_reload) {
|
if (g_reload) {
|
||||||
g_reload = 0;
|
g_reload = 0;
|
||||||
reconcile_all();
|
g_volte_check_retries = 0;
|
||||||
|
g_vowifi_sync_retries = 0;
|
||||||
|
reconcile_all(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prc == 0) {
|
if (prc == 0) {
|
||||||
reconcile_all();
|
if (need_vowifi_sync) {
|
||||||
|
g_vowifi_sync_retries++;
|
||||||
|
} else if (need_volte_check) {
|
||||||
|
g_volte_check_retries++;
|
||||||
|
}
|
||||||
|
reconcile_all(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -572,13 +572,22 @@ static inline int ims_qmi_nas_get_serving(struct ims_qrtr_ep *ep, uint16_t txn_i
|
|||||||
tlen = rlen - 7U;
|
tlen = rlen - 7U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int reg_state = 0;
|
||||||
|
int cs_attach = 0;
|
||||||
|
int ps_attach = 0;
|
||||||
int has_lte = 0;
|
int has_lte = 0;
|
||||||
int has_cs = 0;
|
int has_cs = 0;
|
||||||
uint16_t s_len = 0;
|
uint16_t s_len = 0;
|
||||||
const uint8_t *srv = ims_qmi_tlv_find(tlvs, tlen, 0x01U, &s_len);
|
const uint8_t *srv = ims_qmi_tlv_find(tlvs, tlen, 0x01U, &s_len);
|
||||||
if (srv && s_len >= 6) {
|
if (srv && s_len >= 6) {
|
||||||
|
reg_state = srv[0]; /* 1 = REGISTERED */
|
||||||
|
cs_attach = srv[1]; /* 1 = ATTACHED */
|
||||||
|
ps_attach = srv[2]; /* 1 = ATTACHED */
|
||||||
if (out_reg_state) {
|
if (out_reg_state) {
|
||||||
*out_reg_state = srv[0]; /* 1 = REGISTERED */
|
*out_reg_state = reg_state;
|
||||||
|
}
|
||||||
|
if (cs_attach == 1) {
|
||||||
|
has_cs = 1;
|
||||||
}
|
}
|
||||||
uint8_t n_rad = srv[4];
|
uint8_t n_rad = srv[4];
|
||||||
for (uint8_t i = 0; i < n_rad && (size_t)(5 + i) < s_len; i++) {
|
for (uint8_t i = 0; i < n_rad && (size_t)(5 + i) < s_len; i++) {
|
||||||
@@ -639,8 +648,8 @@ static inline int ims_qmi_nas_get_serving(struct ims_qrtr_ep *ep, uint16_t txn_i
|
|||||||
*out_has_cs_rat = has_cs;
|
*out_has_cs_rat = has_cs;
|
||||||
}
|
}
|
||||||
if (out_lte_only) {
|
if (out_lte_only) {
|
||||||
/* 4G-only if serving RAT is LTE without CS fallback OR modem mode preference is LTE-only. */
|
/* 4G-only if registered EPS-only LTE without CS attach/fallback, OR LTE-only mode_pref. */
|
||||||
*out_lte_only = ((has_lte && !has_cs) || pref_lte_only) ? 1 : 0;
|
*out_lte_only = (pref_lte_only || (reg_state == 1 && ps_attach == 1 && has_lte && !has_cs)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -762,6 +762,7 @@ public:
|
|||||||
uint32_t rtpSsrc = 0x42414E01U;
|
uint32_t rtpSsrc = 0x42414E01U;
|
||||||
int64_t nextRtpTxMs = 0;
|
int64_t nextRtpTxMs = 0;
|
||||||
int64_t nextRegRetryMs = 0;
|
int64_t nextRegRetryMs = 0;
|
||||||
|
int64_t regBackoffMs = 5000;
|
||||||
uint8_t rpMrCounter = 1;
|
uint8_t rpMrCounter = 1;
|
||||||
uint32_t callCounter = 1;
|
uint32_t callCounter = 1;
|
||||||
|
|
||||||
@@ -773,15 +774,19 @@ public:
|
|||||||
ims_mkdir_p(stateDir.c_str(), 0755);
|
ims_mkdir_p(stateDir.c_str(), 0755);
|
||||||
ims_config_load(&cfg, nullptr);
|
ims_config_load(&cfg, nullptr);
|
||||||
ims_state_read(&st);
|
ims_state_read(&st);
|
||||||
aka = std::make_unique<ba_vowifi::SimAkaClient>(cfg.ims_sim_slot, stateDir);
|
if (!aka) {
|
||||||
simId = aka->readIdentity(st, cfg);
|
aka = std::make_unique<ba_vowifi::SimAkaClient>(cfg.ims_sim_slot, stateDir);
|
||||||
|
}
|
||||||
|
if (simId.imsi.empty()) {
|
||||||
|
simId = aka->readIdentity(st, cfg);
|
||||||
|
}
|
||||||
|
|
||||||
if (const char* p = std::getenv("BANANARCHY_PCSCF_PORT")) {
|
if (const char* p = std::getenv("BANANARCHY_PCSCF_PORT")) {
|
||||||
int pv = std::atoi(p);
|
int pv = std::atoi(p);
|
||||||
if (pv > 0 && pv <= 65535) pcscfPort = static_cast<uint16_t>(pv);
|
if (pv > 0 && pv <= 65535) pcscfPort = static_cast<uint16_t>(pv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openCtlSocket() != 0) return -1;
|
if (ctlSrvFd < 0 && openCtlSocket() != 0) return -1;
|
||||||
|
|
||||||
if (mode == "vowifi") {
|
if (mode == "vowifi") {
|
||||||
std::string eHost = cfg.epdg_server[0] ? std::string(cfg.epdg_server) : defaultEpdgHost();
|
std::string eHost = cfg.epdg_server[0] ? std::string(cfg.epdg_server) : defaultEpdgHost();
|
||||||
@@ -789,7 +794,9 @@ public:
|
|||||||
ims_str_copy(st.last_error, sizeof(st.last_error), tunnel.lastError.c_str());
|
ims_str_copy(st.last_error, sizeof(st.last_error), tunnel.lastError.c_str());
|
||||||
ims_str_copy(st.epdg_host, sizeof(st.epdg_host), eHost.c_str());
|
ims_str_copy(st.epdg_host, sizeof(st.epdg_host), eHost.c_str());
|
||||||
ims_state_write(&st);
|
ims_state_write(&st);
|
||||||
return 0; /* stay alive for retry on RELOAD or timer */
|
nextRegRetryMs = monotonicMs() + regBackoffMs;
|
||||||
|
regBackoffMs = std::min<int64_t>(regBackoffMs * 2, 300000);
|
||||||
|
return 0; /* stay alive for retry on backed-off timer or STOP */
|
||||||
}
|
}
|
||||||
localIp = !tunnel.tunIp.empty() ? tunnel.tunIp
|
localIp = !tunnel.tunIp.empty() ? tunnel.tunIp
|
||||||
: (!tunnel.tunIp6.empty() ? tunnel.tunIp6 : "10.99.0.2");
|
: (!tunnel.tunIp6.empty() ? tunnel.tunIp6 : "10.99.0.2");
|
||||||
@@ -852,8 +859,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int timeoutMs = -1;
|
int timeoutMs = -1;
|
||||||
if (callState == CallState::Active) timeoutMs = 20;
|
if (callState == CallState::Active) {
|
||||||
else if (!registered) timeoutMs = 1500;
|
timeoutMs = 20;
|
||||||
|
} else if (!registered && nextRegRetryMs > 0) {
|
||||||
|
int64_t rem = nextRegRetryMs - monotonicMs();
|
||||||
|
timeoutMs = static_cast<int>(std::clamp<int64_t>(rem, 100, 300000));
|
||||||
|
}
|
||||||
|
|
||||||
int prc = ::poll(pfds, n, timeoutMs);
|
int prc = ::poll(pfds, n, timeoutMs);
|
||||||
if (prc < 0) {
|
if (prc < 0) {
|
||||||
@@ -897,7 +908,8 @@ public:
|
|||||||
sendRtpFrame();
|
sendRtpFrame();
|
||||||
nextRtpTxMs = now + 20;
|
nextRtpTxMs = now + 20;
|
||||||
} else if (!registered && nextRegRetryMs > 0 && now >= nextRegRetryMs) {
|
} else if (!registered && nextRegRetryMs > 0 && now >= nextRegRetryMs) {
|
||||||
nextRegRetryMs = now + 10000;
|
nextRegRetryMs = now + regBackoffMs;
|
||||||
|
regBackoffMs = std::min<int64_t>(regBackoffMs * 2, 300000);
|
||||||
if (mode == "vowifi" && !tunnel.connected) {
|
if (mode == "vowifi" && !tunnel.connected) {
|
||||||
init();
|
init();
|
||||||
} else {
|
} else {
|
||||||
@@ -1066,6 +1078,7 @@ private:
|
|||||||
} else if (sip.statusCode == 200) {
|
} else if (sip.statusCode == 200) {
|
||||||
registered = true;
|
registered = true;
|
||||||
nextRegRetryMs = 0;
|
nextRegRetryMs = 0;
|
||||||
|
regBackoffMs = 5000;
|
||||||
ims_state_read(&st);
|
ims_state_read(&st);
|
||||||
if (mode == "vowifi") {
|
if (mode == "vowifi") {
|
||||||
st.vowifi_active = 1;
|
st.vowifi_active = 1;
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ void blankScreenBacklight() {
|
|||||||
writeSysfsStr("/sys/class/leds/white:kbd_backlight/brightness", "0");
|
writeSysfsStr("/sys/class/leds/white:kbd_backlight/brightness", "0");
|
||||||
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "powersave");
|
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "powersave");
|
||||||
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "powersave");
|
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "powersave");
|
||||||
|
runAsyncArgv("/usr/bin/bananarchy-power-policy.sh", "screenoff");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string cur = readSmallFileTrimmed("/sys/class/backlight/backlight/brightness");
|
std::string cur = readSmallFileTrimmed("/sys/class/backlight/backlight/brightness");
|
||||||
@@ -115,6 +116,7 @@ void blankScreenBacklight() {
|
|||||||
writeSysfsStr("/sys/class/backlight/backlight/bl_power", "4");
|
writeSysfsStr("/sys/class/backlight/backlight/bl_power", "4");
|
||||||
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "powersave");
|
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "powersave");
|
||||||
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "powersave");
|
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "powersave");
|
||||||
|
runAsyncArgv("/usr/bin/bananarchy-power-policy.sh", "screenoff");
|
||||||
}
|
}
|
||||||
|
|
||||||
void wakeScreenBacklight() {
|
void wakeScreenBacklight() {
|
||||||
@@ -124,6 +126,7 @@ void wakeScreenBacklight() {
|
|||||||
}
|
}
|
||||||
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "schedutil");
|
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "schedutil");
|
||||||
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "simple_ondemand");
|
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "simple_ondemand");
|
||||||
|
runAsyncArgv("/usr/bin/bananarchy-power-policy.sh", "screenon");
|
||||||
std::string cur = readSmallFileTrimmed("/tmp/sxmo_saved_brightness");
|
std::string cur = readSmallFileTrimmed("/tmp/sxmo_saved_brightness");
|
||||||
int val = std::atoi(cur.c_str());
|
int val = std::atoi(cur.c_str());
|
||||||
if (val < 1) {
|
if (val < 1) {
|
||||||
|
|||||||
Reference in new issue
Block a user