Merge "Disable poor network connection alone" into ics-mr1
This commit is contained in:
committed by
Android (Google) Code Review
commit
8a4cd3b105
@@ -3111,6 +3111,14 @@ public final class Settings {
|
|||||||
public static final String WIFI_WATCHDOG_BLACKLIST_FOLLOWUP_INTERVAL_MS =
|
public static final String WIFI_WATCHDOG_BLACKLIST_FOLLOWUP_INTERVAL_MS =
|
||||||
"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
|
* 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.
|
* the setting needs to be set to 0 to disable it.
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
private ConnectedState mConnectedState = new ConnectedState();
|
private ConnectedState mConnectedState = new ConnectedState();
|
||||||
private DnsCheckingState mDnsCheckingState = new DnsCheckingState();
|
private DnsCheckingState mDnsCheckingState = new DnsCheckingState();
|
||||||
private OnlineWatchState mOnlineWatchState = new OnlineWatchState();
|
private OnlineWatchState mOnlineWatchState = new OnlineWatchState();
|
||||||
|
private OnlineState mOnlineState = new OnlineState();
|
||||||
private DnsCheckFailureState mDnsCheckFailureState = new DnsCheckFailureState();
|
private DnsCheckFailureState mDnsCheckFailureState = new DnsCheckFailureState();
|
||||||
private DelayWalledGardenState mDelayWalledGardenState = new DelayWalledGardenState();
|
private DelayWalledGardenState mDelayWalledGardenState = new DelayWalledGardenState();
|
||||||
private WalledGardenState mWalledGardenState = new WalledGardenState();
|
private WalledGardenState mWalledGardenState = new WalledGardenState();
|
||||||
@@ -163,6 +164,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
private int mMinDnsResponses;
|
private int mMinDnsResponses;
|
||||||
private int mDnsPingTimeoutMs;
|
private int mDnsPingTimeoutMs;
|
||||||
private long mBlacklistFollowupIntervalMs;
|
private long mBlacklistFollowupIntervalMs;
|
||||||
|
private boolean mPoorNetworkDetectionEnabled;
|
||||||
private boolean mWalledGardenTestEnabled;
|
private boolean mWalledGardenTestEnabled;
|
||||||
private String mWalledGardenUrl;
|
private String mWalledGardenUrl;
|
||||||
|
|
||||||
@@ -226,6 +228,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
addState(mWalledGardenState, mConnectedState);
|
addState(mWalledGardenState, mConnectedState);
|
||||||
addState(mBlacklistedApState, mConnectedState);
|
addState(mBlacklistedApState, mConnectedState);
|
||||||
addState(mOnlineWatchState, mConnectedState);
|
addState(mOnlineWatchState, mConnectedState);
|
||||||
|
addState(mOnlineState, mConnectedState);
|
||||||
|
|
||||||
setInitialState(mWatchdogDisabledState);
|
setInitialState(mWatchdogDisabledState);
|
||||||
updateSettings();
|
updateSettings();
|
||||||
@@ -386,9 +389,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWatchdogEnabled() {
|
private boolean isWatchdogEnabled() {
|
||||||
//return getSettingsBoolean(mContentResolver, Settings.Secure.WIFI_WATCHDOG_ON, true);
|
return getSettingsBoolean(mContentResolver, Settings.Secure.WIFI_WATCHDOG_ON, true);
|
||||||
//TODO: fix this when we do aggressive monitoring
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSettings() {
|
private void updateSettings() {
|
||||||
@@ -413,6 +414,10 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
mBlacklistFollowupIntervalMs = Secure.getLong(mContentResolver,
|
mBlacklistFollowupIntervalMs = Secure.getLong(mContentResolver,
|
||||||
Settings.Secure.WIFI_WATCHDOG_BLACKLIST_FOLLOWUP_INTERVAL_MS,
|
Settings.Secure.WIFI_WATCHDOG_BLACKLIST_FOLLOWUP_INTERVAL_MS,
|
||||||
DEFAULT_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,
|
mWalledGardenTestEnabled = getSettingsBoolean(mContentResolver,
|
||||||
Settings.Secure.WIFI_WATCHDOG_WALLED_GARDEN_TEST_ENABLED, true);
|
Settings.Secure.WIFI_WATCHDOG_WALLED_GARDEN_TEST_ENABLED, true);
|
||||||
mWalledGardenUrl = getSettingsStr(mContentResolver,
|
mWalledGardenUrl = getSettingsStr(mContentResolver,
|
||||||
@@ -625,9 +630,13 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
|
|
||||||
initConnection(wifiInfo);
|
initConnection(wifiInfo);
|
||||||
mConnectionInfo = wifiInfo;
|
mConnectionInfo = wifiInfo;
|
||||||
|
mNetEventCounter++;
|
||||||
|
if (mPoorNetworkDetectionEnabled) {
|
||||||
updateBssids();
|
updateBssids();
|
||||||
transitionTo(mDnsCheckingState);
|
transitionTo(mDnsCheckingState);
|
||||||
mNetEventCounter++;
|
} else {
|
||||||
|
transitionTo(mDelayWalledGardenState);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mNetEventCounter++;
|
mNetEventCounter++;
|
||||||
@@ -679,12 +688,18 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
public boolean processMessage(Message msg) {
|
public boolean processMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case EVENT_SCAN_RESULTS_AVAILABLE:
|
case EVENT_SCAN_RESULTS_AVAILABLE:
|
||||||
|
if (mPoorNetworkDetectionEnabled) {
|
||||||
updateBssids();
|
updateBssids();
|
||||||
|
}
|
||||||
return HANDLED;
|
return HANDLED;
|
||||||
case EVENT_WATCHDOG_SETTINGS_CHANGE:
|
case EVENT_WATCHDOG_SETTINGS_CHANGE:
|
||||||
// Stop current checks, but let state update
|
updateSettings();
|
||||||
|
if (mPoorNetworkDetectionEnabled) {
|
||||||
transitionTo(mOnlineWatchState);
|
transitionTo(mOnlineWatchState);
|
||||||
return NOT_HANDLED;
|
} else {
|
||||||
|
transitionTo(mOnlineState);
|
||||||
|
}
|
||||||
|
return HANDLED;
|
||||||
}
|
}
|
||||||
return NOT_HANDLED;
|
return NOT_HANDLED;
|
||||||
}
|
}
|
||||||
@@ -831,7 +846,11 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
transitionTo(mWalledGardenState);
|
transitionTo(mWalledGardenState);
|
||||||
} else {
|
} else {
|
||||||
if (DBG) log("Walled garden test complete - online");
|
if (DBG) log("Walled garden test complete - online");
|
||||||
|
if (mPoorNetworkDetectionEnabled) {
|
||||||
transitionTo(mOnlineWatchState);
|
transitionTo(mOnlineWatchState);
|
||||||
|
} else {
|
||||||
|
transitionTo(mOnlineState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return HANDLED;
|
return HANDLED;
|
||||||
default:
|
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 {
|
class DnsCheckFailureState extends State {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1039,7 +1065,11 @@ public class WifiWatchdogStateMachine extends StateMachine {
|
|||||||
return HANDLED;
|
return HANDLED;
|
||||||
}
|
}
|
||||||
setWalledGardenNotificationVisible(true);
|
setWalledGardenNotificationVisible(true);
|
||||||
|
if (mPoorNetworkDetectionEnabled) {
|
||||||
transitionTo(mOnlineWatchState);
|
transitionTo(mOnlineWatchState);
|
||||||
|
} else {
|
||||||
|
transitionTo(mOnlineState);
|
||||||
|
}
|
||||||
return HANDLED;
|
return HANDLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user