summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2011-08-31 11:46:42 -0700
committerRobert Greenwalt <rgreenwalt@google.com>2011-08-31 16:53:12 -0700
commit9b2886e24301e5d4e7052ec4a6eaff273d3f516c (patch)
tree27925e197c2c104a8ca70be59404c3c444c90c8c /wifi/java/android/net
parentac73e4bb420dbda31a866f3b86b207c71ecfa2f6 (diff)
downloadframeworks_base-9b2886e24301e5d4e7052ec4a6eaff273d3f516c.zip
frameworks_base-9b2886e24301e5d4e7052ec4a6eaff273d3f516c.tar.gz
frameworks_base-9b2886e24301e5d4e7052ec4a6eaff273d3f516c.tar.bz2
Create new isNetworkSupported API
Useful for checking if on a wifi-only device. Similar to asking for NetworkInfo for a network type and checking for null, though here the intent is explicit. bug:5087537 Change-Id: Ia3ddd09b6b735b8b3ceb7a347891e015fd96b218
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r--wifi/java/android/net/wifi/WifiWatchdogStateMachine.java28
1 files changed, 9 insertions, 19 deletions
diff --git a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
index 274edae..c52142d 100644
--- a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
@@ -36,6 +36,7 @@ import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.util.Slog;
+import android.util.Log;
import com.android.internal.util.Protocol;
import com.android.internal.util.State;
@@ -174,7 +175,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
* It triggers a disableNetwork call if a DNS check fails.
*/
public boolean mDisableAPNextFailure = false;
- private ConnectivityManager mConnectivityManager;
+ private static boolean sWifiOnly = false;
private boolean mNotificationShown;
public boolean mHasConnectedWifiManager = false;
@@ -219,9 +220,14 @@ public class WifiWatchdogStateMachine extends StateMachine {
public static WifiWatchdogStateMachine makeWifiWatchdogStateMachine(Context context) {
ContentResolver contentResolver = context.getContentResolver();
+
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(
+ Context.CONNECTIVITY_SERVICE);
+ sWifiOnly = (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false);
+
// Disable for wifi only devices.
if (Settings.Secure.getString(contentResolver, Settings.Secure.WIFI_WATCHDOG_ON) == null &&
- "wifi-only".equals(SystemProperties.get("ro.carrier"))) {
+ sWifiOnly) {
putSettingsBoolean(contentResolver, Settings.Secure.WIFI_WATCHDOG_ON, false);
}
WifiWatchdogStateMachine wwsm = new WifiWatchdogStateMachine(context);
@@ -508,22 +514,6 @@ public class WifiWatchdogStateMachine extends StateMachine {
}
}
- /**
- * @return true if there is definitely no mobile data (we'll be less aggressive)
- */
- private boolean hasNoMobileData() {
- if (mConnectivityManager == null) {
- mConnectivityManager = (ConnectivityManager) mContext.getSystemService(
- Context.CONNECTIVITY_SERVICE);
- }
- NetworkInfo mobileNetInfo = mConnectivityManager.getNetworkInfo(
- ConnectivityManager.TYPE_MOBILE);
- if (mobileNetInfo == null || !mobileNetInfo.isAvailable()) {
- return true;
- }
- return false;
- }
-
class DefaultState extends State {
@Override
public boolean processMessage(Message msg) {
@@ -941,7 +931,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
if (mDisableAPNextFailure || mNumCheckFailures >= mBssids.size()
|| mNumCheckFailures >= mMaxSsidBlacklists) {
- if (hasNoMobileData()) {
+ if (sWifiOnly) {
Slog.w(WWSM_TAG, "Would disable bad network, but device has no mobile data!" +
" Going idle...");
// This state should be called idle -- will be changing flow.