WifiStateTracker: add support for overriding DCHP max retry count in an overlay

Bug: 5551068

Change-Id: I7817eeb1409af2056a63548104c3c64f93ee7def
Signed-off-by: Mike Lockwood <lockwood@google.com>
This commit is contained in:
Mike Lockwood
2012-02-13 13:37:23 -08:00
parent 673b352f6b
commit 11046a2a4b
3 changed files with 10 additions and 1 deletions

View File

@@ -142,4 +142,8 @@
<!-- Development settings -->
<bool name="def_stay_on_while_plugged_in">false</bool>
<!-- Number of retries for connecting to DHCP.
Value here is the same as WifiStateMachine.DEFAULT_MAX_DHCP_RETRIES -->
<integer name="def_max_dhcp_retries">9</integer>
</resources>

View File

@@ -1565,6 +1565,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
loadBooleanSetting(stmt, Settings.Secure.NETSTATS_ENABLED,
R.bool.def_netstats_enabled);
loadIntegerSetting(stmt, Settings.Secure.WIFI_MAX_DHCP_RETRY_COUNT,
R.integer.def_max_dhcp_retries);
} finally {
if (stmt != null) stmt.close();
}

View File

@@ -1742,7 +1742,9 @@ public class WifiStateMachine extends StateMachine {
* If we've exceeded the maximum number of retries for DHCP
* to a given network, disable the network
*/
if (++mReconnectCount > getMaxDhcpRetries()) {
int maxRetries = getMaxDhcpRetries();
// maxRetries == 0 means keep trying forever
if (maxRetries > 0 && ++mReconnectCount > maxRetries) {
loge("Failed " +
mReconnectCount + " times, Disabling " + mLastNetworkId);
WifiConfigStore.disableNetwork(mLastNetworkId,