Skip to content

feat: Update Android architecture - #437

Open
iTEEECH wants to merge 18 commits into
flutternetwork:masterfrom
EXFO:feat/android-architecture
Open

iTEEECH wants to merge 18 commits into
flutternetwork:masterfrom
EXFO:feat/android-architecture

Conversation

@iTEEECH

@iTEEECH iTEEECH commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Update Android architecture

Description

Android Wi‑Fi behavior in wifi_iot and wifi_scan has changed significantly since API 29 (Android 10). Connection, network registration, SSID/IP resolution, and scan result access no longer work reliably when everything stays in one monolithic plugin class that mixes legacy WifiConfiguration / WifiManager APIs with modern WifiNetworkSpecifier / WifiNetworkSuggestion / ConnectivityManager paths.

On current Android versions (especially 12+ / API 31+ and 13+ / API 33+), apps commonly hit:

  • Deprecated or restricted STA APIs for connect / disconnect / register
  •  / unreadable SSID when reading only WifiManager.getConnectionInfo() or a single joinedNetwork
  • Incorrect or missing SSID from scan results when still relying on deprecated ScanResult.SSID on API 33+
  • BroadcastReceiver registration requirements on API 33+ (RECEIVER_NOT_EXPORTED)
  • Hard-to-maintain Android code: legacy and modern logic interleaved inside WifiIotPlugin

Why changes

  • Platform fragmentation — Pre‑Q devices still need WifiConfiguration / addNetwork / enableNetwork. API 29+ requires WifiNetworkSpecifier (local / no internet) or WifiNetworkSuggestion (with internet), plus proper NetworkCallback lifecycle handling.
  • SSID / IP reliability on Android 12+ — With concurrent networks and privacy restrictions, SSID and IPv4 must be resolved from ConnectivityManager Wi‑Fi networks (prefer joined, then active, then others), not only from the legacy connection-info path.
  • Maintainability — WifiIotPlugin owned both Flutter channel plumbing and all STA backends. That made API‑level branching error-prone and blocked safe evolution of modern Android support.
  • Scan API modernization — wifi_scan must follow current Android rules for receivers, throttled startScan(), fine location, and SSID extraction via wifiSsid on API 33+.
  • Production impact — Apps that connect to instrument / lab / IoT networks (including no-internet Wi‑Fi) need stable connect/disconnect and readable SSID across OEM builds and recent Android releases.

Solutions

API level Implementation Role
API < 29 LegacyWifiPlatform WifiConfiguration, legacy connect/disconnect/register
API ≥ 29 ModernWifiPlatform Specifier / suggestion, NetworkCallback, modern SSID/IP

It may be released in development mode to gather feedback before the official release.

Tested on Android 11 and Android 16

@iTEEECH
iTEEECH force-pushed the feat/android-architecture branch from c3b3f75 to f4e5f55 Compare September 14, 2026 13:55
@iTEEECH iTEEECH closed this Sep 14, 2026
@iTEEECH iTEEECH reopened this Sep 14, 2026
@iTEEECH
iTEEECH force-pushed the feat/android-architecture branch from eb27cd0 to 366f2ef Compare September 14, 2026 14:48
@iTEEECH
iTEEECH force-pushed the feat/android-architecture branch from de987c4 to 3572ce5 Compare September 15, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants