summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2011-06-15 14:10:51 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-06-15 14:10:51 -0700
commit1e8b3e4e76ba1a5ba5281234a049702d4df7d926 (patch)
tree0cba515aa3b64eb01391f198bf821592e02d3de4 /core/java
parentf3e3edb2f9cb3f353c57cf7b2e02937306e72703 (diff)
parent1195487228e1eb6c8859368286168051bd505b2f (diff)
downloadframeworks_base-1e8b3e4e76ba1a5ba5281234a049702d4df7d926.zip
frameworks_base-1e8b3e4e76ba1a5ba5281234a049702d4df7d926.tar.gz
frameworks_base-1e8b3e4e76ba1a5ba5281234a049702d4df7d926.tar.bz2
am 11954872: am 5af3405f: am ecda5461: Merge "Fix lease duration handling" into honeycomb-mr2
* commit '1195487228e1eb6c8859368286168051bd505b2f': Fix lease duration handling
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/DhcpStateMachine.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/core/java/android/net/DhcpStateMachine.java b/core/java/android/net/DhcpStateMachine.java
index eaf087f..c49c019 100644
--- a/core/java/android/net/DhcpStateMachine.java
+++ b/core/java/android/net/DhcpStateMachine.java
@@ -66,6 +66,9 @@ public class DhcpStateMachine extends StateMachine {
private static final int DHCP_RENEW = 0;
private static final String ACTION_DHCP_RENEW = "android.net.wifi.DHCP_RENEW";
+ //Used for sanity check on setting up renewal
+ private static final int MIN_RENEWAL_TIME_SECS = 5 * 60; // 5 minutes
+
private enum DhcpAction {
START,
RENEW
@@ -331,13 +334,21 @@ public class DhcpStateMachine extends StateMachine {
if (success) {
Log.d(TAG, "DHCP succeeded on " + mInterfaceName);
- //Do it a bit earlier than half the lease duration time
- //to beat the native DHCP client and avoid extra packets
- //48% for one hour lease time = 29 minutes
- mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
- SystemClock.elapsedRealtime() +
- dhcpInfoInternal.leaseDuration * 480, //in milliseconds
- mDhcpRenewalIntent);
+ long leaseDuration = dhcpInfoInternal.leaseDuration; //int to long conversion
+
+ //Sanity check for renewal
+ //TODO: would be good to notify the user that his network configuration is
+ //bad and that the device cannot renew below MIN_RENEWAL_TIME_SECS
+ if (leaseDuration < MIN_RENEWAL_TIME_SECS) {
+ leaseDuration = MIN_RENEWAL_TIME_SECS;
+ }
+ //Do it a bit earlier than half the lease duration time
+ //to beat the native DHCP client and avoid extra packets
+ //48% for one hour lease time = 29 minutes
+ mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ SystemClock.elapsedRealtime() +
+ leaseDuration * 480, //in milliseconds
+ mDhcpRenewalIntent);
mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_SUCCESS, 0, dhcpInfoInternal)
.sendToTarget();