Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.cc

Issue 2697943002: Return "not implemented" error from BindSocketToNetwork properly. (Closed)
Patch Set: Adding CHECK_EXCEPTION Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 network_handle_by_address_.clear(); 233 network_handle_by_address_.clear();
234 network_info_by_handle_.clear(); 234 network_info_by_handle_.clear();
235 } 235 }
236 236
237 // The implementation is largely taken from UDPSocketPosix::BindToNetwork in 237 // The implementation is largely taken from UDPSocketPosix::BindToNetwork in
238 // https://cs.chromium.org/chromium/src/net/udp/udp_socket_posix.cc 238 // https://cs.chromium.org/chromium/src/net/udp/udp_socket_posix.cc
239 rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork( 239 rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork(
240 int socket_fd, 240 int socket_fd,
241 const rtc::IPAddress& address) { 241 const rtc::IPAddress& address) {
242 RTC_CHECK(thread_checker_.CalledOnValidThread()); 242 RTC_CHECK(thread_checker_.CalledOnValidThread());
243
244 jmethodID network_binding_supported_id = GetMethodID(
245 jni(), *j_network_monitor_class_, "networkBindingSupported", "()Z");
243 // Android prior to Lollipop didn't have support for binding sockets to 246 // Android prior to Lollipop didn't have support for binding sockets to
244 // networks. In that case it should not have reached here because 247 // networks. This may also occur if there is no connectivity manager service.
245 // |network_handle_by_address_| is only populated in Android Lollipop 248 bool network_binding_supported = jni()->CallBooleanMethod(
246 // and above. 249 *j_network_monitor_, network_binding_supported_id);
247 if (android_sdk_int_ < SDK_VERSION_LOLLIPOP) { 250 CHECK_EXCEPTION(jni())
248 LOG(LS_ERROR) << "BindSocketToNetwork is not supported in Android SDK " 251 << "Error during NetworkMonitor.networkBindingSupported";
249 << android_sdk_int_; 252 if (!network_binding_supported) {
253 LOG(LS_WARNING) << "BindSocketToNetwork is not supported on this platform "
254 << "(Android SDK: " << android_sdk_int_ << ")";
250 return rtc::NetworkBindingResult::NOT_IMPLEMENTED; 255 return rtc::NetworkBindingResult::NOT_IMPLEMENTED;
251 } 256 }
252 257
253 auto iter = network_handle_by_address_.find(address); 258 auto iter = network_handle_by_address_.find(address);
254 if (iter == network_handle_by_address_.end()) { 259 if (iter == network_handle_by_address_.end()) {
255 return rtc::NetworkBindingResult::ADDRESS_NOT_FOUND; 260 return rtc::NetworkBindingResult::ADDRESS_NOT_FOUND;
256 } 261 }
257 NetworkHandle network_handle = iter->second; 262 NetworkHandle network_handle = iter->second;
258 263
259 int rv = 0; 264 int rv = 0;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect)( 432 JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect)(
428 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, 433 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor,
429 jlong network_handle) { 434 jlong network_handle) {
430 AndroidNetworkMonitor* network_monitor = 435 AndroidNetworkMonitor* network_monitor =
431 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); 436 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor);
432 network_monitor->OnNetworkDisconnected( 437 network_monitor->OnNetworkDisconnected(
433 static_cast<NetworkHandle>(network_handle)); 438 static_cast<NetworkHandle>(network_handle));
434 } 439 }
435 440
436 } // namespace webrtc_jni 441 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « webrtc/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698