Skip to content

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

Merged
VishnuSanal merged 1 commit into
TeamAmaze:release/4.0from
carrerasdarren-cell:fix/smb-optional-wifi-4708
Dec 2, 2026
Merged

VishnuSanal merged 1 commit into
TeamAmaze:release/4.0from
carrerasdarren-cell:fix/smb-optional-wifi-4708

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown
Contributor

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

@carrerasdarren-cell
carrerasdarren-cell force-pushed the fix/smb-optional-wifi-4708 branch from 1635aa8 to 95abd50 Compare October 20, 2026 16:08
@TranceLove

Copy link
Copy Markdown
Collaborator

May need rebase with the latest release/4.0 codebase for updated Github CI which will expose NDK location to Rust setup routines

@carrerasdarren-cell
carrerasdarren-cell force-pushed the fix/smb-optional-wifi-4708 branch from 95abd50 to 2aeb7bb Compare November 8, 2026 13:14
@VishnuSanal VishnuSanal added the PR-Code-Review-Passed The human code review has passed for this PR. label Nov 8, 2026

@VishnuSanal VishnuSanal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code looks good, I also tested turning off the WiFi and it shows the dialog as expected. ran the tests locally and works as expected too. but I don't have an Android TV or something to test the actual error reported..

@VishnuSanal VishnuSanal added the PR-Manual-Testing-Passed The manual tests, performed by a human on a working build of this PR, passed for this PR. label Nov 8, 2026
@VishnuSanal

Copy link
Copy Markdown
Member

maybe @EmmanuelMess can test this finally (if you still have the TV emulator setup) before merging..

@EmmanuelMess EmmanuelMess added the PR-awaiting-CI-fix this PR is awaiting a current upstream CI failure/breakage to be fixed before merging label Nov 14, 2026
@VishnuSanal

Copy link
Copy Markdown
Member

@carrerasdarren-cell oh, the tests fail - can you pls rebase this on top of current HEAD (one last time!)

@VishnuSanal VishnuSanal self-assigned this Dec 2, 2026
Treat the Wi-Fi multicast lock as optional so local-network discovery
still works on Ethernet. Explain the network requirement when discovery
cannot start and keep manual host entry and cancellation available.
Initialize the discovery disposable so the offline dialog dismisses safely.

Disambiguate the two MockK verifications against Android 36's NSD
overloads without changing their assertions. Rebase on release/4.0
at 6535cf8, which includes the CI runner's higher inotify limit.
Codex assisted with the change and validation.

Fixes TeamAmaze#4708.
@carrerasdarren-cell
carrerasdarren-cell force-pushed the fix/smb-optional-wifi-4708 branch from 2aeb7bb to 6373059 Compare December 2, 2026 03:59
@VishnuSanal
VishnuSanal merged commit 8b4918e into TeamAmaze:release/4.0 Dec 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-awaiting-CI-fix this PR is awaiting a current upstream CI failure/breakage to be fixed before merging PR-Code-Review-Passed The human code review has passed for this PR. PR-Manual-Testing-Passed The manual tests, performed by a human on a working build of this PR, passed for this PR.

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

4 participants