diff options
3 files changed, 9 insertions, 1 deletions
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index 3beaac9..3a8e3fc 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -148,4 +148,7 @@ <!-- 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> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 882aa66..330a189 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -1602,6 +1602,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(); } diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 0134456..1b64f3e 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -1754,7 +1754,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); mWifiConfigStore.disableNetwork(mLastNetworkId, |