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 android.content.BroadcastReceiver; | 7 import android.content.BroadcastReceiver; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.IntentFilter; | 10 import android.content.IntentFilter; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 */ | 154 */ |
155 private void unregisterReceiver() { | 155 private void unregisterReceiver() { |
156 if (mRegistered) { | 156 if (mRegistered) { |
157 mRegistered = false; | 157 mRegistered = false; |
158 mContext.unregisterReceiver(this); | 158 mContext.unregisterReceiver(this); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 public int getCurrentConnectionType() { | 162 public int getCurrentConnectionType() { |
163 // Track exactly what type of connection we have. | 163 // Track exactly what type of connection we have. |
164 if (!mConnectivityManagerDelegate.activeNetworkExists() || | 164 if (!mConnectivityManagerDelegate.activeNetworkExists() |
165 !mConnectivityManagerDelegate.isConnected()) { | 165 || !mConnectivityManagerDelegate.isConnected()) { |
166 return NetworkChangeNotifier.CONNECTION_NONE; | 166 return NetworkChangeNotifier.CONNECTION_NONE; |
167 } | 167 } |
168 | 168 |
169 switch (mConnectivityManagerDelegate.getNetworkType()) { | 169 switch (mConnectivityManagerDelegate.getNetworkType()) { |
170 case ConnectivityManager.TYPE_ETHERNET: | 170 case ConnectivityManager.TYPE_ETHERNET: |
171 return NetworkChangeNotifier.CONNECTION_ETHERNET; | 171 return NetworkChangeNotifier.CONNECTION_ETHERNET; |
172 case ConnectivityManager.TYPE_WIFI: | 172 case ConnectivityManager.TYPE_WIFI: |
173 return NetworkChangeNotifier.CONNECTION_WIFI; | 173 return NetworkChangeNotifier.CONNECTION_WIFI; |
174 case ConnectivityManager.TYPE_WIMAX: | 174 case ConnectivityManager.TYPE_WIMAX: |
175 return NetworkChangeNotifier.CONNECTION_4G; | 175 return NetworkChangeNotifier.CONNECTION_4G; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 Log.d(TAG, "Network connectivity changed, type is: " + mConnectionType); | 238 Log.d(TAG, "Network connectivity changed, type is: " + mConnectionType); |
239 mObserver.onConnectionTypeChanged(newConnectionType); | 239 mObserver.onConnectionTypeChanged(newConnectionType); |
240 } | 240 } |
241 | 241 |
242 private static class NetworkConnectivityIntentFilter extends IntentFilter { | 242 private static class NetworkConnectivityIntentFilter extends IntentFilter { |
243 NetworkConnectivityIntentFilter() { | 243 NetworkConnectivityIntentFilter() { |
244 addAction(ConnectivityManager.CONNECTIVITY_ACTION); | 244 addAction(ConnectivityManager.CONNECTIVITY_ACTION); |
245 } | 245 } |
246 } | 246 } |
247 } | 247 } |
OLD | NEW |