Fix instant QMI call hangup, eliminate post-call dialer/callscreen popups and desktop clock flicker

This commit is contained in:
Luxferre committed 2026-11-05 09:51:53 +02:00
1 parent 1d71bc81d8
commit c9c870c3bb
27 files changed
+867 -308

No files matched your search

+90 -59
View File
@@ -19,7 +19,13 @@ if [ "${1:-}" = "--sim" ] && [ -n "${2:-}" ]; then
fi
resolve_sim_state() {
UIM_ST="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)"
UIM_ST=""
if [ -r /tmp/sxmo_sim_slots ]; then
UIM_ST="$(cat /tmp/sxmo_sim_slots 2>/dev/null || true)"
fi
if [ -z "$UIM_ST" ]; then
UIM_ST="$(doas -n /usr/libexec/msm-modem-uim-selection slots 2>/dev/null || /usr/libexec/msm-modem-uim-selection slots 2>/dev/null || true)"
fi
PRIM_SLOT="$(printf "%s\n" "$UIM_ST" | awk -F= '/^PRIMARY_GW_SLOT=/ {print $2; exit}')"
SEC_SLOT="$(printf "%s\n" "$UIM_ST" | awk -F= '/^SECONDARY_GW_SLOT=/ {print $2; exit}')"
PREF_SLOT="$(printf "%s\n" "$UIM_ST" | awk -F= '/^PREFERRED_SLOT=/ {print $2; exit}')"
@@ -31,24 +37,29 @@ resolve_sim_state() {
}
dial_number() {
# on pinephone if you attempt to make a call while in a call, modem crashes
if sxmo_modemcall.sh list_active_calls | grep -q .; then
sxmo_notify_user.sh "Cannot make call while in a call (for now)."
return 0
fi
NUMBER="$(printf "%s" "$1" | tr -cd '+0-9*#')"
if [ -z "$NUMBER" ]; then
return 1
fi
rm -f /tmp/sxmo_hangup_requested 2>/dev/null || true
# on pinephone if you attempt to make a call while in a call, modem crashes
if [ "$(cat /tmp/sxmo_active_call 2>/dev/null)" = "1" ] && sxmo_modemcall.sh list_active_calls | grep -q .; then
sxmo_notify_user.sh "Cannot make call while in a call (for now)."
return 0
fi
resolve_sim_state
[ -f /tmp/sxmo_hangup_requested ] && return 0
TARGET_SIM="$REQ_SIM_SLOT"
# If 2 SIMs are active and no SIM was chosen yet, prompt via xcallscreen
if [ -z "$TARGET_SIM" ] && [ "$DUAL_ACTIVE" = "1" ]; then
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ] && command -v xcallscreen >/dev/null 2>&1; then
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ]; then
printf "PROMPT_SIM %s\n" "$NUMBER" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
return 0
elif command -v xcallscreen >/dev/null 2>&1; then
xcallscreen >/dev/null 2>&1 || true
return 0
fi
@@ -65,39 +76,32 @@ dial_number() {
xcallscreen outgoing "-" "$NUMBER" >/dev/null 2>&1 || true
fi
if ! CALLID="$(doas -n /usr/libexec/msm-modem-uim-selection call-dial "$TARGET_SIM" "$NUMBER" 2>/dev/null || /usr/libexec/msm-modem-uim-selection call-dial "$TARGET_SIM" "$NUMBER" 2>/dev/null)"; then
if command -v xcallscreen >/dev/null 2>&1; then
xcallscreen ended >/dev/null 2>&1 || true
if [ ! -f /tmp/sxmo_hangup_requested ]; then
if command -v xcallscreen >/dev/null 2>&1; then
xcallscreen ended >/dev/null 2>&1 || true
fi
sxmo_notify_user.sh --urgency=critical "We failed to initiate call on SIM $TARGET_SIM"
return 1
fi
sxmo_notify_user.sh --urgency=critical "We failed to initiate call on SIM $TARGET_SIM"
return 1
return 0
fi
if [ -f /tmp/sxmo_hangup_requested ]; then
doas -n /usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 || true
return 0
fi
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.terminated" \
"$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.hangedupcall" \
"$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.discardedcall" 2>/dev/null || true
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.initiatedcall"
doas -n dbus-send --system --type=signal / org.ofono.VoiceCallManager.CallAdded >/dev/null 2>&1 || true
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ]; then
printf "OUTGOING %s %s SIM%s\n" "$CALLID" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
fi
sxmo_hook_dial.sh || true
sxmo_modemaudio.sh setup_audio || true
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ]; then
if [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.active" ]; then
printf "ACTIVE %s %s SIM%s\n" "$CALLID" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
else
printf "OUTGOING %s %s SIM%s\n" "$CALLID" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
fi
elif command -v xcallscreen >/dev/null 2>&1; then
xcallscreen outgoing "$CALLID" "$NUMBER" >/dev/null 2>&1 || true
fi
sxmo_hook_statusbar.sh state &
return 0
fi
mm_state="$(mmcli -m any -K 2>/dev/null | awk -F':[[:space:]]*' '{gsub(/[[:space:]]+$/, "", $1); if ($1 == "modem.generic.state") {print $2; exit}}')"
if [ "$mm_state" = "disabled" ] || [ -z "$mm_state" ]; then
mmcli -m any -e >/dev/null 2>&1 || true
mmcli -m any --3gpp-register-home >/dev/null 2>&1 || true
sleep 1
fi
sxmo_log "Attempting to dial (SIM $TARGET_SIM): $NUMBER"
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ]; then
printf "OUTGOING - %s SIM%s\n" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
@@ -105,20 +109,42 @@ dial_number() {
xcallscreen outgoing "-" "$NUMBER" >/dev/null 2>&1 || true
fi
if ! CALLID="$(
CALLID="$(
mmcli -m any --voice-create-call="number=$NUMBER" 2>/dev/null |
grep -Eo "Call/[0-9]+" |
grep -oE "[0-9]+"
)"; then
if command -v xcallscreen >/dev/null 2>&1; then
xcallscreen ended >/dev/null 2>&1 || true
grep -oE "[0-9]+" || true
)"
if [ -z "$CALLID" ]; then
mmcli -m any -e >/dev/null 2>&1 || true
mmcli -m any --3gpp-register-home >/dev/null 2>&1 || true
sleep 1
[ -f /tmp/sxmo_hangup_requested ] && return 0
CALLID="$(
mmcli -m any --voice-create-call="number=$NUMBER" 2>/dev/null |
grep -Eo "Call/[0-9]+" |
grep -oE "[0-9]+" || true
)"
fi
if [ -z "$CALLID" ]; then
if [ ! -f /tmp/sxmo_hangup_requested ]; then
if command -v xcallscreen >/dev/null 2>&1; then
xcallscreen ended >/dev/null 2>&1 || true
fi
sxmo_notify_user.sh --urgency=critical "We failed to initiate call"
return 1
fi
sxmo_notify_user.sh --urgency=critical "We failed to initiate call"
return 1
return 0
fi
if [ -f /tmp/sxmo_hangup_requested ]; then
mmcli -m any -o "$CALLID" --hangup >/dev/null 2>&1 || true
mmcli -m any --voice-delete-call="$CALLID" >/dev/null 2>&1 || true
return 0
fi
# cleanup all dangling event files, ignore errors
rm "$XDG_RUNTIME_DIR/sxmo_calls/$CALLID."* 2>/dev/null || true
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/$CALLID."* 2>/dev/null || true
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.initiatedcall"
sxmo_log "Starting call with CALLID: $CALLID"
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ]; then
printf "OUTGOING %s %s SIM%s\n" "$CALLID" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
@@ -126,30 +152,35 @@ dial_number() {
xcallscreen outgoing "$CALLID" "$NUMBER" >/dev/null 2>&1 || true
fi
if ! mmcli -m any -o "$CALLID" --start >/dev/null 2>&1; then
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/$CALLID."* 2>/dev/null || true
mmcli -m any --voice-delete-call="$CALLID" >/dev/null 2>&1 || true
if [ ! -f /tmp/sxmo_hangup_requested ]; then
if command -v xcallscreen >/dev/null 2>&1; then
xcallscreen ended >/dev/null 2>&1 || true
fi
sxmo_notify_user.sh --urgency=critical "We failed to start the call"
return 1
fi
return 0
fi
if [ -f /tmp/sxmo_hangup_requested ]; then
mmcli -m any -o "$CALLID" --hangup >/dev/null 2>&1 || true
mmcli -m any --voice-delete-call="$CALLID" >/dev/null 2>&1 || true
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/$CALLID."* 2>/dev/null || true
return 0
fi
{
mkdir -p "$SXMO_LOGDIR" &&
printf "%s\tcall_start\t%s\t[SIM %s]\n" "$(date +%FT%H:%M:%S%z)" "$NUMBER" "$TARGET_SIM" >> "$SXMO_LOGDIR/modemlog.tsv"
} 2>/dev/null || true
sxmo_log "Invoking dial hook"
sxmo_hook_dial.sh
if ! sxmo_modemaudio.sh setup_audio; then
if command -v xcallscreen >/dev/null 2>&1; then
xcallscreen ended >/dev/null 2>&1 || true
fi
sxmo_notify_user.sh --urgency=critical "We failed to setup call audio"
mmcli -m any --voice-delete-call="$CALLID"
return 1
fi
if ! sxmo_modemcall.sh pickup "$CALLID"; then
if command -v xcallscreen >/dev/null 2>&1; then
xcallscreen ended >/dev/null 2>&1 || true
fi
sxmo_modemaudio.sh reset_audio
mmcli -m any --voice-delete-call="$CALLID"
return 1
fi
sxmo_hook_dial.sh || true
sxmo_modemaudio.sh setup_audio || true
sxmo_hook_statusbar.sh state &
sxmo_jobs.sh start incall_menu sxmo_modemcall.sh incall_menu
}
dial_ussd() {