Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@ -615,6 +615,19 @@ namespace System.Net.NetworkInformation {
string iface_operstate_path;
string iface_flags_path;
#if MONODROID
[DllImport ("__Internal")]
protected static extern int _monodroid_get_android_api_level ();
[DllImport ("__Internal")]
protected static extern bool _monodroid_get_network_interface_up_state (string ifname, ref bool is_up);
[DllImport ("__Internal")]
protected static extern bool _monodroid_get_network_interface_supports_multicast (string ifname, ref bool supports_multicast);
bool android_use_java_api;
#endif
internal string IfacePath {
get { return iface_path; }
}
@ -625,6 +638,9 @@ namespace System.Net.NetworkInformation {
iface_path = "/sys/class/net/" + name + "/";
iface_operstate_path = iface_path + "operstate";
iface_flags_path = iface_path + "flags";
#if MONODROID
android_use_java_api = _monodroid_get_android_api_level () >= 24;
#endif
}
public override IPInterfaceProperties GetIPProperties ()
@ -643,6 +659,23 @@ namespace System.Net.NetworkInformation {
public override OperationalStatus OperationalStatus {
get {
#if MONODROID
if (android_use_java_api) {
// Starting from API 24 (Android 7 "Nougat") Android restricts access to many
// files in the /sys filesystem (see https://code.google.com/p/android/issues/detail?id=205565
// for more information) and therefore we are forced to call into Java API in
// order to get the information. Alas, what we can obtain in this way is quite
// limited. In the case of OperationalStatus we can only determine whether the
// interface is up or down. There is a way to get more detailed information but
// it requires an instance of the Android Context class which is not available
// to us here.
bool is_up = false;
if (_monodroid_get_network_interface_up_state (Name, ref is_up))
return is_up ? OperationalStatus.Up : OperationalStatus.Down;
else
return OperationalStatus.Unknown;
}
#endif
if (!Directory.Exists (iface_path))
return OperationalStatus.Unknown;
@ -679,6 +712,17 @@ namespace System.Net.NetworkInformation {
public override bool SupportsMulticast {
get {
#if MONODROID
if (android_use_java_api) {
// Starting from API 24 (Android 7 "Nougat") Android restricts access to many
// files in the /sys filesystem (see https://code.google.com/p/android/issues/detail?id=205565
// for more information) and therefore we are forced to call into Java API in
// order to get the information.
bool supports_multicast = false;
_monodroid_get_network_interface_supports_multicast (Name, ref supports_multicast);
return supports_multicast;
}
#endif
if (!Directory.Exists (iface_path))
return false;