Created attachment 17463 [details]
Sample App for Repro
Multicast DNS discovery has worked flawlessly on all Android platforms up until 7.0 (API 24). On Android 7.0, every single network interface reports back false, whereas on previous versions, the WIFI connection reports back true.
A sample application which can reproduce the issue is attached. This sample Xamarin.Android app enumerates all the interfaces using System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(). And for each interface returned, it checks the SupportsMulticast property. This property returns false for every network interface when the app is run on Android 7 devices.
Created attachment 17464 [details]
Screenshot on Android 7.0 device
Created attachment 17465 [details]
Screenshot on Android 5.0 device
As you can see here WLAN0 returns TRUE
Created attachment 17471 [details]
Created attachment 17472 [details]
Created attachment 17473 [details]
From a customer:
"We have found that Bonjour browsing unexpectedly stops working on Android 7.0. After the investigation we’ve discovered, that the issue was related to usage of Wi-Fi network interface in general and it was caused by the changes in system WifiManager API.
To address the issue are now using the ConnectivityManager API.
We were using the WiFiManager API to get the WiFi MAC address to pick the proper network for mDNS search.
Starting in Android 6.0 the programmatic access to the WiFi MAC address was disable, thusly the WiFiManager doesn’t report the actual identifier. In Android 6.0 we had mechanism to use the first non-loopback interface if no interfaces were found with the current MAC. This would happen on Android 6.0. For Android 7.0 the first loopback network interface is a fake, so it now fails.
Because of this we moved to the ConnectivityManager API for Android 5+ devices. We can detect the WiFI interface without knowing the MAC address.
I don’t know how the lower level networking is handled by the Xamarin libraries, but from the behaviors exhibited I would assume it is similar. I’m passing this along in hopes that it will speed up the fix for the defect that we are waiting on for a fix."
The original issue happens because Google disabled access to some files in the /sys/class/net/[INTERFACE] files (for instance "flags", "operstate") which are what we use to determine the status of the interface including its multicast capability.
I'm working on a different way to obtain the information from the system.
Relevant upstream bug https://code.google.com/p/android/issues/detail?id=205565
PRs with a fix/workaround are up: https://github.com/xamarin/xamarin-android/pull/261 and https://github.com/xamarin/monodroid/pull/522 - once those are accepted another PR, this time for Mono, will be opened and complete the fix for this issue.
Alas, we won't be able to obtain arbitrary interface MAC - even Java classes can't provide us with the information.
Mono PR https://github.com/mono/mono/pull/3781
With the acceptance of the above (and its backport to mono 4.8 in commit 1db9061145385d28dc6ce5cbda768bdefe406b16) the bug is fixed.