fix(android): pass PROTOCOL_DNS_SD so mDNS registration works
Android 16 added NsdManager.checkProtocol(): registerService with protocol 0 threw IllegalArgumentException: Unsupported protocol — silently, since the old code swallowed the exception into a dead reflection fallback and start() overwrote the failure status with the Listening line. mDNS never actually advertised (the Phase 8 session streamed via --peer, masking it). Also advertise after the listening status so a registration failure stays visible, and log the exception and the registration success. Validated live on the Fairphone 6: the desktop --discover lists the phone and a full --send session decodes (in-band SPS 320x240 -> 2496x1040) and renders.
This commit is contained in:
@@ -304,6 +304,32 @@ Validation: `gradle :app:assembleDebug :app:testDebugUnitTest` green
|
||||
(25/25, full --rerun-tasks rebuild, only two pre-existing warnings);
|
||||
`meson test` 5/5 unchanged (no C++ touched).
|
||||
|
||||
### Discovery bug found and fixed on-device (2026-09-10, same day)
|
||||
|
||||
The user reported the desktop sender never discovered the phone.
|
||||
Root cause (found live on the Fairphone 6): `registerService(info, 0,
|
||||
listener)` — Android 16's `NsdManager.checkProtocol()` rejects protocol
|
||||
`0` with `IllegalArgumentException: Unsupported protocol`. The old code
|
||||
swallowed it into the dead reflection fallback, and `start()` posted the
|
||||
"Listening…" status AFTER advertiseNsd, overwriting the failure text — so
|
||||
mDNS never advertised and Phase 8's NSD validation was only ever "no
|
||||
crash" (8.5 streamed via --peer, masking it).
|
||||
|
||||
Fixes in `ReceiverPipeline.advertiseNsd()`/`start()`:
|
||||
- pass `NsdManager.PROTOCOL_DNS_SD`;
|
||||
- advertise AFTER the listening status so a failure stays visible;
|
||||
- `Log.e` the registration exception; `Log.i` on registered success.
|
||||
|
||||
On-device validation (adb, live): `mDNS registered:
|
||||
screencast._screencast._tcp` in logcat; `dumpsys servicediscovery` shows
|
||||
the active Advertiser (key diagnostic: `mClientRequests` empty == no
|
||||
request ever issued); desktop `avahi-browse` and `screencast --discover`
|
||||
list the phone at 192.168.178.29:5005; a 25s `--send --target monitor
|
||||
--peer 192.168.178.29:5005` session decoded (in-band SPS reconfigured
|
||||
320x240 → 2496x1040) and rendered (screencap mean brightness 0.51).
|
||||
Note: with both the Pi and the phone on the LAN, plain `--send` refuses
|
||||
(two receivers found) — target the phone with `--peer`.
|
||||
|
||||
Still open (accepted, needs a device or a new test dep):
|
||||
|
||||
- Untested on device: `setOutputSurface` mid-session (surface switch) and
|
||||
|
||||
Reference in New Issue
Block a user