Skip to content

[ai] smb: Handle optional Wi-Fi and unavailable local networks. - #4751

Open
carrerasdarren-cell wants to merge 1 commit into
TeamAmaze:release/4.0from
carrerasdarren-cell:fix/smb-optional-wifi-4708
Open

carrerasdarren-cell wants to merge 1 commit into
TeamAmaze:release/4.0from
carrerasdarren-cell:fix/smb-optional-wifi-4708

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown

Fixes: #4708

Description

Opening SMB device search can fail while constructing its discovery strategies on a device without the optional Wi-Fi service. Treat the Wi-Fi multicast lock as optional so NSD discovery remains available over Ethernet. When the existing local-network check reports no connection, show an explanation and retain manual hostname entry and cancellation. Initialize the disposable so that this early dialog path can close safely.

The existing NetworkUtil interface-name fallback remains unchanged. This is not a universal offline detector; actual hardware discovery is outside the validation below.

Issue tracker

Fixes #4708. The related Android TV manifest work in #4705 is already merged; this change handles the runtime SMB dialog and optional Wi-Fi service.

Automatic tests

  • Added unit tests for specific individual functions

  • Added headless tests for new app functionality

  • Added emulator tests for new UI elements

  • Reproduced the missing-service failure on exact original 94afab32: one selected real MainActivity / DialogFragment case fails with null cannot be cast to non-null type android.net.wifi.WifiManager through the NSD strategy and SMB search dialog.

  • :app:testFdroidDebugUnitTest --tests '*SmbSearchDialogNetworkAvailabilityTest' --tests '*NsdManagerDiscoverDeviceStrategyTest' --tests '*SmbConnectDialogTest' --tests '*NetworkUtilTest' --tests '*SmbDeviceScannerObservableTest': 117 passed, 0 failures/errors/skips on the final source. This includes 15 new dialog cases and 102 existing cases across configured SDKs 21, 28 and 30: manual SMB 9, NetworkUtil 18, NSD 45, scanner 30.

  • New real-dialog controls cover the unavailable-network explanation, manual entry, cancellation, Ethernet discovery without a Wi-Fi manager, and the normal Wi-Fi multicast-lock lifecycle. Services and addresses are synthetic; the other scanner strategies receive no local address, and no real discovery traffic is sent.

The local runner placed caches/reports on the SSD, serialized workers, and passed --add-opens=java.base/java.net=ALL-UNNAMED to the JDK 17 test JVM for the existing MockK NetworkInterface tests. Owner build inputs, dependencies and fail-fast behavior were unchanged. An initial mock-setup mismatch and the initial JDK module-access failure are excluded from the passing evidence. The final message was refined to “local network” to include supported transports such as USB/rndis, then the same 117 cases were rerun successfully.

Manual tests

  • Done

  • Device: Not performed; validation is headless Robolectric.

  • OS: No emulator or physical-device validation, screenshots or human review claimed. No device settings were changed.

Build tasks success

Successfully ran the following owner tasks locally on the same final source:

  • ./gradlew assembleDebug — both F-Droid and Play debug APKs built; packaging readback confirms the debug package and optional Wi-Fi declaration.
  • ./gradlew spotlessCheck

Generative code

  • This PR used generative code tools (GenAI, LLMs, etc.)

  • Model: OpenAI Codex coding assistant

  • Version: Exact runtime model version is not independently exposed in this session.

  • Provider: OpenAI

Wi-Fi is optional in the manifest, so SMB discovery can be opened on
devices without a WifiManager. Make its multicast lock optional so
Ethernet discovery can still proceed.

When no local network is available, explain why discovery cannot
start and keep manual entry and cancellation available. Initialize
the disposable so this early dialog path dismisses safely.

Cover the real dialog flow with synthetic services for unavailable
networking, manual entry, cancellation and Wi-Fi/Ethernet controls.

Fixes TeamAmaze#4708.
@carrerasdarren-cell
carrerasdarren-cell force-pushed the fix/smb-optional-wifi-4708 branch from 1635aa8 to 95abd50 Compare October 20, 2026 16:08
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.

Find out when the WiFi feature is not available and inform the user

1 participant