Fix QMI USSD async response handling and prevent st terminal popup
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
MODEM="$1"
|
||||
TYPE="$2"
|
||||
MESSAGE="${3:-}"
|
||||
|
||||
# If xdialer, xmodem, or msm-modem-uim-selection ussd is actively handling USSD,
|
||||
# do not interfere with the active USSD session.
|
||||
RDIR="${XDG_RUNTIME_DIR:-/tmp}"
|
||||
if [ -f "$RDIR/xdialer.pid" ] || [ -f "$RDIR/xmodem.pid" ] || \
|
||||
pgrep -f "msm-modem-uim-selection ussd" >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
MM_IFACE="org.freedesktop.ModemManager1"
|
||||
DBUS_PROP_IFACE="org.freedesktop.DBus.Properties"
|
||||
USSD_IFACE="org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd"
|
||||
|
||||
if [ "$TYPE" = "NetworkNotification" ] || [ "$TYPE" = "NetworkRequest" ]; then
|
||||
MESSAGE="$(busctl --json=short call "$MM_IFACE" "$MODEM" "$DBUS_PROP_IFACE" Get ss "$USSD_IFACE" "$TYPE" 2>/dev/null | jq -r '.data[].data // empty' 2>/dev/null || true)"
|
||||
fi
|
||||
|
||||
if [ -z "$MESSAGE" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sxmo_notify_user.sh "USSD: $MESSAGE"
|
||||
Reference in New Issue
Block a user