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

Unified Diff: net/android/network_change_notifier_android.cc

Issue 1454313002: Adding platform support check for NetworkObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@home
Patch Set: Added forcing networkhandle support to NCNAndroid and NCNAndroidTest Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: net/android/network_change_notifier_android.cc
diff --git a/net/android/network_change_notifier_android.cc b/net/android/network_change_notifier_android.cc
index eac6589a8ef23ce88c33298923c733f61d570806..cafa2cd12bde0dd103ae8eb308346531b3424340 100644
--- a/net/android/network_change_notifier_android.cc
+++ b/net/android/network_change_notifier_android.cc
@@ -59,6 +59,7 @@
#include "net/android/network_change_notifier_android.h"
+#include "base/android/build_info.h"
#include "base/threading/thread.h"
#include "net/base/address_tracker_linux.h"
#include "net/dns/dns_config_service_posix.h"
@@ -162,6 +163,18 @@ void NetworkChangeNotifierAndroid::GetCurrentMaxBandwidthAndConnectionType(
connection_type);
}
+void NetworkChangeNotifierAndroid::ForceNetworkHandlesSupportedForTesting() {
+ force_network_handles_supported_for_testing_ = true;
+}
+
+bool NetworkChangeNotifierAndroid::AreNetworkHandlesCurrentlySupported() const {
+ // Notifications for API using NetworkHandles and querying using
+ // NetworkHandles only implemented for Android versions >= L.
+ return force_network_handles_supported_for_testing_ ||
+ (base::android::BuildInfo::GetInstance()->sdk_int() >=
+ base::android::SDK_VERSION_LOLLIPOP);
+}
+
void NetworkChangeNotifierAndroid::GetCurrentConnectedNetworks(
NetworkChangeNotifier::NetworkList* networks) const {
delegate_->GetCurrentlyConnectedNetworks(networks);
@@ -222,7 +235,8 @@ NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid(
: NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()),
delegate_(delegate),
dns_config_service_thread_(
- new DnsConfigServiceThread(dns_config_for_testing)) {
+ new DnsConfigServiceThread(dns_config_for_testing)),
+ force_network_handles_supported_for_testing_(false) {
CHECK_EQ(NetId::INVALID, NetworkChangeNotifier::kInvalidNetworkHandle)
<< "kInvalidNetworkHandle doesn't match NetId::INVALID";
delegate_->AddObserver(this);
« no previous file with comments | « net/android/network_change_notifier_android.h ('k') | net/android/network_change_notifier_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698