-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
SMB device discovery strategy using mDNS/NsdManager #4536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/4.0
Are you sure you want to change the base?
Conversation
b3ce74f to
cef5633
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements SMB device discovery using Android's NsdManager API for mDNS/Bonjour/ZeroConf service discovery. The implementation follows the existing strategy pattern, adding NsdManagerDiscoverDeviceStrategy alongside the existing WSDD and same-subnet discovery strategies.
- Adds a new discovery strategy using NsdManager for mDNS-based SMB server discovery
- Refactors the Observable to properly handle individual emitter disposal and error propagation
- Adds required Android permissions for multicast and nearby Wi-Fi device access
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| NsdManagerDiscoverDeviceStrategy.kt | New strategy implementation using NsdManager to discover SMB services via mDNS, with support for both pre-API 34 (using deprecated resolveService) and API 34+ (using hostAddresses) |
| SmbDeviceScannerObservable.kt | Modified to use Observable.create instead of fromCallable, properly handle emitter disposal, add explicit onSubscribe call, and propagate errors to observers |
| NsdManagerDiscoverDeviceStrategyTest.kt | Comprehensive unit tests for the new NsdManager strategy covering service discovery, resolution, error handling, and resource cleanup |
| SmbDeviceScannerObservableTest.kt | Unit tests for the Observable implementation verifying strategy coordination, device emission, disposal, and error propagation |
| SmbSearchDialog.kt | Minor refactoring: rename mInflater to inflater, replace Color.parseColor with toColorInt extension |
| AndroidManifest.xml | Adds INTERNET (duplicate), CHANGE_WIFI_MULTICAST_STATE, and NEARBY_WIFI_DEVICES permissions for mDNS functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/src/main/java/com/amaze/filemanager/utils/smb/NsdManagerDiscoverDeviceStrategy.kt
Show resolved
Hide resolved
app/src/main/java/com/amaze/filemanager/utils/smb/NsdManagerDiscoverDeviceStrategy.kt
Show resolved
Hide resolved
app/src/main/java/com/amaze/filemanager/utils/smb/SmbDeviceScannerObservable.kt
Show resolved
Hide resolved
a2b6f19 to
43be6b0
Compare
43be6b0 to
4465cb3
Compare
|
I need to test this, is there a way to run mDNS on a docker compose structure that you know will work for this? Or do I need to set up an mDNS in my Ubuntu machine with a samba service? |
Description
NsdManagerimplementation ofSmbDeviceScannerObservable.DiscoverDeviceStrategy, to enable discover Samba servers advertised on the network using mDNS.Issue tracker
Fixes #4488
Automatic tests
Manual tests
Done
Device: Fairphone 5
OS: LineageOS 23.0 (Android 16)
With proper configuration of
avahi-daemonandsamba, Amaze is able to discover Samba servers on the same network.Build tasks success
Successfully running following tasks on local:
./gradlew assembledebug./gradlew spotlessCheck