| OLD | NEW |
| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 343 } |
| 344 | 344 |
| 345 // This class gets called back by ConnectivityManager whenever networks come | 345 // This class gets called back by ConnectivityManager whenever networks come |
| 346 // and go. It gets called back on a special handler thread | 346 // and go. It gets called back on a special handler thread |
| 347 // ConnectivityManager creates for making the callbacks. The callbacks in | 347 // ConnectivityManager creates for making the callbacks. The callbacks in |
| 348 // turn post to the UI thread where mObserver lives. | 348 // turn post to the UI thread where mObserver lives. |
| 349 @TargetApi(Build.VERSION_CODES.LOLLIPOP) | 349 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 350 private class MyNetworkCallback extends NetworkCallback { | 350 private class MyNetworkCallback extends NetworkCallback { |
| 351 // If non-null, this indicates a VPN is in place for the current user, a
nd no other | 351 // If non-null, this indicates a VPN is in place for the current user, a
nd no other |
| 352 // networks are accessible. | 352 // networks are accessible. |
| 353 private Network mVpnInPlace = null; | 353 private Network mVpnInPlace; |
| 354 | 354 |
| 355 // Initialize mVpnInPlace. | 355 // Initialize mVpnInPlace. |
| 356 void initializeVpnInPlace() { | 356 void initializeVpnInPlace() { |
| 357 final Network[] networks = getAllNetworksFiltered(mConnectivityManag
erDelegate, null); | 357 final Network[] networks = getAllNetworksFiltered(mConnectivityManag
erDelegate, null); |
| 358 mVpnInPlace = null; | 358 mVpnInPlace = null; |
| 359 // If the filtered list of networks contains just a VPN, then that V
PN is in place. | 359 // If the filtered list of networks contains just a VPN, then that V
PN is in place. |
| 360 if (networks.length == 1) { | 360 if (networks.length == 1) { |
| 361 final NetworkCapabilities capabilities = | 361 final NetworkCapabilities capabilities = |
| 362 mConnectivityManagerDelegate.getNetworkCapabilities(netw
orks[0]); | 362 mConnectivityManagerDelegate.getNetworkCapabilities(netw
orks[0]); |
| 363 if (capabilities != null && capabilities.hasTransport(TRANSPORT_
VPN)) { | 363 if (capabilities != null && capabilities.hasTransport(TRANSPORT_
VPN)) { |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 return network.getNetworkHandle(); | 987 return network.getNetworkHandle(); |
| 988 } else { | 988 } else { |
| 989 // NOTE(pauljensen): This depends on Android framework implementatio
n details. These | 989 // NOTE(pauljensen): This depends on Android framework implementatio
n details. These |
| 990 // details cannot change because Lollipop is long since released. | 990 // details cannot change because Lollipop is long since released. |
| 991 // NetIDs are only 16-bit so use parseInt. This function returns a l
ong because | 991 // NetIDs are only 16-bit so use parseInt. This function returns a l
ong because |
| 992 // getNetworkHandle() returns a long. | 992 // getNetworkHandle() returns a long. |
| 993 return Integer.parseInt(network.toString()); | 993 return Integer.parseInt(network.toString()); |
| 994 } | 994 } |
| 995 } | 995 } |
| 996 } | 996 } |
| OLD | NEW |