Skip to content

fix(network): request ACCESS_LOCAL_NETWORK for LAN servers on Android 17 - #2972

Open
ismael-ares wants to merge 1 commit into
PixelPlayerHQ:masterfrom
ismael-ares:fix/android17-local-network-permission
Open

ismael-ares wants to merge 1 commit into
PixelPlayerHQ:masterfrom
ismael-ares:fix/android17-local-network-permission

Conversation

@ismael-ares

Copy link
Copy Markdown

Fixes #2895, fixes #2927. Also addresses the Android 17 report in #2287.

Since Android 17, apps targeting SDK 37 cannot reach the local network unless they hold the ACCESS_LOCAL_NETWORK runtime permission (docs). PixelPlayer targets SDK 37 but neither declared nor requested it. As a result, connections to self-hosted Navidrome/Jellyfin servers on the LAN silently timed out (failed to connect to /192.168.x.x ... after 15000ms), and the permission can't be granted manually because it isn't declared.

Changes

  • Declare ACCESS_LOCAL_NETWORK in the manifest.
  • Navidrome and Jellyfin login: if the server URL points to the local network, request the permission before connecting. That means a private, link-local or ULA address, a .local host, or a host name that resolves to one of those. If the user denies it, show a clear message instead of waiting for the timeout. Public servers never trigger the prompt.
  • On startup: if a saved Navidrome/Jellyfin server is on the LAN and the permission is missing, request it. This covers users who logged in before updating and users who revoked it.
  • Cast sheet: add the permission to the ones it already requests. The existing "Nearby devices" explanation covers it.
  • Unit tests for the LAN detection (LocalNetworkAccessTest).

Testing

  • Pixel 9a, Android 17: login to Navidrome over http:// on the LAN shows the system "Nearby devices" prompt; after allowing it, login and playback work.
  • ./gradlew :app:testDebugUnitTest --tests "*LocalNetworkAccessTest" passes.

Apps targeting SDK 37 can no longer reach the local network without the
ACCESS_LOCAL_NETWORK runtime permission. PixelPlayer neither declared nor
requested it, so connections to self-hosted Navidrome/Jellyfin servers on
the LAN silently timed out and casting could not reach local devices.

- Declare ACCESS_LOCAL_NETWORK in the manifest.
- Ask for it before logging in to a Navidrome/Jellyfin server whose URL
  points to the local network (private/link-local/ULA address, .local
  host, or a host name resolving to one), and show a clear message if it
  is denied instead of waiting for the timeout.
- On startup, ask for it when a saved Navidrome/Jellyfin server is on the
  LAN, covering users who logged in before updating or revoked it.
- Include it in the permissions requested by the cast sheet.
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.

[Bug]: Playback source error when playing Jellyfin tracks [Bug]: Android 17 changes to http streams

1 participant