Skip to content

fix(android): improve Android 11 WifiNetworkSpecifier compatibility and SSID resolution - #3

Open
Nukeio wants to merge 3 commits into
subtlesayak:mainfrom
Nukeio:main
Open

Nukeio wants to merge 3 commits into
subtlesayak:mainfrom
Nukeio:main

Conversation

@Nukeio

@Nukeio Nukeio commented Jun 25, 2026

Copy link
Copy Markdown

Overview

This PR improves OpenDash compatibility on Android 11 (API 30), particularly on ColorOS devices where WifiNetworkSpecifier behaves differently compared to newer Android versions.

Root Cause

On Android 11 / ColorOS:

  • WifiNetworkSpecifier opens the system Wi-Fi Settings instead of the in-app pairing dialog.
  • NetworkCapabilities.transportInfo may be unavailable or return <unknown ssid>.
  • The application could begin authentication before the exact dashboard SSID was resolved.
  • Prefix-based discovery (RE_) could be propagated into the authentication flow, resulting in authentication failure.

Changes

  • Prevent authentication until the exact dashboard SSID has been resolved.
  • Prevent prefix-only (RE_) SSIDs from being used during authentication.
  • Added an Android 11 SSID polling fallback when transportInfo is unavailable.
  • Improved ConnectivityManager.requestNetwork() callback reliability by using an explicit Handler.
  • Preserved the existing connection flow for Android versions where the SSID is immediately available.

Tested On

Component Value
Device OPPO A92 (CPH1945)
Android 11 (API 30)
ROM ColorOS 11.1
Motorcycle Royal Enfield Guerrilla 450
Dash Firmware FOTA 03.07

Result

  • ✅ Wi-Fi connection succeeds
  • ✅ Dashboard SSID resolves correctly
  • ✅ Authentication succeeds
  • ✅ Dashboard reaches the LIVE state
  • ✅ Video streaming works successfully
Screenshot_2026-06-26-03-28-07-31_ec6e1ea73d917897991cb3ce7a9b18dc Screenshot_2026-06-26-03-28-18-98_ec6e1ea73d917897991cb3ce7a9b18dc Screenshot_2026-06-26-03-29-18-17_ec6e1ea73d917897991cb3ce7a9b18dc IMG20260626033036

Notes

This PR focuses only on improving Android 11 connectivity.

The following issues are intentionally not addressed in this PR and will be handled separately:

  • Temporary "Connection failed" message before successful connection.
  • Mobile data / routing behavior after connecting to the dashboard.
  • Media control compatibility with some music applications.

Request for Testing

Feedback from users running Android 12, Android 13, Android 14 and Android 15 would be appreciated to verify that the existing connection flow remains unaffected.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a33d83085d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +267 to +270
resolvedSsid = fallbackSsid
onSsidResolved?.invoke(fallbackSsid)
_state.value = WifiState(
status = WifiConnStatus.CONNECTED,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve the Network before publishing fallback CONNECTED

In the Android 11 fallback path, this publishes CONNECTED from WifiManager.connectionInfo without ever assigning this@DashWifiManager.network. In the OEM/manual-join case this fallback is meant to cover, onAvailable may not have supplied a Network, so DashViewModel.confirmDiscoveredDash() later passes wifiManager.network as null and DashSocket cannot bind its UDP sockets to the dash Wi-Fi; auth/video traffic can then route over the default network instead of 192.168.1.1. Please resolve and store the Wi-Fi Network (or keep waiting) before reporting a usable connection.

Useful? React with 👍 / 👎.

// with a valid SSID. We poll WifiManager.connectionInfo (deprecated but the only
// reliable path on API 30 with location permission) until we get the real SSID.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
scope.launch {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cancel the Android 11 SSID poll on release

This poll is launched in the ViewModel scope but is not retained or canceled by release()/disconnect(). If the user cancels or retries within the initial 5-second delay, the stale coroutine can still read the old/current active Wi-Fi, invoke onSsidResolved, and set the manager back to CONNECTED after the request was released. Track this job and cancel it alongside the network callback, or gate the update on the current request and wantConnected.

Useful? React with 👍 / 👎.

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.

1 participant