With Android 7.0 (Nougat) it is no longer possible to read some
authorMarek Habersack <grendel@twistedcode.net>
Mon, 17 Oct 2016 17:40:21 +0000 (19:40 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Mon, 17 Oct 2016 20:29:49 +0000 (22:29 +0200)
commitc439b678878aa9ebeee1ce29853a295f5184b19f
treed9ed0f5000c20663378273df3ca7f6091148530c
parent297c25787be0a333254683e7e7fa23255243a674
With Android 7.0 (Nougat) it is no longer possible to read some

information about network interfaces from the /sys filesystem. Google
placed restrictions on two files used by the Mono BCL to read
information about the interface:

      /sys/class/net/[DEVICE]/flags
      /sys/class/net/[DEVICE]/operstate

The information we used to read from `flags` let us determine whether
the interface supports multicast and the `operstate` file provided us
with detailed information on the current device state.

Additionally, it is now impossible to read the hardware MAC address used
by any interface. This bit of information is also unavailable when using
the Java APIs and therefore applications running on devices with API
24 (and possibly newer) will not be able to access this information.

More details about the issue are available from the upstream Android
bug:

      https://code.google.com/p/android/issues/detail?id=205565

In order to obtain the required information, we now need to use the Java
APIs on devices with API 24+ and this commit implements the backend to
retrieve this information. It is done in C in order to avoid overhead of
creating mirror .NET objects when calling Java, thus saving time and
memory during an operation which may be performed by some applications
quite frequently.

This patch implements code that calls into the Xamarin.Android
runtime when runnin under API24 or newer to obtain the information.

Part of fix for https://bugzilla.xamarin.com/show_bug.cgi?id=44296
mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs