modem, callscreen, ring: fix DSDS incoming ring hangup/volume and add Primary/Secondary GW SIM swap UI

This commit is contained in:
Luxferre committed 2026-10-27 13:02:14 +02:00
1 parent 9a079e1068
commit 7927bacb67
18 files changed
+280 -84

No files matched your search

+3 -2
View File
@@ -12,9 +12,10 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
### New features and improvements
- **Dual-SIM Dual Standby (DSDS) and outgoing SIM selection**:
- Updated `msm-modem-uim-selection` to provision both physical SIM slots simultaneously (`primary-gw-provisioning` and `secondary-gw-provisioning`) with QMI `NAS` Dual-Standby Preference (`DualStandbyWithTuneAway`) and network registration across both subscriptions.
- Updated `msm-modem-uim-selection` to provision both physical SIM slots simultaneously (`primary-gw-provisioning` and `secondary-gw-provisioning`) with QMI `NAS` Dual-Standby Preference (`DualStandbyWithTuneAway`) and network registration across both subscriptions, plus `--swap-gw` support to swap which physical slot holds `primary-gw-provisioning` (4G/LTE/3G + Mobile Data) versus `secondary-gw-provisioning` (2G GSM DSDS standby).
- Added an event-driven QMI `WMS` and `VOICE` QRTR listener (`dsds-daemon`, supervised by `sxmo_modemmonitor.sh`) so both SIM cards can receive incoming voice calls (with `q6voiced` `hw:0,4` audio routing) and SMS messages (single and multipart GSM-7 / UCS-2) simultaneously.
- Added interactive `[1] SIM 1` / `[2] SIM 2` outgoing SIM selection prompts when two SIM cards are active across voice calls (`xcallscreen` / `sxmo_modemdial.sh`), SMS (`xsms` / `sxmo_modemsendsms.sh`), and USSD queries (`xdialer` / `msm-modem-uim-selection ussd`), plus live dual-SIM status and instant default SIM switching in `xmodem`.
- Added interactive `[1] SIM 1` / `[2] SIM 2` outgoing SIM selection prompts when two SIM cards are active across voice calls (`xcallscreen` / `sxmo_modemdial.sh`), SMS (`xsms` / `sxmo_modemsendsms.sh`), and USSD queries (`xdialer` / `msm-modem-uim-selection ussd`), plus live dual-SIM role badges (`[PRI 4G / DEFAULT]`, `[PRI 4G / DSDS]`, `[SEC 2G / DEFAULT]`, `[SEC 2G / DSDS]`), instant default SIM switching, and full Primary/Secondary GW (`4G/Data`) slot swapping in `xmodem`.
- Synchronized incoming call ringtone and vibration lifecycle (`sxmo_hook_ring.sh`, `callscreen.so`, `sxmo_modem.sh`, and `dsds-daemon`) with `flock` single-instance locking, `0 dB` (`RX3 Digital Volume <= 84`) hardware volume capping, and immediate `sxmo_hook_ring.sh` / `pw-play` / `sxmo_vibrate` termination before audio teardown on remote hangup.
- **Instant USB charging state icon update**:
- Added `/etc/udev/rules.d/85-bananarchy-battery.rules` and updated `sxmo_hook_battery.sh` to inspect `/sys/class/power_supply/pm8916-lbc-chgr/online` immediately on `power_supply` udev events so the statusbar charging indicator appears and disappears the moment the cable is plugged in or unplugged.
+1 -1
View File
@@ -191,7 +191,7 @@ All fifteen phone applications are compiled as shared-object plugins (`/usr/lib/
11. **Modem, Dual-SIM, and PIN/PUK manager (`modem.so` / `xmodem`)**:
- **Open**: select **Modem** from the System menu, or run `xmodem`. Also opens automatically when a SIM card requires PIN or PUK unlock.
- **Four control tabs (`Left`/`Right` or `1`–`4`)**:
- **`1:SIMs`**: inspects both physical SIM slots via QMI UIM (`PRESENT`/`EMPTY`, `[ACTIVE / DEFAULT]`, `[ACTIVE / DSDS]`, `READY`/`PIN-LOCK`/`PUK-LOCK`, remaining retries, operator, RAT, and phone number). Press `Return` on a slot to **Set as Default / Primary SIM**, **Unlock SIM PIN**, **Unblock SIM with PUK**, **Enable / Disable PIN Lock**, or **Change SIM PIN** (with automatic `ModemManager` reprobe after unlock).
- **`1:SIMs`**: inspects both physical SIM slots via QMI UIM (`PRESENT`/`EMPTY`, `[PRI 4G / DEFAULT]`, `[PRI 4G / DSDS]`, `[SEC 2G / DEFAULT]`, `[SEC 2G / DSDS]`, `READY`/`PIN-LOCK`/`PUK-LOCK`, remaining retries, operator, RAT, and phone number). Press `Return` on a slot (or use the bottom quick-action rows) to **Set as Default SIM (Calls/SMS)** (instant switch without dropping network registration), **Make Primary GW (4G/Data Swap)** (`msm-modem-uim-selection switch <slot> --swap-gw` to move 4G/LTE/3G + Mobile Data to that slot and 2G DSDS standby to the other), **Unlock SIM PIN**, **Unblock SIM with PUK**, **Enable / Disable PIN Lock**, or **Change SIM PIN** (with automatic `ModemManager` reprobe after unlock).
- **`2:Radio`**: shows signal bar, registration status, access technology (`LTE`/`UMTS`/`GSM`), operator, both IMEIs, and phone number, with actions to switch **Network Mode** (`4G/3G/2G`, `3G/2G`, `4G Only`, `3G Only`, `2G Only`), **Send USSD Code**, toggle **Modem Power**, or **Restart ModemManager**.
- **`3:AT`**: interactive AT command console with presets (`AT`, `ATI`, `AT+CSQ`, `AT+CPIN?`, `AT+COPS?`, etc.) and custom keypad entry.
- **`4:Log`**: scrollable history of calls, SMS events, and USSD responses.
+12 -1
View File
@@ -115,6 +115,10 @@ checkforfinishedcalls() {
if ! sxmo_modemcall.sh list_active_calls | grep -q .; then
# Cleanup
sxmo_jobs.sh stop ringing
pkill -TERM -f sxmo_hook_ring.sh 2>/dev/null || true
pkill -TERM -f "pw-play.*ring" 2>/dev/null || true
pkill -TERM -f "mpv.*ring" 2>/dev/null || true
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/"* 2>/dev/null || true
if [ "$STATE" != muted ] && [ ! -f "$XDG_CONFIG_HOME/sxmo/.novibrate" ]; then
sxmo_vibrate 600 &
@@ -133,6 +137,13 @@ checkforfinishedcalls() {
sxmo_hook_after_call.sh
else
# Or refresh the menu
if ! sxmo_modemcall.sh list_active_calls | grep -q "ringing-in"; then
sxmo_jobs.sh stop ringing
pkill -TERM -f sxmo_hook_ring.sh 2>/dev/null || true
pkill -TERM -f "pw-play.*ring" 2>/dev/null || true
pkill -TERM -f "mpv.*ring" 2>/dev/null || true
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
fi
sxmo_jobs.sh start incall_menu sxmo_modemcall.sh incall_menu
fi
done
@@ -165,7 +176,7 @@ checkforincomingcalls() {
else
stderr "Invoking ring hook (async)"
CONTACTNAME=$(sxmo_contacts.sh --name-or-number "$INCOMINGNUMBER")
sxmo_jobs.sh start ringing sxmo_hook_ring.sh "$CONTACTNAME"
sxmo_jobs.sh start --group ringing sxmo_hook_ring.sh "$CONTACTNAME"
mkdir -p "$SXMO_LOGDIR"
printf %b "$TIME\tcall_ring\t$INCOMINGNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv"
+4 -2
View File
@@ -93,7 +93,8 @@ pickup() {
return 1
fi
if ! mmcli -m any -o "$CALLID" --accept; then
if ! mmcli -m any -o "$CALLID" --accept 2>/dev/null && \
! doas -n /usr/libexec/msm-modem-uim-selection call-accept "$CALLID" >/dev/null 2>&1; then
sxmo_notify_user.sh --urgency=critical "We failed to accept the call"
return 1
fi
@@ -152,7 +153,8 @@ hangup() {
sxmo_hook_discard.sh
fi
if ! mmcli -m any -o "$CALLID" --hangup; then
if ! mmcli -m any -o "$CALLID" --hangup 2>/dev/null && \
! doas -n /usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1; then
# we ignore already closed calls
if list_active_calls | grep -q "/$CALLID "; then
sxmo_notify_user.sh --urgency=critical "We failed to hangup the call"
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -549,13 +549,14 @@ provision_slot() {
fi
if [ "$need_prim" = "1" ]; then
if [ "${SECONDARY_GW_SLOT:-0}" = "$chosen_slot" ]; then
if [ "${SECONDARY_GW_SLOT:-0}" != "0" ]; then
$QMICLI_MODEM --uim-change-provisioning-session='activate=no,session-type=secondary-gw-provisioning' >/dev/null 2>&1 || true
SECONDARY_GW_SLOT=0
fi
if [ "$PRIMARY_GW_SLOT" != "0" ]; then
$QMICLI_MODEM --uim-change-provisioning-session='activate=no,session-type=primary-gw-provisioning' >/dev/null 2>&1 || true
fi
sleep 0.2
if [ -n "$chosen_aid" ]; then
echo "Selecting AID $chosen_aid on slot $chosen_slot (primary-gw-provisioning)"
if ! $QMICLI_MODEM --uim-change-provisioning-session="slot=$chosen_slot,activate=yes,session-type=primary-gw-provisioning,aid=$chosen_aid" >/dev/null 2>&1; then
@@ -565,6 +566,7 @@ provision_slot() {
echo "Selecting slot $chosen_slot (primary-gw-provisioning)"
$QMICLI_MODEM --uim-change-provisioning-session="slot=$chosen_slot,activate=yes,session-type=primary-gw-provisioning" >/dev/null 2>&1 || true
fi
sleep 0.2
else
echo "Slot $chosen_slot already bound to primary-gw-provisioning ($chosen_app_state)."
fi
@@ -675,7 +677,7 @@ enable_and_register_modem() {
i=$((i + 1))
done
if [ -z "$mm_state" ] || [ "$mm_state" = "failed" ] || { [ "$force_unlock" = "1" ] && [ "$mm_state" = "locked" ]; }; then
if [ -z "$mm_state" ] || [ "$mm_state" = "failed" ] || [ "$force_unlock" = "2" ] || { [ "$force_unlock" = "1" ] && [ "$mm_state" = "locked" ]; }; then
restart_modemmanager_clean
i=0
mm_state=""
@@ -929,7 +931,12 @@ PY
fi
SIM_WAIT_TIME=2
provision_slot "$target" 4
spawn_enable_and_register "$target" 0
pkill -f "msm-modem-uim-selection dsds-daemon" 2>/dev/null || true
if [ "${3:-}" = "--swap-gw" ]; then
spawn_enable_and_register "$target" 2
else
spawn_enable_and_register "$target" 0
fi
exit 0
;;
@@ -1887,7 +1894,7 @@ STATE_MAP = {
7: "waiting",
8: "terminated",
9: "terminated",
10: "dialing",
10: "setup",
}
if sub_cmd == "call-dial":
@@ -2306,22 +2313,32 @@ STATE_MAP = {
7: "waiting",
8: "terminated",
9: "terminated",
10: "dialing",
10: "setup",
}
active_calls = {}
audio_opened = False
def stop_ringing_user():
run_user_cmd(
"rm -f /tmp/sxmo_call_ringing; "
"sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
"pkill -TERM -f sxmo_hook_ring.sh 2>/dev/null; "
"pkill -TERM -f 'pw-play.*ring' 2>/dev/null; "
"pkill -TERM -f 'mpv.*ring' 2>/dev/null; "
"pkill -TERM -x sxmo_vibrate 2>/dev/null || true"
)
def set_q6voiced_audio(enable):
global audio_opened
if enable and not audio_opened:
audio_opened = True
subprocess.run(["dbus-send", "--system", "--type=signal", "/", "org.ofono.VoiceCallManager.CallAdded"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
run_user_cmd("sxmo_modemaudio.sh setup")
run_user_cmd("sxmo_modemaudio.sh setup_audio")
elif not enable and audio_opened:
audio_opened = False
subprocess.run(["dbus-send", "--system", "--type=signal", "/", "org.ofono.VoiceCallManager.CallRemoved"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
run_user_cmd("sxmo_modemaudio.sh teardown")
run_user_cmd("sxmo_modemaudio.sh reset_audio")
def has_sub1_call_files():
try:
@@ -2329,20 +2346,49 @@ def has_sub1_call_files():
except Exception:
return False
def has_mm_call_files():
try:
for fn in os.listdir(CALLS_DIR):
if fn and fn[0].isdigit():
return True
except Exception:
pass
return False
def sync_sub1_calls(calls, sim_slot):
global active_calls
now_str = datetime.datetime.now().astimezone().isoformat(timespec="seconds")
for old_cid, old_info in list(active_calls.items()):
if old_cid not in calls:
calls[old_cid] = {
"id": old_cid,
"state": 9,
"dir": old_info.get("dir", 1),
"num": old_info.get("num", ""),
}
if old_info.get("state") == "terminated":
del active_calls[old_cid]
else:
calls[old_cid] = {
"id": old_cid,
"state": 9,
"dir": old_info.get("dir", 1),
"num": old_info.get("num", ""),
}
for cid, c in calls.items():
for cid, c in list(calls.items()):
st = STATE_MAP.get(c["state"], "unknown")
if st == "setup":
if c["dir"] == 1 and has_sub1_call_files():
st = "dialing"
else:
continue
# Skip calls that are already managed by ModemManager / sxmo_modem.sh on Primary GW
if cid not in active_calls:
if st == "terminated":
continue
if c["dir"] == 1 and not has_sub1_call_files():
continue
if c["dir"] == 2:
time.sleep(0.35)
if has_mm_call_files():
continue
num = c["num"] or active_calls.get(cid, {}).get("num") or "Unknown"
if num and num != "Unknown" and not num.startswith("+") and len(num) >= 10:
num = "+" + num
@@ -2352,7 +2398,7 @@ def sync_sub1_calls(calls, sim_slot):
# Update /run/user/10000/sxmo_calls/sub1_<id>.<state>
for fn in os.listdir(CALLS_DIR):
if fn.startswith(f"{call_key}."):
if fn.startswith(f"{call_key}.") and not fn.endswith(".initiatedcall") and not fn.endswith(".pickedupcall") and not fn.endswith(".mutedring"):
try:
os.remove(os.path.join(CALLS_DIR, fn))
except Exception:
@@ -2362,16 +2408,26 @@ def sync_sub1_calls(calls, sim_slot):
open(os.path.join(CALLS_DIR, f"{call_key}.{st}"), "w").close()
except Exception:
pass
else:
for fn in os.listdir(CALLS_DIR):
if fn.startswith(f"{call_key}."):
try:
os.remove(os.path.join(CALLS_DIR, fn))
except Exception:
pass
if st == prev:
continue
active_calls[cid] = {"state": st, "num": num, "dir": c["dir"]}
if st == "ringing-in":
if has_mm_call_files():
del active_calls[cid]
continue
with open(os.path.join(LOG_DIR, "modemlog.tsv"), "a", encoding="utf-8") as f:
f.write(f"{now_str}\tcall_ring\t{num}\t[SIM {sim_slot}]\n")
send_fifo("/tmp/dwm_plugin_callscreen.fifo", f"INCOMING {call_key} {num} SIM{sim_slot}")
run_user_cmd(f"sxmo_hook_ring.sh '{num}'")
run_user_cmd(f"sxmo_jobs.sh start --group ringing sxmo_hook_ring.sh '{num}'")
elif st in ("dialing", "ringing-out"):
set_q6voiced_audio(True)
if prev not in ("dialing", "ringing-out"):
@@ -2379,18 +2435,17 @@ def sync_sub1_calls(calls, sim_slot):
f.write(f"{now_str}\tcall_dial\t{num}\t[SIM {sim_slot}]\n")
send_fifo("/tmp/dwm_plugin_callscreen.fifo", f"OUTGOING {call_key} {num} SIM{sim_slot}")
elif st == "active":
run_user_cmd("pkill -f sxmo_ring.sh || true; pkill -f mpv || true")
stop_ringing_user()
set_q6voiced_audio(True)
with open(os.path.join(LOG_DIR, "modemlog.tsv"), "a", encoding="utf-8") as f:
f.write(f"{now_str}\tcall_start\t{num}\t[SIM {sim_slot}]\n")
send_fifo("/tmp/dwm_plugin_callscreen.fifo", f"ACTIVE {call_key} {num} SIM{sim_slot}")
elif st == "terminated":
run_user_cmd("pkill -f sxmo_ring.sh || true")
stop_ringing_user()
evt = "call_missed" if prev == "ringing-in" else "call_hangup"
with open(os.path.join(LOG_DIR, "modemlog.tsv"), "a", encoding="utf-8") as f:
f.write(f"{now_str}\t{evt}\t{num}\t[SIM {sim_slot}]\n")
send_fifo("/tmp/dwm_plugin_callscreen.fifo", "ENDED CALL ENDED")
del active_calls[cid]
has_live = any(v["state"] in ("dialing", "ringing-out", "active", "held", "ringing-in", "waiting") for v in active_calls.values())
if not has_live:
@@ -2403,6 +2458,7 @@ def sync_sub1_calls(calls, sim_slot):
except Exception:
pass
if removed_stale:
stop_ringing_user()
send_fifo("/tmp/dwm_plugin_callscreen.fifo", "ENDED CALL ENDED")
if audio_opened:
set_q6voiced_audio(False)
@@ -8,6 +8,11 @@
# up the call).
# kill existing ring playback
rm -f /tmp/sxmo_call_ringing 2>/dev/null || true
sxmo_jobs.sh stop ringing
pkill -TERM -f sxmo_hook_ring.sh 2>/dev/null || true
pkill -TERM -f "pw-play.*ring" 2>/dev/null || true
pkill -TERM -f "mpv.*ring" 2>/dev/null || true
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
sxmo_playerctl.sh resume_all
@@ -7,6 +7,11 @@
# incoming call, i.e., ignore the call ringing in.
# kill existing ring playback
rm -f /tmp/sxmo_call_ringing 2>/dev/null || true
sxmo_jobs.sh stop ringing
pkill -TERM -f sxmo_hook_ring.sh 2>/dev/null || true
pkill -TERM -f "pw-play.*ring" 2>/dev/null || true
pkill -TERM -f "mpv.*ring" 2>/dev/null || true
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
sxmo_playerctl.sh resume_all
@@ -6,7 +6,12 @@
# This script is executed (asynchronously) when you pick up an incoming call
# kill existing ring playback
rm -f /tmp/sxmo_call_ringing 2>/dev/null || true
sxmo_jobs.sh stop ringing
pkill -TERM -f sxmo_hook_ring.sh 2>/dev/null || true
pkill -TERM -f "pw-play.*ring" 2>/dev/null || true
pkill -TERM -f "mpv.*ring" 2>/dev/null || true
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
# Pause all player automatically
sxmo_playerctl.sh pause_all
@@ -83,6 +83,12 @@ if [ "$(cat /tmp/sxmo_active_call 2>/dev/null)" = "2" ]; then
exit 0
fi
# Prevent duplicate concurrent ringer instances
exec 9>"$XDG_RUNTIME_DIR/sxmo_ring.lock"
if ! flock -n 9; then
exit 0
fi
case "${SXMO_RINGVOL:-100}" in
''|*[!0-9]*) SXMO_RINGVOL=100 ;;
esac
@@ -93,10 +99,13 @@ if [ -r "$XDG_CONFIG_HOME/sxmo/speaker_vol" ]; then
read -r SAVED_SPK_VOL < "$XDG_CONFIG_HOME/sxmo/speaker_vol" 2>/dev/null || SAVED_SPK_VOL=85
fi
case "$SAVED_SPK_VOL" in ''|*[!0-9]*) SAVED_SPK_VOL=85 ;; esac
SAVED_RX3=$(( 60 + SAVED_SPK_VOL * 32 / 100 ))
SAVED_RX3=$(( 60 + SAVED_SPK_VOL * 24 / 100 ))
RING_PID=""
VIB_PID=""
WAIT_PID=""
SAW_RING_STATE=0
TICKS=0
is_call_picked_up() {
[ "$(cat /tmp/sxmo_active_call 2>/dev/null)" = "2" ] && return 0
@@ -106,13 +115,42 @@ is_call_picked_up() {
return 1
}
has_ringing_call_files() {
[ -e /tmp/sxmo_call_ringing ] && return 0
for f in "$XDG_RUNTIME_DIR"/sxmo_calls/*.monitoredcall "$XDG_RUNTIME_DIR"/sxmo_calls/*.ringing-in; do
[ -e "$f" ] && return 0
done
return 1
}
should_stop_ringing() {
is_call_picked_up && return 0
for f in "$XDG_RUNTIME_DIR"/sxmo_calls/*.mutedring \
"$XDG_RUNTIME_DIR"/sxmo_calls/*.discardedcall \
"$XDG_RUNTIME_DIR"/sxmo_calls/*.hangedupcall; do
[ -e "$f" ] && return 0
done
if [ "$SAW_RING_STATE" -eq 1 ] || [ "$TICKS" -ge 10 ]; then
if ! has_ringing_call_files; then
return 0
fi
fi
return 1
}
finish() {
trap - INT TERM EXIT
[ -n "$WAIT_PID" ] && kill -TERM "$WAIT_PID" 2>/dev/null || true
[ -n "$RING_PID" ] && pkill -TERM -P "$RING_PID" 2>/dev/null || true
[ -n "$VIB_PID" ] && pkill -TERM -P "$VIB_PID" 2>/dev/null || true
[ -n "$RING_PID" ] && kill -TERM "$RING_PID" 2>/dev/null || true
[ -n "$VIB_PID" ] && kill -TERM "$VIB_PID" 2>/dev/null || true
pkill -TERM -P "$$" 2>/dev/null || true
if [ -n "${SXMO_RINGTONE:-}" ]; then
pkill -TERM -f "pw-play.*$SXMO_RINGTONE" 2>/dev/null || true
pkill -TERM -f "mpv.*$SXMO_RINGTONE" 2>/dev/null || true
fi
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
if ! is_call_picked_up; then
amixer -c 0 cset "name='RX3 Digital Volume'" "$SAVED_RX3" >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SAVED_SPK_VOL}%" >/dev/null 2>&1 || true
@@ -132,7 +170,7 @@ ring() {
if [ "${SXMO_RINGVOL:-100}" -le 0 ] || [ -z "${SXMO_RINGTONE:-}" ] || [ ! -f "$SXMO_RINGTONE" ]; then
return 0
fi
ring_rx3=$(( 60 + SXMO_RINGVOL * 34 / 100 ))
ring_rx3=$(( 60 + SXMO_RINGVOL * 24 / 100 ))
pw_vol="$(awk -v v="$SXMO_RINGVOL" 'BEGIN { printf "%.2f", v / 100.0 }')"
(
@@ -154,7 +192,7 @@ EOF
(
for d in 0.15 0.40; do
sleep "$d" || exit 0
is_call_picked_up && exit 0
should_stop_ringing && exit 0
amixer -c 0 -s >/dev/null 2>&1 <<EOF || true
cset "name='SPK DAC Switch'" 1
cset "name='RX3 MIX1 INP1'" 3
@@ -177,7 +215,9 @@ EOF
if [ "$use_pw" -eq 1 ]; then
i=0
while [ "$i" -lt "$loops" ]; do
is_call_picked_up && break
should_stop_ringing && break
amixer -c 0 cset "name='RX3 Digital Volume'" "$ring_rx3" >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true
pw-play --volume="$pw_vol" "$SXMO_RINGTONE" >/dev/null 2>&1 &
rchild="$!"
wait "$rchild" 2>/dev/null
@@ -188,6 +228,7 @@ EOF
break
fi
i=$(( i + 1 ))
should_stop_ringing && break
sleep 0.2 &
rchild="$!"
wait "$rchild" 2>/dev/null || break
@@ -195,7 +236,7 @@ EOF
done
fi
if [ "$use_pw" -eq 0 ] && ! is_call_picked_up; then
if [ "$use_pw" -eq 0 ] && ! should_stop_ringing; then
mpv --no-config --no-terminal --no-resume-playback --quiet --vo=null --no-video \
--ao=pipewire,pulse,alsa --audio-channels=stereo --audio-samplerate=48000 \
--volume-max=150 --volume="$SXMO_RINGVOL" \
@@ -213,12 +254,13 @@ vibrate() {
vchild=""
trap '[ -n "$vchild" ] && kill -TERM "$vchild" 2>/dev/null; exit 0' INT TERM EXIT
while : ; do
is_call_picked_up && exit 0
should_stop_ringing && exit 0
sxmo_vibrate 1500 "$SXMO_VIBRATE_STRENGTH" &
vchild="$!"
wait "$vchild" 2>/dev/null || exit 0
vchild=""
should_stop_ringing && exit 0
sleep 0.5 &
vchild="$!"
wait "$vchild" 2>/dev/null || exit 0
@@ -230,6 +272,10 @@ vibrate() {
trap 'finish' INT TERM EXIT
if has_ringing_call_files; then
SAW_RING_STATE=1
fi
# RING & VIBRATE MODE (DEFAULT)
if [ ! -f "$XDG_CONFIG_HOME/sxmo/.noring" ] && [ ! -f "$XDG_CONFIG_HOME/sxmo/.novibrate" ]; then
sxmo_log "RING AND VIBRATE ($SXMO_RINGTONE, vol=${SXMO_RINGVOL}%, vib=${SXMO_VIBRATE_STRENGTH})"
@@ -249,6 +295,18 @@ elif [ ! -f "$XDG_CONFIG_HOME/sxmo/.novibrate" ] && [ -f "$XDG_CONFIG_HOME/sxmo/
vibrate
fi
sleep "${SXMO_RINGTIME:-20}" &
wait "$!"
MAX_TICKS=$(( ${SXMO_RINGTIME:-20} * 5 ))
while [ "$TICKS" -lt "$MAX_TICKS" ]; do
if [ "$SAW_RING_STATE" -eq 0 ] && has_ringing_call_files; then
SAW_RING_STATE=1
fi
if should_stop_ringing; then
break
fi
sleep 0.2 &
WAIT_PID="$!"
wait "$WAIT_PID" 2>/dev/null || break
WAIT_PID=""
TICKS=$(( TICKS + 1 ))
done
finish
Binary file not shown.
Binary file not shown.
Binary file not shown.
+36 -15
View File
@@ -1178,6 +1178,15 @@ int callscreen_run_main(int argc, char** argv) {
return callId;
};
auto stopRingingJobs = [&]() {
::unlink("/tmp/sxmo_call_ringing");
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
"pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; "
"pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; "
"pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; "
"pkill -TERM -x sxmo_vibrate >/dev/null 2>&1");
};
auto acceptIncomingCall = [&]() {
if (callState != CallState::Incoming) {
return;
@@ -1190,13 +1199,12 @@ int callscreen_run_main(int argc, char** argv) {
dtmfSent.clear();
selectedRow = 0;
writeActiveStateFiles();
stopRingingJobs();
setSpeakerRoute(false);
render();
if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
runAsyncArgv("sxmo_modemcall.sh", "pickup", cid.c_str());
} else {
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1");
}
};
@@ -1205,11 +1213,10 @@ int callscreen_run_main(int argc, char** argv) {
return;
}
ringMuted = true;
stopRingingJobs();
std::string cid = resolveActiveModemCallId();
if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
runAsyncArgv("sxmo_modemcall.sh", "mute", cid.c_str());
} else {
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1");
}
statusNotice = "Ringtone silenced";
statusNoticeUntilMs = nowMs() + 2500;
@@ -1221,12 +1228,6 @@ int callscreen_run_main(int argc, char** argv) {
if (micMuted) {
setMicMuted(false);
}
alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false);
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false);
alsa.setEnum("EAR_S", 0);
alsa.setEnum("RX3 MIX1 INP1", 3);
alsa.setBoolean("SPK DAC Switch", true);
runAsyncCmd("sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1");
if (callStartMs > 0 &&
(callState == CallState::Active || callState == CallState::Outgoing)) {
lastFinalDurationSec = static_cast<int>((nowMs() - callStartMs) / 1000);
@@ -1239,17 +1240,29 @@ int callscreen_run_main(int argc, char** argv) {
dtmfMode = false;
ringMuted = false;
writeActiveStateFiles();
stopRingingJobs();
alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false);
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false);
alsa.setEnum("EAR_S", 0);
alsa.setEnum("RX3 MIX1 INP1", 3);
alsa.setBoolean("SPK DAC Switch", true);
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
"pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; "
"pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; "
"pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; "
"pkill -TERM -x sxmo_vibrate >/dev/null 2>&1; "
"sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1");
render();
};
auto hangupCall = [&]() {
std::string cid = resolveActiveModemCallId();
bool wasIncoming = (callState == CallState::Incoming);
stopRingingJobs();
if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
runAsyncArgv("sxmo_modemcall.sh", "hangup", cid.c_str());
} else {
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
"mmcli -m any --voice-hangup-all >/dev/null 2>&1");
runAsyncCmd("mmcli -m any --voice-hangup-all >/dev/null 2>&1");
}
transitionToEnded(wasIncoming ? "CALL REJECTED" : "CALL ENDED");
};
@@ -1516,8 +1529,9 @@ int callscreen_run_main(int argc, char** argv) {
callState = CallState::Active;
callStartMs = nowMs();
ringMuted = false;
setSpeakerRoute(speakerOn);
writeActiveStateFiles();
stopRingingJobs();
setSpeakerRoute(speakerOn);
render();
} else if (foundState == "ringing-in" && callState == CallState::Idle) {
callState = CallState::Incoming;
@@ -1543,8 +1557,15 @@ int callscreen_run_main(int argc, char** argv) {
struct dirent* ent;
while ((ent = ::readdir(d)) != nullptr) {
if (ent->d_name[0] != '.' && ent->d_name[0] != '\0') {
std::string fpPath = callsDir + "/" + ent->d_name;
::unlink(fpPath.c_str());
std::string fn(ent->d_name);
if (fn.rfind("sub", 0) == 0 ||
fn.find(".ringing-in") != std::string::npos ||
fn.find(".dialing") != std::string::npos ||
fn.find(".ringing-out") != std::string::npos ||
fn.find(".active") != std::string::npos) {
std::string fpPath = callsDir + "/" + fn;
::unlink(fpPath.c_str());
}
}
}
::closedir(d);
+67 -35
View File
@@ -760,9 +760,10 @@ int runModemApp(int argc, char** argv) {
10, cardY + 2, 22, kIconSim);
std::string title = "SIM Slot " + std::to_string(s.slotNum);
if (status.dualSimActive &&
(s.isActiveProvisioned || s.isSecondaryProvisioned)) {
title += s.isPreferred ? " [ACTIVE / DEFAULT]" : " [ACTIVE / DSDS]";
if (status.dualSimActive && s.isActiveProvisioned) {
title += s.isPreferred ? " [PRI 4G / DEFAULT]" : " [PRI 4G / DSDS]";
} else if (status.dualSimActive && s.isSecondaryProvisioned) {
title += s.isPreferred ? " [SEC 2G / DEFAULT]" : " [SEC 2G / DSDS]";
} else if (s.isActiveProvisioned) {
title += " [ACTIVE]";
} else if (s.isSecondaryProvisioned) {
@@ -854,23 +855,28 @@ int runModemApp(int argc, char** argv) {
10, cardY + 44, 18, line3, 220);
}
// Quick Action Rows below the 2 SIM cards (4 rows, 24px each)
// Quick Action Rows below the 2 SIM cards (5 rows, 19px each)
int actSlot = (simRowSel == 1) ? 2 : 1;
int otherSlot = (status.preferredSlot == 1) ? 2 : 1;
int otherGwSlot = (status.primaryGwSlot == 1) ? 2 : 1;
if (status.primaryGwSlot == 0) {
if (status.slots[1].state == "present" && status.slots[0].state != "present") {
otherSlot = 2;
otherGwSlot = 2;
} else if (status.slots[0].state == "present" && status.slots[1].state != "present") {
otherSlot = 1;
otherGwSlot = 1;
}
}
std::string quickRows[4] = {
std::string quickRows[5] = {
std::string(kIconRefresh) +
(status.primaryGwSlot == 0
? (" Activate SIM " + std::to_string(otherSlot))
: (status.dualSimActive
? (" Set Default SIM to Slot " + std::to_string(otherSlot))
: (" Switch Active to SIM " + std::to_string(otherSlot)))),
std::string(kIconSignal) + " Swap Primary (4G/Data) to Slot " +
std::to_string(otherGwSlot),
std::string(kIconUnlock) + " Unlock SIM (PIN / PUK)",
std::string(kIconLock) + " Enable / Disable SIM PIN",
std::string(kIconKey) + " Change SIM PIN Code",
@@ -878,13 +884,13 @@ int runModemApp(int argc, char** argv) {
(void)actSlot;
int baseY = contentY + 142;
for (int r = 0; r < 4; ++r) {
int ry = baseY + r * 23;
for (int r = 0; r < 5; ++r) {
int ry = baseY + r * 19;
bool isSel = (simRowSel == (r + 2));
XSetForeground(dpy, gc, isSel ? pt.spec.selBg : ((r % 2 == 0) ? pt.spec.bgAltEven : pt.spec.bgAltOdd));
XFillRectangle(dpy, pix, gc, 4, ry, kWinWidth - 8, 22);
XFillRectangle(dpy, pix, gc, 4, ry, kWinWidth - 8, 18);
drawPango(layoutSmall, isSel ? &colWhite : &colLight,
10, ry, 22, quickRows[r], kWinWidth - 20);
10, ry, 18, quickRows[r], kWinWidth - 20);
}
drawSoftkeyBar("Actions", "Select", "Close");
@@ -1085,27 +1091,28 @@ int runModemApp(int argc, char** argv) {
// Modal Overlays
if (modal == ModalMode::SimActions) {
XSetForeground(dpy, gc, pt.spec.bgOverlay);
XFillRectangle(dpy, pix, gc, 12, 44, kWinWidth - 24, 196);
XFillRectangle(dpy, pix, gc, 12, 38, kWinWidth - 24, 214);
XSetForeground(dpy, gc, pt.spec.accent);
XDrawRectangle(dpy, pix, gc, 12, 44, kWinWidth - 25, 195);
XDrawRectangle(dpy, pix, gc, 12, 38, kWinWidth - 25, 213);
std::string hdr = "SIM Slot " + std::to_string(targetSlot) + " Actions";
drawPango(layoutMain, &colYellow, 20, 48, 24, hdr, kWinWidth - 40);
drawPango(layoutMain, &colYellow, 20, 42, 22, hdr, kWinWidth - 40);
const char* actLabels[5] = {
"Set as Default / Primary SIM",
const char* actLabels[6] = {
"Set as Default SIM (Fast)",
"Make Primary GW (4G/Data Swap)",
"Unlock SIM (Enter PIN)",
"Unblock SIM (Enter PUK)",
"Enable / Disable SIM PIN",
"Change SIM PIN Code",
};
for (int i = 0; i < 5; ++i) {
int ry = 76 + i * 30;
for (int i = 0; i < 6; ++i) {
int ry = 68 + i * 29;
bool isSel = (actionSel == i);
XSetForeground(dpy, gc, isSel ? pt.spec.selBg : pt.spec.bgButton);
XFillRectangle(dpy, pix, gc, 18, ry, kWinWidth - 36, 26);
XFillRectangle(dpy, pix, gc, 18, ry, kWinWidth - 36, 25);
drawPango(layoutSmall, isSel ? &colWhite : &colLight,
24, ry, 26, actLabels[i], kWinWidth - 48);
24, ry, 25, actLabels[i], kWinWidth - 48);
}
drawSoftkeyBar("Select", "OK", "Back");
} else if (modal == ModalMode::VerifyPin ||
@@ -1312,13 +1319,22 @@ int runModemApp(int argc, char** argv) {
::unlink(activePidPath.c_str());
};
auto switchSimSlotNow = [&](int slotNum) {
auto switchSimSlotNow = [&](int slotNum, bool swapGw = false) {
slotNum = std::clamp(slotNum, 1, 2);
setBanner("Switching active SIM to Slot " + std::to_string(slotNum) + "...");
if (swapGw) {
setBanner("Swapping Primary (4G/Data) to Slot " + std::to_string(slotNum) + "...");
} else {
setBanner("Setting Default SIM to Slot " + std::to_string(slotNum) + "...");
}
render();
int rc = 0;
runCaptureCmd("doas -n /usr/libexec/msm-modem-uim-selection switch " +
std::to_string(slotNum) + " >/dev/null 2>&1", &rc);
std::string cmd = "doas -n /usr/libexec/msm-modem-uim-selection switch " +
std::to_string(slotNum);
if (swapGw) {
cmd += " --swap-gw";
}
cmd += " >/dev/null 2>&1";
runCaptureCmd(cmd, &rc);
runAsyncCmd("sxmo_hook_statusbar.sh modem >/dev/null 2>&1");
refreshData(false);
if (status.slots[slotNum - 1].needsPin() ||
@@ -1327,7 +1343,11 @@ int runModemApp(int argc, char** argv) {
return;
}
if (rc == 0) {
setBanner("Active SIM set to Slot " + std::to_string(slotNum));
if (swapGw) {
setBanner("Primary (4G/Data) swapped to Slot " + std::to_string(slotNum));
} else {
setBanner("Default SIM set to Slot " + std::to_string(slotNum));
}
} else {
setBanner("Failed to switch SIM slot");
}
@@ -1524,16 +1544,26 @@ int runModemApp(int argc, char** argv) {
otherSlot = 1;
}
}
switchSimSlotNow(otherSlot);
switchSimSlotNow(otherSlot, false);
} else if (row == 3) {
openPinOrPukModalForSlot(defaultActiveOrPresentSlot());
int otherGwSlot = (status.primaryGwSlot == 1) ? 2 : 1;
if (status.primaryGwSlot == 0) {
if (status.slots[1].state == "present" && status.slots[0].state != "present") {
otherGwSlot = 2;
} else if (status.slots[0].state == "present" && status.slots[1].state != "present") {
otherGwSlot = 1;
}
}
switchSimSlotNow(otherGwSlot, true);
} else if (row == 4) {
openPinOrPukModalForSlot(defaultActiveOrPresentSlot());
} else if (row == 5) {
targetSlot = defaultActiveOrPresentSlot();
wizardStep = 0;
inputPin1.clear();
modalError.clear();
modal = ModalMode::TogglePinLock;
} else if (row == 5) {
} else if (row == 6) {
targetSlot = defaultActiveOrPresentSlot();
wizardStep = 0;
inputPin1.clear();
@@ -1572,30 +1602,32 @@ int runModemApp(int argc, char** argv) {
if (modal == ModalMode::SimActions) {
int act = actionSel;
modal = ModalMode::None;
if (act >= 1 && act <= 4 &&
if (act >= 2 && act <= 5 &&
status.slots[targetSlot - 1].state != "present") {
targetSlot = defaultActiveOrPresentSlot();
}
if (act == 0) {
switchSimSlotNow(targetSlot);
switchSimSlotNow(targetSlot, false);
} else if (act == 1) {
switchSimSlotNow(targetSlot, true);
} else if (act == 2) {
wizardStep = 0;
inputPin1.clear();
modalError.clear();
modal = ModalMode::VerifyPin;
} else if (act == 2) {
} else if (act == 3) {
wizardStep = 0;
inputPin1.clear();
inputPin2.clear();
inputPin3.clear();
modalError.clear();
modal = ModalMode::UnblockPuk;
} else if (act == 3) {
} else if (act == 4) {
wizardStep = 0;
inputPin1.clear();
modalError.clear();
modal = ModalMode::TogglePinLock;
} else if (act == 4) {
} else if (act == 5) {
wizardStep = 0;
inputPin1.clear();
inputPin2.clear();
@@ -1868,10 +1900,10 @@ int runModemApp(int argc, char** argv) {
if (modal == ModalMode::SimActions) {
if (sym == XK_Up || sym == XK_KP_Up) {
actionSel = (actionSel + 4) % 5;
actionSel = (actionSel + 5) % 6;
render();
} else if (sym == XK_Down || sym == XK_KP_Down) {
actionSel = (actionSel + 1) % 5;
actionSel = (actionSel + 1) % 6;
render();
} else if (sym == XK_Return || sym == XK_KP_Enter) {
handleEnterKey();
@@ -2005,7 +2037,7 @@ int runModemApp(int argc, char** argv) {
render();
} else if (sym == XK_Up || sym == XK_KP_Up) {
if (activeTab == TabId::SimCards) {
simRowSel = (simRowSel + 5) % 6;
simRowSel = (simRowSel + 6) % 7;
} else if (activeTab == TabId::RadioInfo) {
radioRowSel = (radioRowSel + 4) % 5;
} else if (activeTab == TabId::AtConsole) {
@@ -2020,7 +2052,7 @@ int runModemApp(int argc, char** argv) {
render();
} else if (sym == XK_Down || sym == XK_KP_Down) {
if (activeTab == TabId::SimCards) {
simRowSel = (simRowSel + 1) % 6;
simRowSel = (simRowSel + 1) % 7;
} else if (activeTab == TabId::RadioInfo) {
radioRowSel = (radioRowSel + 1) % 5;
} else if (activeTab == TabId::AtConsole) {
+1 -1
View File
@@ -354,7 +354,7 @@ int runRingtonesApp(int argc, char** argv) {
stopPreview();
settings = loadRingSettings();
int rvol = std::clamp(settings.ringVol, 0, 100);
int rx3 = (rvol <= 0) ? 0 : (60 + rvol * 34 / 100);
int rx3 = (rvol <= 0) ? 0 : (60 + rvol * 24 / 100);
int mpvVol = rvol;
std::string volArg = "--volume=" + std::to_string(mpvVol);
runAsyncCmd("amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; "