From f689645c65905c15a12d45de8f361e4e535a5840 Mon Sep 17 00:00:00 2001
From: Affe Null <affenull2345@gmail.com>
Date: Fri, 2 Jun 2023 19:25:21 +0200
Subject: [PATCH] Attempt to get multi-SIM management working

---
 wroomd/src/devices/qmi_modem.rs | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/wroomd/src/devices/qmi_modem.rs b/wroomd/src/devices/qmi_modem.rs
index 018a8c4..77a0314 100644
--- a/wroomd/src/devices/qmi_modem.rs
+++ b/wroomd/src/devices/qmi_modem.rs
@@ -377,22 +377,21 @@ pub async fn action(
         }
         Action::ActivateCard(this_slot) => {
             let this_slot_id = this_slot.slot;
-            let updates = ctx
+            let updates: Vec<(u32, u32, Vec<u8>)> = ctx
                 .with(move |state| {
                     let nsessions = state.qmi_session_slots.len() as u32;
-                    let updates: Vec<(u32, u32, Vec<u8>)> = state
+                    let updates = state
                         .qmi_session_slots
                         .iter()
+                        .flatten()
+                        .filter(|slot_id| **slot_id != this_slot_id)
                         .zip(1..nsessions)
-                        .chain([(&Some(this_slot_id), 0)])
-                        .filter_map(|(slot, index)| {
-                            slot.and_then(|slot_id| {
-                                state
-                                    .aids
-                                    .get(&slot_id)
-                                    .cloned()
-                                    .map(|aid| (index, slot_id, aid))
-                            })
+                        .chain([(&this_slot_id, 0)])
+                        .filter_map(|(slot_id, index)| {
+                            state
+                                .aids
+                                .get(slot_id)
+                                .map(|aid| (index, *slot_id, aid.to_vec()))
                         })
                         .collect();
                     (state, updates)
-- 
GitLab