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/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/sdk/android/src/jni/classreferenceholder.h" | 17 #include "webrtc/sdk/android/src/jni/classreferenceholder.h" |
18 #include "webrtc/sdk/android/src/jni/jni_helpers.h" | 18 #include "webrtc/sdk/android/src/jni/jni_helpers.h" |
19 #include "webrtc/base/bind.h" | 19 #include "webrtc/base/bind.h" |
| 20 #include "webrtc/base/checks.h" |
20 #include "webrtc/base/common.h" | 21 #include "webrtc/base/common.h" |
21 #include "webrtc/base/ipaddress.h" | 22 #include "webrtc/base/ipaddress.h" |
22 | 23 |
23 namespace webrtc_jni { | 24 namespace webrtc_jni { |
24 | 25 |
25 enum AndroidSdkVersion { | 26 enum AndroidSdkVersion { |
26 SDK_VERSION_LOLLIPOP = 21, | 27 SDK_VERSION_LOLLIPOP = 21, |
27 SDK_VERSION_MARSHMALLOW = 23 | 28 SDK_VERSION_MARSHMALLOW = 23 |
28 }; | 29 }; |
29 | 30 |
(...skipping 24 matching lines...) Expand all Loading... |
54 } | 55 } |
55 if (enum_name == "CONNECTION_UNKNOWN_CELLULAR") { | 56 if (enum_name == "CONNECTION_UNKNOWN_CELLULAR") { |
56 return NetworkType::NETWORK_UNKNOWN_CELLULAR; | 57 return NetworkType::NETWORK_UNKNOWN_CELLULAR; |
57 } | 58 } |
58 if (enum_name == "CONNECTION_BLUETOOTH") { | 59 if (enum_name == "CONNECTION_BLUETOOTH") { |
59 return NetworkType::NETWORK_BLUETOOTH; | 60 return NetworkType::NETWORK_BLUETOOTH; |
60 } | 61 } |
61 if (enum_name == "CONNECTION_NONE") { | 62 if (enum_name == "CONNECTION_NONE") { |
62 return NetworkType::NETWORK_NONE; | 63 return NetworkType::NETWORK_NONE; |
63 } | 64 } |
64 ASSERT(false); | 65 RTC_NOTREACHED(); |
65 return NetworkType::NETWORK_UNKNOWN; | 66 return NetworkType::NETWORK_UNKNOWN; |
66 } | 67 } |
67 | 68 |
68 static rtc::AdapterType AdapterTypeFromNetworkType(NetworkType network_type) { | 69 static rtc::AdapterType AdapterTypeFromNetworkType(NetworkType network_type) { |
69 switch (network_type) { | 70 switch (network_type) { |
70 case NETWORK_UNKNOWN: | 71 case NETWORK_UNKNOWN: |
71 return rtc::ADAPTER_TYPE_UNKNOWN; | 72 return rtc::ADAPTER_TYPE_UNKNOWN; |
72 case NETWORK_ETHERNET: | 73 case NETWORK_ETHERNET: |
73 return rtc::ADAPTER_TYPE_ETHERNET; | 74 return rtc::ADAPTER_TYPE_ETHERNET; |
74 case NETWORK_WIFI: | 75 case NETWORK_WIFI: |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect)( | 427 JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect)( |
427 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, | 428 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, |
428 jlong network_handle) { | 429 jlong network_handle) { |
429 AndroidNetworkMonitor* network_monitor = | 430 AndroidNetworkMonitor* network_monitor = |
430 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); | 431 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); |
431 network_monitor->OnNetworkDisconnected( | 432 network_monitor->OnNetworkDisconnected( |
432 static_cast<NetworkHandle>(network_handle)); | 433 static_cast<NetworkHandle>(network_handle)); |
433 } | 434 } |
434 | 435 |
435 } // namespace webrtc_jni | 436 } // namespace webrtc_jni |
OLD | NEW |