Fix background call hangup and end calls on screen lock or lid close

This commit is contained in:
Luxferre committed 2026-11-04 17:59:19 +02:00
1 parent c7cdde6734
commit 0c352f0a10
55 files changed
+391 -120

No files matched your search

Binary file not shown.
+21 -4
View File
@@ -2,6 +2,10 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
export HOME="${HOME:-/home/user}"
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/10000}"
export PATH="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:$PATH"
# include common definitions
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
. sxmo_hook_icons.sh
@@ -127,13 +131,23 @@ pickup() {
}
hangup() {
CALLID="$1"
CALLID="${1:-all}"
case "$CALLID" in
""|"-"|"all")
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/"* /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
mmcli -m any --voice-hangup-all >/dev/null 2>&1 || true
doas -n /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || \
/usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || true
doas -n dbus-send --system --type=signal / org.ofono.VoiceCallManager.CallRemoved >/dev/null 2>&1 || true
sxmo_hook_hangup.sh || true
return 0
;;
sub1_*|sub0_*)
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}."* 2>/dev/null || true
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}."* "$XDG_RUNTIME_DIR/sxmo_calls/sub1_dialing."* /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
doas -n /usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 || \
/usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 || true
/usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 || \
doas -n /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || true
doas -n dbus-send --system --type=signal / org.ofono.VoiceCallManager.CallRemoved >/dev/null 2>&1 || true
sxmo_hook_hangup.sh || true
return 0
@@ -155,10 +169,13 @@ hangup() {
# this call was never picked up and hung up immediately, so it is a discarded call
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.discardedcall" || true
fi
rm -f /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
HANGUP_FAILED=0
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
! mmcli -m any --voice-hangup-all 2>/dev/null && \
! doas -n /usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 && \
! doas -n /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1; then
# we ignore already closed calls
if list_active_calls | grep -q "/$CALLID "; then
HANGUP_FAILED=1
+14 -6
View File
@@ -2,6 +2,10 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
export HOME="${HOME:-/home/user}"
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/10000}"
export PATH="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:$PATH"
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
@@ -57,8 +61,7 @@ dial_number() {
sxmo_log "Attempting to dial on Secondary GW (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
fi
if command -v xcallscreen >/dev/null 2>&1; then
elif command -v xcallscreen >/dev/null 2>&1; then
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
@@ -68,13 +71,19 @@ dial_number() {
sxmo_notify_user.sh --urgency=critical "We failed to initiate call on SIM $TARGET_SIM"
return 1
fi
rm "$XDG_RUNTIME_DIR/sxmo_calls/$CALLID."* 2>/dev/null || true
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
sxmo_hook_dial.sh || true
sxmo_modemaudio.sh setup_audio || 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
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
@@ -93,8 +102,7 @@ dial_number() {
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
fi
if command -v xcallscreen >/dev/null 2>&1; then
elif command -v xcallscreen >/dev/null 2>&1; then
xcallscreen outgoing "-" "$NUMBER" >/dev/null 2>&1 || true
fi