modem: prevent duplicate SIM PIN entry dialog in dual-SIM mode

This commit is contained in:
Luxferre committed 2026-10-28 08:32:05 +02:00
1 parent 2e2adcc7f2
commit 4aa087f372
6 files changed
+174 -65

No files matched your search

@@ -43,6 +43,11 @@ mainloop() {
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)"
if printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_PIN1_STATE=(enabled-not-verified|blocked)|SLOT[12]_APP_STATE=(pin1|puk1)"; then
newstate="locked"
elif [ "$newstate" = "locked" ] && printf "%s\n" "$uim_st" | grep -q "^MODEM_AVAILABLE=1$"; then
newstate="$(mmcli -m any -K 2>/dev/null | grep "^modem.generic.state " | cut -d':' -f2 | sed 's/^ //')"
if [ "$newstate" = "locked" ]; then
newstate="disabled"
fi
elif printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_STATE=present" && printf "%s\n" "$uim_st" | grep -q "^PRIMARY_GW_SLOT=0$"; then
doas -n /usr/libexec/msm-modem-uim-selection boot >/dev/null 2>&1 || true
newstate="$(mmcli -m any -K 2>/dev/null | grep "^modem.generic.state " | cut -d':' -f2 | sed 's/^ //')"
Binary file not shown.
@@ -544,7 +544,7 @@ provision_slot() {
eval "other_app_state=\$SLOT${other_slot}_APP_STATE"
need_prim=1
if [ "$PRIMARY_GW_SLOT" = "$chosen_slot" ] && { [ "$chosen_app_state" = "ready" ] || [ "$chosen_app_state" = "pin1-or-upin-pin-required" ] || [ "$chosen_app_state" = "puk1-or-upin-puk-required" ] || [ "$chosen_app_state" = "pin1_or_upin_pin_required" ] || [ "$chosen_app_state" = "puk1_or_upin_puk_required" ]; }; then
if [ "$PRIMARY_GW_SLOT" = "$chosen_slot" ] && [ -n "$chosen_app_state" ] && [ "$chosen_app_state" != "none" ] && [ "$chosen_app_state" != "illegal" ]; then
need_prim=0
fi
@@ -574,7 +574,7 @@ provision_slot() {
# Dual-SIM Dual Standby (DSDS): provision the second present SIM slot to secondary-gw-provisioning
if [ "$other_state" = "present" ]; then
need_sec=1
if [ "${SECONDARY_GW_SLOT:-0}" = "$other_slot" ] && { [ "$other_app_state" = "ready" ] || [ "$other_app_state" = "pin1-or-upin-pin-required" ] || [ "$other_app_state" = "puk1-or-upin-puk-required" ] || [ "$other_app_state" = "pin1_or_upin_pin_required" ] || [ "$other_app_state" = "puk1_or_upin_puk_required" ]; }; then
if [ "${SECONDARY_GW_SLOT:-0}" = "$other_slot" ] && [ -n "$other_app_state" ] && [ "$other_app_state" != "none" ] && [ "$other_app_state" != "illegal" ]; then
need_sec=0
fi
if [ "$need_sec" = "1" ]; then
@@ -948,10 +948,15 @@ PY
exit 1
fi
prepare_slot_for_pin_op "$slot"
eval "before_pin1=\${SLOT${slot}_PIN1_STATE:-}"
eval "before_app=\${SLOT${slot}_APP_STATE:-}"
eval "before_ret=\${SLOT${slot}_PIN1_RETRIES:-3}"
verified=0
wrong_pin=0
if [ "${PIN_OP_SESSION:-primary-gw-provisioning}" = "primary-gw-provisioning" ]; then
if [ "$before_pin1" = "enabled-verified" ] || [ "$before_pin1" = "disabled" ] || [ "$before_app" = "ready" ]; then
verified=1
fi
if [ "$verified" = "0" ] && [ "${PIN_OP_SESSION:-primary-gw-provisioning}" = "primary-gw-provisioning" ]; then
sim_id="$(timeout 3 mmcli -m any 2>/dev/null | grep -oE 'SIM/[0-9]+' | head -n1 | cut -d'/' -f2 || true)"
if [ -n "$sim_id" ]; then
mm_pin_out="$(timeout 5 mmcli -i "$sim_id" --pin="$pin" 2>&1)" && verified=1 || {
@@ -17,6 +17,13 @@ sxmo_debug "$2 (old: $1 [reason: $3])"
open_sim_unlock_ui() {
(
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)"
if printf "%s\n" "$uim_st" | grep -q "^MODEM_AVAILABLE=1$"; then
if ! printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_PIN1_STATE=(enabled-not-verified|blocked)|SLOT[12]_APP_STATE=(pin1|puk1)"; then
sxmo_log "QMI UIM reports no SIM requires PIN/PUK; skipping unlock UI."
exit 0
fi
fi
i=0
while [ "$i" -lt 40 ] && [ ! -p /tmp/dwm_plugin_modem.fifo ]; do
sleep 0.2