Fix background call hangup and end calls on screen lock or lid close
This commit is contained in:
1 parent
c7cdde6734
commit
0c352f0a10
55 files changed
+391
-120
No files matched your search
Binary file not shown.
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
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.
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.
@@ -2046,6 +2046,14 @@ if sub_cmd == "call-dial":
|
||||
num = "".join(c for c in arg2 if c in "+0123456789*#").encode("ascii")
|
||||
if not num:
|
||||
sys.exit(1)
|
||||
calls_dir = "/run/user/10000/sxmo_calls"
|
||||
dial_marker = os.path.join(calls_dir, f"sub{sub}_dialing.initiatedcall")
|
||||
try:
|
||||
os.makedirs(calls_dir, exist_ok=True)
|
||||
open(dial_marker, "w").close()
|
||||
os.chown(dial_marker, 10000, 10000)
|
||||
except Exception:
|
||||
pass
|
||||
s = socket.socket(AF_QIPCRTR, socket.SOCK_DGRAM)
|
||||
qmi_req(s, 1, 0x0044, struct.pack("<BHB", 0x01, 1, sub))
|
||||
tlvs = qmi_req(s, 2, 0x0020, struct.pack("<BH", 0x01, len(num)) + num, timeout=5.0)
|
||||
@@ -2056,28 +2064,70 @@ if sub_cmd == "call-dial":
|
||||
subprocess.run(["dbus-send", "--system", "--type=signal", "/", "org.ofono.VoiceCallManager.CallAdded"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
cid = tlvs.get(0x10, b"\x01")[0]
|
||||
prefix = f"sub{sub}_"
|
||||
try:
|
||||
cid_marker = os.path.join(calls_dir, f"{prefix}{cid}.initiatedcall")
|
||||
open(cid_marker, "w").close()
|
||||
os.chown(cid_marker, 10000, 10000)
|
||||
if os.path.exists(dial_marker):
|
||||
os.remove(dial_marker)
|
||||
except Exception:
|
||||
pass
|
||||
print(f"{prefix}{cid}")
|
||||
sys.exit(0)
|
||||
try:
|
||||
if os.path.exists(dial_marker):
|
||||
os.remove(dial_marker)
|
||||
except Exception:
|
||||
pass
|
||||
sys.exit(1)
|
||||
|
||||
elif sub_cmd in ("call-accept", "call-hangup", "call-dtmf"):
|
||||
import subprocess
|
||||
if sub_cmd == "call-hangup" and arg1 in ("", "-", "all"):
|
||||
any_ended = False
|
||||
txn = 1
|
||||
for sub in (1, 0):
|
||||
s = socket.socket(AF_QIPCRTR, socket.SOCK_DGRAM)
|
||||
qmi_req(s, txn, 0x0044, struct.pack("<BHB", 0x01, 1, sub))
|
||||
txn += 1
|
||||
calls = parse_call_info(qmi_req(s, txn, 0x002F))
|
||||
txn += 1
|
||||
for cid, c in calls.items():
|
||||
if c["state"] not in (8, 9):
|
||||
tlvs = qmi_req(s, txn, 0x0021, struct.pack("<BHB", 0x01, 1, cid))
|
||||
txn += 1
|
||||
res_tlv = tlvs.get(0x02, b"")
|
||||
if len(res_tlv) >= 4 and struct.unpack("<HH", res_tlv[:4]) == (0, 0):
|
||||
any_ended = True
|
||||
s.close()
|
||||
if any_ended:
|
||||
subprocess.run(["dbus-send", "--system", "--type=signal", "/", "org.ofono.VoiceCallManager.CallRemoved"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
sys.exit(0)
|
||||
sys.exit(1)
|
||||
|
||||
# Target sub=1 by default or parse sub1_<id>
|
||||
target_sub = 1
|
||||
target_cid = 0
|
||||
if arg1.startswith("sub0_"):
|
||||
target_sub = 0
|
||||
target_cid = int(arg1.split("_", 1)[1])
|
||||
try:
|
||||
target_cid = int(arg1.split("_", 1)[1])
|
||||
except Exception:
|
||||
target_cid = 0
|
||||
elif arg1.startswith("sub1_"):
|
||||
target_sub = 1
|
||||
target_cid = int(arg1.split("_", 1)[1])
|
||||
try:
|
||||
target_cid = int(arg1.split("_", 1)[1])
|
||||
except Exception:
|
||||
target_cid = 0
|
||||
elif arg1.isdigit() and sub_cmd != "call-dtmf":
|
||||
target_cid = int(arg1)
|
||||
|
||||
s = socket.socket(AF_QIPCRTR, socket.SOCK_DGRAM)
|
||||
qmi_req(s, 1, 0x0044, struct.pack("<BHB", 0x01, 1, target_sub))
|
||||
if target_cid == 0:
|
||||
calls = parse_call_info(qmi_req(s, 2, 0x002F))
|
||||
calls = parse_call_info(qmi_req(s, 2, 0x002F))
|
||||
if target_cid == 0 or (sub_cmd == "call-hangup" and target_cid not in calls):
|
||||
target_cid = 0
|
||||
for cid, c in calls.items():
|
||||
if sub_cmd == "call-accept" and c["state"] in (2, 7):
|
||||
target_cid = cid
|
||||
@@ -2094,6 +2144,11 @@ elif sub_cmd in ("call-accept", "call-hangup", "call-dtmf"):
|
||||
tlvs = qmi_req(s, 3, 0x0022, struct.pack("<BHB", 0x01, 1, target_cid))
|
||||
elif sub_cmd == "call-hangup":
|
||||
tlvs = qmi_req(s, 3, 0x0021, struct.pack("<BHB", 0x01, 1, target_cid))
|
||||
txn = 4
|
||||
for cid, c in calls.items():
|
||||
if cid != target_cid and c["state"] not in (8, 9):
|
||||
qmi_req(s, txn, 0x0021, struct.pack("<BHB", 0x01, 1, cid))
|
||||
txn += 1
|
||||
subprocess.run(["dbus-send", "--system", "--type=signal", "/", "org.ofono.VoiceCallManager.CallRemoved"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
else:
|
||||
ch = (arg1[-1] if arg1 else "0").encode("ascii")[:1]
|
||||
@@ -2764,7 +2819,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}.") and not fn.endswith(".initiatedcall") and not fn.endswith(".pickedupcall") and not fn.endswith(".mutedring"):
|
||||
if fn == "sub1_dialing.initiatedcall" or (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:
|
||||
@@ -2942,7 +2997,8 @@ while True:
|
||||
if not got_voice_ind and (active_calls or has_sub1_call_files()):
|
||||
full_tlvs = qmi_req(vs, voice_addr, v_txn, 0x002F)
|
||||
v_txn = (v_txn % 60000) + 1
|
||||
sync_sub1_calls(parse_call_info(full_tlvs), sec_slot)
|
||||
if full_tlvs:
|
||||
sync_sub1_calls(parse_call_info(full_tlvs), sec_slot)
|
||||
|
||||
if not os.path.exists("/tmp/bananarchy_screen_locked") and time.time() - last_poll >= 600.0:
|
||||
w_txn = poll_stored_sms(ws, wms_addr, w_txn, sec_slot)
|
||||
|
||||
@@ -17,6 +17,16 @@ cur_state=""
|
||||
printf '1\n' > /tmp/bananarchy_screen_locked
|
||||
pkill -STOP -x conky 2>/dev/null || true
|
||||
|
||||
if ! sxmo_jobs.sh running proximity_lock -q; then
|
||||
if [ -f /tmp/sxmo_call_ringing ] || [ -f /tmp/sxmo_active_call ] || [ -n "$(ls -A "$XDG_RUNTIME_DIR/sxmo_calls" 2>/dev/null)" ]; then
|
||||
rm -f /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
|
||||
if [ -p /tmp/dwm_plugin_callscreen.fifo ]; then
|
||||
printf 'HANGUP_CLOSE\n' > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
|
||||
fi
|
||||
sxmo_modemcall.sh hangup all >/dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$SXMO_DISABLE_LEDS" ]; then
|
||||
sxmo_led.sh blink blue &
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user