mirror of
https://github.com/koreader/koreader.git
synced 2026-11-28 08:17:00 +00:00
On Kobo, isConnected is aliased to ifHasAnAddress, which returns true as long as the interface holds any IP — including a stale lease from a previous network. The early-return gate in turnOnWifiAndWaitForConnection short-circuits before obtainIP() ever runs, so after switching networks KOReader reports "Connected" while every request times out on the old subnet's gateway. Track the SSID a lease was obtained for (lease_ssid) and add hasLeaseForCurrentNetwork(), which compares it against wpa_supplicant's reported association. Guard the fast-path gates in turnOnWifiAndWaitForConnection and doNothingAndWaitForConnection with it: on a stale lease, release the old IP and fall through to the normal reconnect path. lease_ssid is set in reconnectOrShowNetworkMenu (sync connect) and connectivityCheck (async restore), and cleared when Wi-Fi goes down or a connection is aborted. When the backend cannot report an SSID (non-wpa_supplicant platforms), hasLeaseForCurrentNetwork() returns true so connections are never churned on uncertainty, preserving existing behaviour everywhere but Kobo. Refs #14790, #14478, #14716 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GjgwQjZY2xoZPSuSXBJqv8