Skip to content

Commit 84a7167

Browse files
greatgitsbyclaude
andcommitted
esim: tune CFUN wait to 2s, fix refresh/switch race in CellularManager
- Reduce post-CFUN sleep from 3s to 2s (modem reliably ready) - Add _finish_refresh that skips UI update when busy, preventing stale profile list from flashing during switch operations Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bed7ef2 commit 84a7167

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

system/hardware/tici/lpa.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,4 +771,5 @@ def switch_profile(self, iccid: str) -> None:
771771
raise LPAError(f"EnableProfile failed: {PROFILE_ERROR_CODES.get(code, 'unknown')} (0x{code:02X})")
772772
if code == 0x00:
773773
self._client._serial.write(b'AT+CFUN=0\rAT+CFUN=1\r')
774+
time.sleep(2)
774775
self._client._serial.reset_input_buffer()

system/ui/lib/cellular_manager.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,21 @@ def worker():
122122
lpa = self._ensure_lpa()
123123
lpa.process_notifications()
124124
profiles = lpa.list_profiles()
125-
self._callback_queue.append(lambda: self._finish(profiles=profiles))
125+
self._callback_queue.append(lambda: self._finish_refresh(profiles))
126126
except Exception:
127127
cloudlog.exception("Failed to list eSIM profiles")
128128
time.sleep(LPA_RETRY_INTERVAL)
129129
self._callback_queue.append(lambda: self.refresh_profiles())
130130

131131
threading.Thread(target=worker, daemon=True).start()
132132

133+
def _finish_refresh(self, profiles: list[Profile]):
134+
if self._busy:
135+
return
136+
self._profiles = profiles
137+
for cb in self._profiles_updated_cbs:
138+
cb(profiles)
139+
133140
def switch_profile(self, iccid: str):
134141
self._switching_iccid = iccid
135142
self._run_operation(lambda lpa: lpa.switch_profile(iccid), "Failed to switch eSIM profile")

0 commit comments

Comments
 (0)