Fix issue in AndroidNetworkMonitor for Wi-Fi Direct socket binding.

AndroidNetworkMonitor::BindSocketToNetwork incorrectly checks if the
socket_fd is NETWORK_UNSPECIFIED, when it should instead be checking
if the network_handle is that. This causes the PhysicalSocket to think
that it has succesfully bound to the port, when it really has not.
This stops IceCandidates from being created for these addresses
(although a socket is listening).

The net result of this is that webrtc connections don't work when both
peers are using Wifi-Direct to communicate, although we didn't notice
this previously since we were using Wifi-Direct only on one side.

TBR=pthatcher@webrtc.org

Bug: webrtc:8403
Change-Id: Ibe8f5424654ac9db1f79927ba7ac241fd40d9cba
Reviewed-on: https://webrtc-review.googlesource.com/12442
Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20331}
This commit is contained in:
Taylor Brandstetter
2017-10-17 09:32:20 -07:00
committed by Commit Bot
parent 39260c4a6b
commit 157e76f8a1

View File

@ -230,10 +230,6 @@ rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork(
const rtc::IPAddress& address) {
RTC_CHECK(thread_checker_.CalledOnValidThread());
if (socket_fd == 0 /* NETWORK_UNSPECIFIED */) {
return rtc::NetworkBindingResult::NOT_IMPLEMENTED;
}
jmethodID network_binding_supported_id = GetMethodID(
jni(), *j_network_monitor_class_, "networkBindingSupported", "()Z");
// Android prior to Lollipop didn't have support for binding sockets to
@ -254,6 +250,10 @@ rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork(
}
NetworkHandle network_handle = iter->second;
if (network_handle == 0 /* NETWORK_UNSPECIFIED */) {
return rtc::NetworkBindingResult::NOT_IMPLEMENTED;
}
int rv = 0;
if (android_sdk_int_ >= SDK_VERSION_MARSHMALLOW) {
// See declaration of android_setsocknetwork() here: