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

Side by Side Diff: net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java

Issue 2011123002: Add a null check in ConnectivityManagerDelegate.getNetworkState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2739
Patch Set: Created 4 years, 6 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 | net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import static android.net.ConnectivityManager.TYPE_VPN; 7 import static android.net.ConnectivityManager.TYPE_VPN;
8 import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; 8 import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
9 import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN; 9 import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN;
10 import static android.net.NetworkCapabilities.TRANSPORT_VPN; 10 import static android.net.NetworkCapabilities.TRANSPORT_VPN;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return getNetworkState(mConnectivityManager.getActiveNetworkInfo()); 87 return getNetworkState(mConnectivityManager.getActiveNetworkInfo());
88 } 88 }
89 89
90 /** 90 /**
91 * Returns connection type and status information about |network|. 91 * Returns connection type and status information about |network|.
92 * Only callable on Lollipop and newer releases. 92 * Only callable on Lollipop and newer releases.
93 */ 93 */
94 @TargetApi(Build.VERSION_CODES.LOLLIPOP) 94 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
95 NetworkState getNetworkState(Network network) { 95 NetworkState getNetworkState(Network network) {
96 final NetworkInfo networkInfo = mConnectivityManager.getNetworkInfo( network); 96 final NetworkInfo networkInfo = mConnectivityManager.getNetworkInfo( network);
97 if (networkInfo.getType() == TYPE_VPN) { 97 if (networkInfo != null && networkInfo.getType() == TYPE_VPN) {
98 // When a VPN is in place the underlying network type can be que ried via 98 // When a VPN is in place the underlying network type can be que ried via
99 // getActiveNeworkInfo() thanks to 99 // getActiveNeworkInfo() thanks to
100 // https://android.googlesource.com/platform/frameworks/base/+/d 6a7980d 100 // https://android.googlesource.com/platform/frameworks/base/+/d 6a7980d
101 return getNetworkState(); 101 return getNetworkState();
102 } 102 }
103 return getNetworkState(networkInfo); 103 return getNetworkState(networkInfo);
104 } 104 }
105 105
106 /** 106 /**
107 * Returns connection type and status information gleaned from networkIn fo. 107 * Returns connection type and status information gleaned from networkIn fo.
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 */ 887 */
888 @TargetApi(Build.VERSION_CODES.LOLLIPOP) 888 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
889 @VisibleForTesting 889 @VisibleForTesting
890 static int networkToNetId(Network network) { 890 static int networkToNetId(Network network) {
891 // NOTE(pauljensen): This depends on Android framework implementation de tails. 891 // NOTE(pauljensen): This depends on Android framework implementation de tails.
892 // Fortunately this functionality is unlikely to ever change. 892 // Fortunately this functionality is unlikely to ever change.
893 // TODO(pauljensen): When we update to Android M SDK, use Network.getNet workHandle(). 893 // TODO(pauljensen): When we update to Android M SDK, use Network.getNet workHandle().
894 return Integer.parseInt(network.toString()); 894 return Integer.parseInt(network.toString());
895 } 895 }
896 } 896 }
OLDNEW
« no previous file with comments | « no previous file | net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698