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

Side by Side Diff: talk/app/webrtc/java/android/org/webrtc/NetworkMonitorAutoDetect.java

Issue 1655313005: Remove the network with empty name or NONE connection type from the network list. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 | « no previous file | 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 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 import android.net.LinkProperties; 46 import android.net.LinkProperties;
47 import android.net.Network; 47 import android.net.Network;
48 import android.net.NetworkCapabilities; 48 import android.net.NetworkCapabilities;
49 import android.net.NetworkInfo; 49 import android.net.NetworkInfo;
50 import android.net.NetworkRequest; 50 import android.net.NetworkRequest;
51 import android.net.wifi.WifiInfo; 51 import android.net.wifi.WifiInfo;
52 import android.net.wifi.WifiManager; 52 import android.net.wifi.WifiManager;
53 import android.os.Build; 53 import android.os.Build;
54 import android.telephony.TelephonyManager; 54 import android.telephony.TelephonyManager;
55 55
56 import java.util.ArrayList;
57
56 /** 58 /**
57 * Borrowed from Chromium's 59 * Borrowed from Chromium's
58 * src/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.jav a 60 * src/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.jav a
59 * 61 *
60 * Used by the NetworkMonitor to listen to platform changes in connectivity. 62 * Used by the NetworkMonitor to listen to platform changes in connectivity.
61 * Note that use of this class requires that the app have the platform 63 * Note that use of this class requires that the app have the platform
62 * ACCESS_NETWORK_STATE permission. 64 * ACCESS_NETWORK_STATE permission.
63 */ 65 */
64 public class NetworkMonitorAutoDetect extends BroadcastReceiver { 66 public class NetworkMonitorAutoDetect extends BroadcastReceiver {
65 public static enum ConnectionType { 67 public static enum ConnectionType {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 * Only callable on Lollipop and newer releases. 230 * Only callable on Lollipop and newer releases.
229 */ 231 */
230 @SuppressLint("NewApi") 232 @SuppressLint("NewApi")
231 Network[] getAllNetworks() { 233 Network[] getAllNetworks() {
232 if (connectivityManager == null) { 234 if (connectivityManager == null) {
233 return new Network[0]; 235 return new Network[0];
234 } 236 }
235 return connectivityManager.getAllNetworks(); 237 return connectivityManager.getAllNetworks();
236 } 238 }
237 239
238 NetworkInformation[] getActiveNetworkList() { 240 NetworkInformation[] getActiveNetworkList() {
AlexG 2016/02/03 22:35:27 May be return List<NetworkInformation> from this f
honghaiz3 2016/02/04 04:43:29 Done.
239 if (!supportNetworkCallback()) { 241 if (!supportNetworkCallback()) {
240 return new NetworkInformation[0]; 242 return new NetworkInformation[0];
241 } 243 }
242 Network[] networks = getAllNetworks(); 244 ArrayList<NetworkInformation> netInfoList = new ArrayList<NetworkInformati on>();
243 NetworkInformation[] netInfos = new NetworkInformation[networks.length]; 245 for (Network network : getAllNetworks()) {
244 for (int i = 0; i < networks.length; ++i) { 246 NetworkInformation info = networkToInfo(network);
245 netInfos[i] = networkToInfo(networks[i]); 247 if (info.name != null && info.type != ConnectionType.CONNECTION_NONE
248 && info.type != ConnectionType.CONNECTION_UNKNOWN) {
249 netInfoList.add(info);
250 }
246 } 251 }
247 return netInfos; 252 NetworkInformation[] netInfos = new NetworkInformation[netInfoList.size()] ;
253 return netInfoList.toArray(netInfos);
248 } 254 }
249 255
250 /** 256 /**
251 * Returns the NetID of the current default network. Returns 257 * Returns the NetID of the current default network. Returns
252 * INVALID_NET_ID if no current default network connected. 258 * INVALID_NET_ID if no current default network connected.
253 * Only callable on Lollipop and newer releases. 259 * Only callable on Lollipop and newer releases.
254 */ 260 */
255 @SuppressLint("NewApi") 261 @SuppressLint("NewApi")
256 int getDefaultNetId() { 262 int getDefaultNetId() {
257 if (!supportNetworkCallback()) { 263 if (!supportNetworkCallback()) {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 * Extracts NetID of network. Only available on Lollipop and newer releases. 590 * Extracts NetID of network. Only available on Lollipop and newer releases.
585 */ 591 */
586 @SuppressLint("NewApi") 592 @SuppressLint("NewApi")
587 private static int networkToNetId(Network network) { 593 private static int networkToNetId(Network network) {
588 // NOTE(pauljensen): This depends on Android framework implementation detail s. 594 // NOTE(pauljensen): This depends on Android framework implementation detail s.
589 // Fortunately this functionality is unlikely to ever change. 595 // Fortunately this functionality is unlikely to ever change.
590 // TODO(honghaiz): When we update to Android M SDK, use Network.getNetworkHa ndle(). 596 // TODO(honghaiz): When we update to Android M SDK, use Network.getNetworkHa ndle().
591 return Integer.parseInt(network.toString()); 597 return Integer.parseInt(network.toString());
592 } 598 }
593 } 599 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698