OLD | NEW |
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 |
11 #include "webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.h" | 11 #include "webrtc/sdk/android/src/jni/pc/androidnetworkmonitor_jni.h" |
12 | 12 |
13 #include <dlfcn.h> | 13 #include <dlfcn.h> |
14 // This was added in Lollipop to dlfcn.h | 14 // This was added in Lollipop to dlfcn.h |
15 #define RTLD_NOLOAD 4 | 15 #define RTLD_NOLOAD 4 |
16 | 16 |
17 #include "webrtc/rtc_base/bind.h" | 17 #include "webrtc/rtc_base/bind.h" |
18 #include "webrtc/rtc_base/checks.h" | 18 #include "webrtc/rtc_base/checks.h" |
19 #include "webrtc/rtc_base/ipaddress.h" | 19 #include "webrtc/rtc_base/ipaddress.h" |
20 #include "webrtc/sdk/android/src/jni/classreferenceholder.h" | 20 #include "webrtc/sdk/android/src/jni/classreferenceholder.h" |
21 #include "webrtc/sdk/android/src/jni/jni_helpers.h" | 21 #include "webrtc/sdk/android/src/jni/jni_helpers.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 LOG(LS_WARNING) << "Get an unknown type for the interface " << if_name; | 382 LOG(LS_WARNING) << "Get an unknown type for the interface " << if_name; |
383 } | 383 } |
384 return type; | 384 return type; |
385 } | 385 } |
386 | 386 |
387 rtc::NetworkMonitorInterface* | 387 rtc::NetworkMonitorInterface* |
388 AndroidNetworkMonitorFactory::CreateNetworkMonitor() { | 388 AndroidNetworkMonitorFactory::CreateNetworkMonitor() { |
389 return new AndroidNetworkMonitor(); | 389 return new AndroidNetworkMonitor(); |
390 } | 390 } |
391 | 391 |
392 JOW(void, NetworkMonitor_nativeNotifyConnectionTypeChanged)( | 392 JOW(void, NetworkMonitor_nativeNotifyConnectionTypeChanged) |
393 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor) { | 393 (JNIEnv* jni, jobject j_monitor, jlong j_native_monitor) { |
394 rtc::NetworkMonitorInterface* network_monitor = | 394 rtc::NetworkMonitorInterface* network_monitor = |
395 reinterpret_cast<rtc::NetworkMonitorInterface*>(j_native_monitor); | 395 reinterpret_cast<rtc::NetworkMonitorInterface*>(j_native_monitor); |
396 network_monitor->OnNetworksChanged(); | 396 network_monitor->OnNetworksChanged(); |
397 } | 397 } |
398 | 398 |
399 JOW(void, NetworkMonitor_nativeNotifyOfActiveNetworkList)( | 399 JOW(void, NetworkMonitor_nativeNotifyOfActiveNetworkList) |
400 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, | 400 (JNIEnv* jni, |
401 jobjectArray j_network_infos) { | 401 jobject j_monitor, |
| 402 jlong j_native_monitor, |
| 403 jobjectArray j_network_infos) { |
402 AndroidNetworkMonitor* network_monitor = | 404 AndroidNetworkMonitor* network_monitor = |
403 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); | 405 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); |
404 std::vector<NetworkInformation> network_infos; | 406 std::vector<NetworkInformation> network_infos; |
405 size_t num_networks = jni->GetArrayLength(j_network_infos); | 407 size_t num_networks = jni->GetArrayLength(j_network_infos); |
406 for (size_t i = 0; i < num_networks; ++i) { | 408 for (size_t i = 0; i < num_networks; ++i) { |
407 jobject j_network_info = jni->GetObjectArrayElement(j_network_infos, i); | 409 jobject j_network_info = jni->GetObjectArrayElement(j_network_infos, i); |
408 CHECK_EXCEPTION(jni) << "Error during GetObjectArrayElement"; | 410 CHECK_EXCEPTION(jni) << "Error during GetObjectArrayElement"; |
409 network_infos.push_back(GetNetworkInformationFromJava(jni, j_network_info)); | 411 network_infos.push_back(GetNetworkInformationFromJava(jni, j_network_info)); |
410 } | 412 } |
411 network_monitor->SetNetworkInfos(network_infos); | 413 network_monitor->SetNetworkInfos(network_infos); |
412 } | 414 } |
413 | 415 |
414 JOW(void, NetworkMonitor_nativeNotifyOfNetworkConnect)( | 416 JOW(void, NetworkMonitor_nativeNotifyOfNetworkConnect) |
415 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, | 417 (JNIEnv* jni, |
416 jobject j_network_info) { | 418 jobject j_monitor, |
| 419 jlong j_native_monitor, |
| 420 jobject j_network_info) { |
417 AndroidNetworkMonitor* network_monitor = | 421 AndroidNetworkMonitor* network_monitor = |
418 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); | 422 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); |
419 NetworkInformation network_info = | 423 NetworkInformation network_info = |
420 GetNetworkInformationFromJava(jni, j_network_info); | 424 GetNetworkInformationFromJava(jni, j_network_info); |
421 network_monitor->OnNetworkConnected(network_info); | 425 network_monitor->OnNetworkConnected(network_info); |
422 } | 426 } |
423 | 427 |
424 JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect)( | 428 JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect) |
425 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, | 429 (JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, jlong network_handle) { |
426 jlong network_handle) { | |
427 AndroidNetworkMonitor* network_monitor = | 430 AndroidNetworkMonitor* network_monitor = |
428 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); | 431 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); |
429 network_monitor->OnNetworkDisconnected( | 432 network_monitor->OnNetworkDisconnected( |
430 static_cast<NetworkHandle>(network_handle)); | 433 static_cast<NetworkHandle>(network_handle)); |
431 } | 434 } |
432 | 435 |
433 } // namespace webrtc_jni | 436 } // namespace webrtc_jni |
OLD | NEW |