From 157e76f8a143e597fcfc37fec7b09e8f5db5ec74 Mon Sep 17 00:00:00 2001 From: Taylor Brandstetter Date: Tue, 17 Oct 2017 09:32:20 -0700 Subject: [PATCH] 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 Reviewed-by: Taylor Brandstetter Cr-Commit-Position: refs/heads/master@{#20331} --- sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc b/sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc index 662f6cb9c5..a48b3df186 100644 --- a/sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc +++ b/sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc @@ -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: