diff --git a/CHANGELOG.md b/CHANGELOG.md index 954b4bb1921..e013bd16221 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,11 @@ removed. See [#49536](https://github.com/dart-lang/sdk/issues/49536) for details. +#### `dart:io` + +- Deprecated `NetworkInterface.listSupported`. Has always returned true since + Dart 2.3. + #### `dart:js_util` - Added several helper functions to access more JavaScript operator, like diff --git a/runtime/bin/io_natives.cc b/runtime/bin/io_natives.cc index 12e64805ce2..8926499dbb5 100644 --- a/runtime/bin/io_natives.cc +++ b/runtime/bin/io_natives.cc @@ -94,7 +94,6 @@ namespace bin { V(Namespace_Create, 2) \ V(Namespace_GetDefault, 0) \ V(Namespace_GetPointer, 1) \ - V(NetworkInterface_ListSupported, 0) \ V(OSError_inProgressErrorCode, 0) \ V(Platform_NumberOfProcessors, 0) \ V(Platform_OperatingSystem, 0) \ diff --git a/runtime/bin/socket_base.cc b/runtime/bin/socket_base.cc index de4f2598d69..8abfb48cff1 100644 --- a/runtime/bin/socket_base.cc +++ b/runtime/bin/socket_base.cc @@ -294,10 +294,6 @@ void FUNCTION_NAME(InternetAddress_RawAddrToString)(Dart_NativeArguments args) { Dart_SetReturnValue(args, ThrowIfError(DartUtils::NewString(str))); } -void FUNCTION_NAME(NetworkInterface_ListSupported)(Dart_NativeArguments args) { - Dart_SetBooleanReturnValue(args, SocketBase::ListInterfacesSupported()); -} - void FUNCTION_NAME(SocketBase_IsBindError)(Dart_NativeArguments args) { intptr_t error_number = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); diff --git a/runtime/bin/socket_base.h b/runtime/bin/socket_base.h index 320165323f6..3052876033c 100644 --- a/runtime/bin/socket_base.h +++ b/runtime/bin/socket_base.h @@ -278,9 +278,6 @@ class SocketBase : public AllStatic { static bool RawAddrToString(RawAddr* addr, char* str); static bool FormatNumericAddress(const RawAddr& addr, char* address, int len); - // Whether ListInterfaces is supported. - static bool ListInterfacesSupported(); - // List interfaces. Returns a AddressList of InterfaceSocketAddress's. static AddressList* ListInterfaces( int type, diff --git a/runtime/bin/socket_base_android.cc b/runtime/bin/socket_base_android.cc index 61e30abfbfc..0e047099c1c 100644 --- a/runtime/bin/socket_base_android.cc +++ b/runtime/bin/socket_base_android.cc @@ -332,10 +332,6 @@ static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { ((family == AF_INET) || (family == AF_INET6))))); } -bool SocketBase::ListInterfacesSupported() { - return true; -} - AddressList* SocketBase::ListInterfaces( int type, OSError** os_error) { diff --git a/runtime/bin/socket_base_fuchsia.cc b/runtime/bin/socket_base_fuchsia.cc index 670a24048f5..806a25ef173 100644 --- a/runtime/bin/socket_base_fuchsia.cc +++ b/runtime/bin/socket_base_fuchsia.cc @@ -334,10 +334,6 @@ static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { ((family == AF_INET) || (family == AF_INET6))))); } -bool SocketBase::ListInterfacesSupported() { - return true; -} - AddressList* SocketBase::ListInterfaces( int type, OSError** os_error) { diff --git a/runtime/bin/socket_base_posix.cc b/runtime/bin/socket_base_posix.cc index e5c48c22208..caa7ab87492 100644 --- a/runtime/bin/socket_base_posix.cc +++ b/runtime/bin/socket_base_posix.cc @@ -375,10 +375,6 @@ static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { ((family == AF_INET) || (family == AF_INET6)))); } -bool SocketBase::ListInterfacesSupported() { - return true; -} - AddressList* SocketBase::ListInterfaces( int type, OSError** os_error) { diff --git a/runtime/bin/socket_base_win.cc b/runtime/bin/socket_base_win.cc index 4d033052d76..07f6e71dead 100644 --- a/runtime/bin/socket_base_win.cc +++ b/runtime/bin/socket_base_win.cc @@ -331,10 +331,6 @@ bool SocketBase::RawAddrToString(RawAddr* addr, char* str) { return false; } -bool SocketBase::ListInterfacesSupported() { - return true; -} - AddressList* SocketBase::ListInterfaces( int type, OSError** os_error) { diff --git a/sdk/lib/_internal/vm/bin/socket_patch.dart b/sdk/lib/_internal/vm/bin/socket_patch.dart index 88a31867c32..6a222fb0cdd 100644 --- a/sdk/lib/_internal/vm/bin/socket_patch.dart +++ b/sdk/lib/_internal/vm/bin/socket_patch.dart @@ -99,9 +99,7 @@ class InternetAddress { @patch class NetworkInterface { @patch - static bool get listSupported { - return _listSupported(); - } + static bool get listSupported => true; @patch static Future> list( @@ -113,9 +111,6 @@ class NetworkInterface { includeLinkLocal: includeLinkLocal, type: type); } - - @pragma("vm:external-name", "NetworkInterface_ListSupported") - external static bool _listSupported(); } void _throwOnBadPort(int port) { @@ -761,8 +756,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { "Address family not supported by protocol family, " // ...and then add some details. "sourceAddress.type must be ${InternetAddressType.unix} but was " - "${source.type}", - address: address); + "${source.type}", address: address); } connectionResult = socket.nativeCreateUnixDomainBindConnect( address.address, source.address, _Namespace._namespace); diff --git a/sdk/lib/io/socket.dart b/sdk/lib/io/socket.dart index a7431cb332b..b8307fe35d5 100644 --- a/sdk/lib/io/socket.dart +++ b/sdk/lib/io/socket.dart @@ -178,7 +178,9 @@ abstract class NetworkInterface { /// Whether the [list] method is supported. /// - /// The [list] method is currently unsupported on Android. + /// The [list] method is supported on all platforms supported by Dart so this + /// property is always true. + @Deprecated("listSupported is always true.") external static bool get listSupported; /// Query the system for [NetworkInterface]s. diff --git a/tests/standalone/io/network_interface_test.dart b/tests/standalone/io/network_interface_test.dart index bfdd20eecff..a50b7227b6b 100644 --- a/tests/standalone/io/network_interface_test.dart +++ b/tests/standalone/io/network_interface_test.dart @@ -43,9 +43,6 @@ void testListIndex() { } void main() { - if (!NetworkInterface.listSupported) { - return; - } testListLoopback(); testListLinkLocal(); testListIndex(); diff --git a/tests/standalone_2/io/network_interface_test.dart b/tests/standalone_2/io/network_interface_test.dart index 55dbfcefa03..2c2241cf626 100644 --- a/tests/standalone_2/io/network_interface_test.dart +++ b/tests/standalone_2/io/network_interface_test.dart @@ -45,9 +45,6 @@ void testListIndex() { } void main() { - if (!NetworkInterface.listSupported) { - return; - } testListLoopback(); testListLinkLocal(); testListIndex(); diff --git a/tests/standalone_2/io/raw_datagram_socket_test.dart b/tests/standalone_2/io/raw_datagram_socket_test.dart index bd382a47131..90c0bd5acc6 100644 --- a/tests/standalone_2/io/raw_datagram_socket_test.dart +++ b/tests/standalone_2/io/raw_datagram_socket_test.dart @@ -128,10 +128,6 @@ testDatagramSocketMulticastIf() { option = RawSocketOption(RawSocketOption.levelIPv4, RawSocketOption.IPv4MulticastInterface, address.rawAddress); } else { - if (!NetworkInterface.listSupported) { - asyncEnd(); - return; - } var interface = await NetworkInterface.list(); if (interface.length == 0) { asyncEnd();