Add Dual-SIM Dual Standby (DSDS), outgoing SIM selection, and instant charging icon update

This commit is contained in:
Luxferre committed 2026-10-27 11:36:00 +02:00
1 parent 5132deb4d8
commit 46f1255905
28 files changed
+2560 -280

No files matched your search

+76 -4
View File
@@ -8,8 +8,25 @@
set -e
dial_number() {
REQ_SIM_SLOT="${SXMO_SIM_SLOT:-}"
if [ "${1:-}" = "--sim" ] && [ -n "${2:-}" ]; then
REQ_SIM_SLOT="$2"
shift 2
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)"
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}')"
DUAL_ACTIVE="$(printf "%s\n" "$UIM_ST" | awk -F= '/^DUAL_SIM_ACTIVE=/ {print $2; exit}')"
[ -n "$PRIM_SLOT" ] || PRIM_SLOT="1"
[ -n "$SEC_SLOT" ] || SEC_SLOT="0"
[ -n "$PREF_SLOT" ] || PREF_SLOT="$PRIM_SLOT"
[ -n "$DUAL_ACTIVE" ] || DUAL_ACTIVE="0"
}
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)."
@@ -21,6 +38,51 @@ dial_number() {
return 1
fi
resolve_sim_state
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
printf "PROMPT_SIM %s\n" "$NUMBER" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
xcallscreen >/dev/null 2>&1 || true
return 0
fi
TARGET_SIM="$PREF_SLOT"
fi
[ -n "$TARGET_SIM" ] || TARGET_SIM="$PRIM_SLOT"
# Secondary GW SIM call via QMI VOICE sub=1
if [ "$TARGET_SIM" = "$SEC_SLOT" ] && [ "$SEC_SLOT" != "0" ]; then
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
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
fi
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
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
elif command -v xcallscreen >/dev/null 2>&1; then
xcallscreen outgoing "$CALLID" "$NUMBER" >/dev/null 2>&1 || true
fi
sxmo_jobs.sh start proximity_lock sxmo_proximitylock.sh
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
@@ -28,7 +90,10 @@ dial_number() {
sleep 1
fi
sxmo_log "Attempting to 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
xcallscreen outgoing "-" "$NUMBER" >/dev/null 2>&1 || true
fi
@@ -48,7 +113,9 @@ dial_number() {
# cleanup all dangling event files, ignore errors
rm "$XDG_RUNTIME_DIR/sxmo_calls/$CALLID."* 2>/dev/null || true
sxmo_log "Starting call with CALLID: $CALLID"
if command -v xcallscreen >/dev/null 2>&1; then
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
elif command -v xcallscreen >/dev/null 2>&1; then
xcallscreen outgoing "$CALLID" "$NUMBER" >/dev/null 2>&1 || true
fi
@@ -82,7 +149,12 @@ dial_number() {
dial_ussd() {
USSD="$1"
sxmo_log "Dialling USSD: $USSD"
OUTPUT="$(doas -n /usr/libexec/msm-modem-uim-selection ussd initiate "$USSD" 2>/dev/null || /usr/libexec/msm-modem-uim-selection ussd initiate "$USSD" 2>/dev/null || true)"
SIM_ARG=""
if [ -n "$REQ_SIM_SLOT" ]; then
SIM_ARG="--sim $REQ_SIM_SLOT"
fi
# shellcheck disable=SC2086
OUTPUT="$(doas -n /usr/libexec/msm-modem-uim-selection ussd initiate $SIM_ARG "$USSD" 2>/dev/null || /usr/libexec/msm-modem-uim-selection ussd initiate $SIM_ARG "$USSD" 2>/dev/null || true)"
if [ -z "$OUTPUT" ]; then
DBUS_MODEM="$(mmcli -J -L 2>/dev/null | jq -r '."modem-list"[]' 2>/dev/null | head -n1)"
MM_BUS="org.freedesktop.ModemManager1"