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

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

No files matched your search

+43 -17
View File
@@ -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);
if(tlvs_len > 0)
memcpy(req + 7, tlvs, tlvs_len);
if(sendto(sock, req, 7 + tlvs_len, 0, (const struct sockaddr *)addr,
sizeof(*addr)) < 0) {
if(sendto(sock, req, 7 + tlvs_len, 0,
addr ? (const struct sockaddr *)addr : NULL,
addr ? (socklen_t)sizeof(*addr) : 0) < 0) {
return -1;
}
@@ -1952,7 +1953,9 @@ int main(int argc, char **argv)
#else
static int apply_sig_hysteresis(const char *mode)
{
const char *mock_path = getenv("BANANARCHY_DSDS_SIG_MOCK_SOCK");
struct sockaddr_qrtr nas_addr;
const struct sockaddr_qrtr *target = NULL;
int dark, ns, sub;
uint16_t txn = 1;
@@ -1963,39 +1966,62 @@ static int apply_sig_hysteresis(const char *mode)
else
return 1;
if(lookup_srv(3, &nas_addr) < 0)
return 0;
ns = socket(AF_QIPCRTR, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if(ns < 0)
return 0;
if(mock_path && *mock_path) {
struct sockaddr_un sun;
size_t mlen = strlen(mock_path);
if(mlen >= sizeof(sun.sun_path))
return 1;
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++) {
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];
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);
if(dark) {
/* Thresholds: RSSI (-105, -75 dBm), LTE RSRP (-120, -90 dBm) to suppress
* minor standby radio fluctuations from waking APSS over QRTR. */
/* Coarse thresholds + rate=0 (threshold-only, avg=5 s) over RSSI, WCDMA
* RSCP, and LTE RSRP so minor standby fluctuations do not wake APSS. */
uint8_t sig_tlvs[] = {
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);
} else {
uint8_t sig_tlvs[] = {
0x10, 0x06, 0x00, 0x05,
(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,
0x13, 0x0b, 0x00, 0x05,
0x88, 0xff, 0x92, 0xff, 0x9c, 0xff, 0xa6, 0xff, 0xb0, 0xff
0x18, 0x06, 0x00, 0x05,
(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);
}
}
+141 -27
View File
@@ -43,6 +43,10 @@ static int g_bearer_up = 0;
static int g_baseband_ims_set = 0;
static int64_t g_baseband_try_since_ms = 0;
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) {
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);
}
g_vowifi_pid = pid;
g_vowifi_sync_retries = 0;
ims_str_copy(g_vowifi_running_mode, sizeof(g_vowifi_running_mode), mode);
return 0;
}
@@ -326,6 +331,49 @@ static int ensure_qrtr(void) {
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) {
if (!g_imsdcm_ready || g_imsdcm.fd < 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;
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.vowifi_mode, sizeof(g_state.vowifi_mode), g_cfg.vowifi_mode);
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;
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;
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);
@@ -619,14 +688,20 @@ static void reconcile_all(void) {
int effective_vowifi = (strcmp(g_cfg.vowifi_mode, "on") == 0) ||
(strcmp(g_cfg.vowifi_mode, "auto") == 0 && network_4g_only == 1);
int qrtr_ok = (ensure_qrtr() == 0);
struct ims_qrtr_addr tmp_addr;
int has_ims = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_IMS, 0, 200, &tmp_addr) == 0);
int has_imsa = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_IMSA, 0, 200, &tmp_addr) == 0);
int has_dsd = qrtr_ok && (ims_qrtr_lookup(&g_qrtr, IMS_QMI_SVC_DSD, 0, 200, &tmp_addr) == 0);
int qrtr_ok = 0;
int has_ims = 0;
int has_imsa = 0;
int has_dsd = 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;
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_userspace_volte = 0;
@@ -636,8 +711,11 @@ static void reconcile_all(void) {
if (strcmp(g_vowifi_running_mode, "volte") == 0) {
stop_vowifi_child();
}
if (g_baseband_ims_set && has_ims) {
(void)ims_qmi_ims_set_services(&g_qrtr, next_txn(), 0, 0, 0);
if (g_baseband_ims_set && ensure_qrtr() == 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;
}
if (g_bearer_up) {
@@ -649,6 +727,8 @@ static void reconcile_all(void) {
g_state.ims_apn_ip[0] = '\0';
}
close_imsdcm();
g_dsd_apn_applied[0] = '\0';
g_volte_check_retries = 0;
g_state.volte_registered = 0;
g_baseband_try_since_ms = 0;
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) {
ensure_imsdcm();
}
if (has_dsd) {
(void)ims_qmi_dsd_set_ims_apn(&g_qrtr, next_txn(), g_cfg.ims_apn);
if (has_dsd && strcmp(g_dsd_apn_applied, g_cfg.ims_apn) != 0) {
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);
@@ -727,12 +809,21 @@ static void reconcile_all(void) {
g_state.vowifi_ipv6_epdg = 0;
g_state.tun_ip[0] = '\0';
g_state.tun_iface[0] = '\0';
g_vowifi_sync_retries = 0;
if (!want_userspace_volte) {
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 ||
prev.volte_registered != g_state.volte_registered ||
@@ -760,7 +851,8 @@ static void handle_imsdcm_qrtr_packet(void) {
if (flags == IMS_QMI_FLAG_IND) {
/* IMSA / NAS indication: reconcile state immediately. */
reconcile_all();
g_volte_check_retries = 0;
reconcile_all(0);
return;
}
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);
reply_client(cfd, rsp);
} 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");
} else if (strcmp(line, "AUTO_MATCH") == 0) {
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);
(void)ims_config_save(&g_cfg, NULL);
(void)pdc_send_load_and_select(&m, 1);
reconcile_all();
g_volte_check_retries = 0;
reconcile_all(0);
char rsp[256];
snprintf(rsp, sizeof(rsp), "OK MATCHED=%s PLMN=%s-%s\n", m.id, mcc, mnc);
reply_client(cfd, rsp);
@@ -911,7 +1009,8 @@ static void handle_ctl_client(int srv_fd) {
if (activate && rc != 0) {
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");
} else {
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");
} else {
pdc_delete_or_reset(line + 11, 0);
reconcile_all();
g_volte_check_retries = 0;
reconcile_all(0);
reply_client(cfd, "OK\n");
}
} 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");
} else {
pdc_delete_or_reset(NULL, 1);
reconcile_all();
g_volte_check_retries = 0;
reconcile_all(0);
reply_client(cfd, "OK\n");
}
} else if (strcmp(line, "STOP") == 0) {
@@ -1010,7 +1111,7 @@ int main(void) {
}
ims_state_defaults(&g_state);
reconcile_all();
reconcile_all(0);
while (!g_stop) {
struct pollfd pfds[4];
@@ -1037,10 +1138,16 @@ int main(void) {
nfds++;
}
/* Idle 0% CPU whenever no child registration sync is pending. */
int timeout_ms = (g_vowifi_pid > 0 || (g_state.volte_active && !g_state.volte_registered))
? 2000
: -1;
int need_vowifi_sync = (g_vowifi_pid > 0) &&
((strcmp(g_vowifi_running_mode, "vowifi") == 0 && !g_state.vowifi_registered) ||
(strcmp(g_vowifi_running_mode, "volte") == 0 && !g_state.volte_registered)) &&
(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);
if (prc < 0) {
if (errno == EINTR) continue;
@@ -1066,16 +1173,23 @@ int main(void) {
g_vowifi_running_mode[0] = '\0';
}
}
reconcile_all();
reconcile_all(0);
}
if (g_reload) {
g_reload = 0;
reconcile_all();
g_volte_check_retries = 0;
g_vowifi_sync_retries = 0;
reconcile_all(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;
}
+12 -3
View File
@@ -572,13 +572,22 @@ static inline int ims_qmi_nas_get_serving(struct ims_qrtr_ep *ep, uint16_t txn_i
tlen = rlen - 7U;
}
int reg_state = 0;
int cs_attach = 0;
int ps_attach = 0;
int has_lte = 0;
int has_cs = 0;
uint16_t s_len = 0;
const uint8_t *srv = ims_qmi_tlv_find(tlvs, tlen, 0x01U, &s_len);
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) {
*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];
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;
}
if (out_lte_only) {
/* 4G-only if serving RAT is LTE without CS fallback OR modem mode preference is LTE-only. */
*out_lte_only = ((has_lte && !has_cs) || pref_lte_only) ? 1 : 0;
/* 4G-only if registered EPS-only LTE without CS attach/fallback, OR LTE-only mode_pref. */
*out_lte_only = (pref_lte_only || (reg_state == 1 && ps_attach == 1 && has_lte && !has_cs)) ? 1 : 0;
}
return 0;
}
+20 -7
View File
@@ -762,6 +762,7 @@ public:
uint32_t rtpSsrc = 0x42414E01U;
int64_t nextRtpTxMs = 0;
int64_t nextRegRetryMs = 0;
int64_t regBackoffMs = 5000;
uint8_t rpMrCounter = 1;
uint32_t callCounter = 1;
@@ -773,15 +774,19 @@ public:
ims_mkdir_p(stateDir.c_str(), 0755);
ims_config_load(&cfg, nullptr);
ims_state_read(&st);
aka = std::make_unique<ba_vowifi::SimAkaClient>(cfg.ims_sim_slot, stateDir);
simId = aka->readIdentity(st, cfg);
if (!aka) {
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")) {
int pv = std::atoi(p);
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") {
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.epdg_host, sizeof(st.epdg_host), eHost.c_str());
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
: (!tunnel.tunIp6.empty() ? tunnel.tunIp6 : "10.99.0.2");
@@ -852,8 +859,12 @@ public:
}
int timeoutMs = -1;
if (callState == CallState::Active) timeoutMs = 20;
else if (!registered) timeoutMs = 1500;
if (callState == CallState::Active) {
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);
if (prc < 0) {
@@ -897,7 +908,8 @@ public:
sendRtpFrame();
nextRtpTxMs = now + 20;
} 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) {
init();
} else {
@@ -1066,6 +1078,7 @@ private:
} else if (sip.statusCode == 200) {
registered = true;
nextRegRetryMs = 0;
regBackoffMs = 5000;
ims_state_read(&st);
if (mode == "vowifi") {
st.vowifi_active = 1;
+3
View File
@@ -103,6 +103,7 @@ void blankScreenBacklight() {
writeSysfsStr("/sys/class/leds/white:kbd_backlight/brightness", "0");
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "powersave");
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "powersave");
runAsyncArgv("/usr/bin/bananarchy-power-policy.sh", "screenoff");
return;
}
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/devices/system/cpu/cpufreq/policy0/scaling_governor", "powersave");
writeSysfsStr("/sys/class/devfreq/1c00000.gpu/governor", "powersave");
runAsyncArgv("/usr/bin/bananarchy-power-policy.sh", "screenoff");
}
void wakeScreenBacklight() {
@@ -124,6 +126,7 @@ void wakeScreenBacklight() {
}
writeSysfsStr("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "schedutil");
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");
int val = std::atoi(cur.c_str());
if (val < 1) {