Skip to content

Fix Android IP detection and multicast for OpenBikeControl (MyWhoosh Link) - #4864

Merged
cagnulein merged 3 commits into
masterfrom
fix-openbikecontrol-android-ip-multicast
Jul 30, 2026
Merged

Fix Android IP detection and multicast for OpenBikeControl (MyWhoosh Link)#4864
cagnulein merged 3 commits into
masterfrom
fix-openbikecontrol-android-ip-multicast

Conversation

@cagnulein

Copy link
Copy Markdown
Owner

Summary

  • OpenBikeControl (MyWhoosh Link) TCP server never got any client connections on Android — root cause: localipaddress::getIP() only used the deprecated WifiManager.getConnectionInfo().getIpAddress() API, which returns 0 on modern Android, so mDNS advertised 0.0.0.0 as the service address. Added a QNetworkInterface-based fallback (preferring wlan*) and stricter validation of the JNI-derived address.
  • Android silently drops incoming WiFi multicast packets (including mDNS queries) unless the app holds a WifiManager.MulticastLock. Added CHANGE_WIFI_MULTICAST_STATE permission and acquire/release the lock in ForegroundService.
  • Ports forward two commits from the abandoned branch android-ipaddress-not-valid (closed PR Prefer wlan IPv4 and validate JNI IP #4357, never merged, no review comments, all CI green at the time).

Relates to #4717 (Zwift Click steering via MyWhoosh not working — button routing was already fixed in 592c28e, but messages never reach MyWhoosh because no TCP client ever connects).

Test plan

  • CI Android build
  • Install built APK on a real Android device with MyWhoosh Link + Zwift Click steering enabled, confirm a TCP client connects and steering commands reach MyWhoosh

…Link)

MyWhoosh Link's mDNS advertising and TCP server never receive incoming
connections on Android because:
- localipaddress::getIP() relied solely on the deprecated
  WifiManager.getConnectionInfo().getIpAddress() API, which returns 0
  on modern Android, causing mDNS to publish 0.0.0.0 as the service
  address. Add a QNetworkInterface-based fallback (preferring wlan*)
  and validate the JNI-derived address before using it.
- Android silently drops incoming WiFi multicast packets (including
  mDNS queries) unless the app holds a WifiManager.MulticastLock.
  Acquire one in ForegroundService alongside the new
  CHANGE_WIFI_MULTICAST_STATE permission.

Ports forward two commits from the abandoned branch
android-ipaddress-not-valid (closed PR #4357, never merged).
…id IP

QNetworkInterface enumeration relies on netlink route sockets, which
SELinux denies to untrusted (third-party) apps on modern Android
(observed as nlmsg_readpriv AVC denials), so it was returning no
usable interface at all on affected devices. Query the device's IPv4
address via ConnectivityManager.getLinkProperties() on the active
network instead, which goes through the normal system service and
isn't subject to that restriction. Falls back to the legacy
WifiManager JNI path (still validated) on Android < 6.0 where
getActiveNetwork() doesn't exist.
connManager's local reference was deleted right after getActiveNetwork()
but then reused for getLinkProperties(), corrupting the JNI local
reference table (observed as a SIGABRT: "jobject is an invalid local
reference... popped reference at index 15 in a table of size 12",
crashing inside QMdnsEngine::ProviderPrivate::publish() -> getIP()).

Fix by only deleting local refs after their last use, and wrap the
whole function in PushLocalFrame/PopLocalFrame so it doesn't depend on
the calling thread's default local reference capacity.
@cagnulein
cagnulein merged commit 845c1c3 into master Jul 30, 2026
26 of 28 checks passed
@cagnulein
cagnulein deleted the fix-openbikecontrol-android-ip-multicast branch July 30, 2026 19:21
cagnulein added a commit that referenced this pull request Jul 31, 2026
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.

1 participant