am 8a4cd3b1: Merge "Disable poor network connection alone" into ics-mr1

* commit '8a4cd3b1053d92ecb34628218f303343746691f4':
  Disable poor network connection alone
This commit is contained in:
Irfan Sheriff
2011-12-06 21:07:36 -08:00
committed by Android Git Automerger
2 changed files with 49 additions and 11 deletions

View File

@@ -3111,6 +3111,14 @@ public final class Settings {
public static final String WIFI_WATCHDOG_BLACKLIST_FOLLOWUP_INTERVAL_MS =
"wifi_watchdog_blacklist_followup_interval_ms";
/**
* Setting to turn off poor network avoidance on Wi-Fi. Feature is disabled by default and
* the setting needs to be set to 1 to enable it.
* @hide
*/
public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
"wifi_watchdog_poor_network_test_enabled";
/**
* Setting to turn off walled garden test on Wi-Fi. Feature is enabled by default and
* the setting needs to be set to 0 to disable it.

View File

@@ -150,6 +150,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
private ConnectedState mConnectedState = new ConnectedState();
private DnsCheckingState mDnsCheckingState = new DnsCheckingState();
private OnlineWatchState mOnlineWatchState = new OnlineWatchState();
private OnlineState mOnlineState = new OnlineState();
private DnsCheckFailureState mDnsCheckFailureState = new DnsCheckFailureState();
private DelayWalledGardenState mDelayWalledGardenState = new DelayWalledGardenState();
private WalledGardenState mWalledGardenState = new WalledGardenState();
@@ -163,6 +164,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
private int mMinDnsResponses;
private int mDnsPingTimeoutMs;
private long mBlacklistFollowupIntervalMs;
private boolean mPoorNetworkDetectionEnabled;
private boolean mWalledGardenTestEnabled;
private String mWalledGardenUrl;
@@ -226,6 +228,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
addState(mWalledGardenState, mConnectedState);
addState(mBlacklistedApState, mConnectedState);
addState(mOnlineWatchState, mConnectedState);
addState(mOnlineState, mConnectedState);
setInitialState(mWatchdogDisabledState);
updateSettings();
@@ -386,9 +389,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
}
private boolean isWatchdogEnabled() {
//return getSettingsBoolean(mContentResolver, Settings.Secure.WIFI_WATCHDOG_ON, true);
//TODO: fix this when we do aggressive monitoring
return false;
return getSettingsBoolean(mContentResolver, Settings.Secure.WIFI_WATCHDOG_ON, true);
}
private void updateSettings() {
@@ -413,6 +414,10 @@ public class WifiWatchdogStateMachine extends StateMachine {
mBlacklistFollowupIntervalMs = Secure.getLong(mContentResolver,
Settings.Secure.WIFI_WATCHDOG_BLACKLIST_FOLLOWUP_INTERVAL_MS,
DEFAULT_BLACKLIST_FOLLOWUP_INTERVAL_MS);
//TODO: enable this by default after changing watchdog behavior
//Also, update settings description
mPoorNetworkDetectionEnabled = getSettingsBoolean(mContentResolver,
Settings.Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, false);
mWalledGardenTestEnabled = getSettingsBoolean(mContentResolver,
Settings.Secure.WIFI_WATCHDOG_WALLED_GARDEN_TEST_ENABLED, true);
mWalledGardenUrl = getSettingsStr(mContentResolver,
@@ -625,9 +630,13 @@ public class WifiWatchdogStateMachine extends StateMachine {
initConnection(wifiInfo);
mConnectionInfo = wifiInfo;
updateBssids();
transitionTo(mDnsCheckingState);
mNetEventCounter++;
if (mPoorNetworkDetectionEnabled) {
updateBssids();
transitionTo(mDnsCheckingState);
} else {
transitionTo(mDelayWalledGardenState);
}
break;
default:
mNetEventCounter++;
@@ -679,12 +688,18 @@ public class WifiWatchdogStateMachine extends StateMachine {
public boolean processMessage(Message msg) {
switch (msg.what) {
case EVENT_SCAN_RESULTS_AVAILABLE:
updateBssids();
if (mPoorNetworkDetectionEnabled) {
updateBssids();
}
return HANDLED;
case EVENT_WATCHDOG_SETTINGS_CHANGE:
// Stop current checks, but let state update
transitionTo(mOnlineWatchState);
return NOT_HANDLED;
updateSettings();
if (mPoorNetworkDetectionEnabled) {
transitionTo(mOnlineWatchState);
} else {
transitionTo(mOnlineState);
}
return HANDLED;
}
return NOT_HANDLED;
}
@@ -831,7 +846,11 @@ public class WifiWatchdogStateMachine extends StateMachine {
transitionTo(mWalledGardenState);
} else {
if (DBG) log("Walled garden test complete - online");
transitionTo(mOnlineWatchState);
if (mPoorNetworkDetectionEnabled) {
transitionTo(mOnlineWatchState);
} else {
transitionTo(mOnlineState);
}
}
return HANDLED;
default:
@@ -963,6 +982,13 @@ public class WifiWatchdogStateMachine extends StateMachine {
}
}
/* Child state of ConnectedState indicating that we are online
* and there is nothing to do
*/
class OnlineState extends State {
}
class DnsCheckFailureState extends State {
@Override
@@ -1039,7 +1065,11 @@ public class WifiWatchdogStateMachine extends StateMachine {
return HANDLED;
}
setWalledGardenNotificationVisible(true);
transitionTo(mOnlineWatchState);
if (mPoorNetworkDetectionEnabled) {
transitionTo(mOnlineWatchState);
} else {
transitionTo(mOnlineState);
}
return HANDLED;
}
}