diff options
author | Irfan Sheriff <isheriff@google.com> | 2011-11-21 14:03:00 -0800 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2011-11-21 14:03:00 -0800 |
commit | b9c955664bf300deb11e5aaf88e8ff4d11b26a73 (patch) | |
tree | 128176e32c14711685313a678013263e5871120b /core/java/android/net/DhcpStateMachine.java | |
parent | 38bc731875fec30d1a39f50cf3bf7234656f6698 (diff) | |
download | frameworks_base-b9c955664bf300deb11e5aaf88e8ff4d11b26a73.zip frameworks_base-b9c955664bf300deb11e5aaf88e8ff4d11b26a73.tar.gz frameworks_base-b9c955664bf300deb11e5aaf88e8ff4d11b26a73.tar.bz2 |
Add support for infinite dhcp lease time
Bug: 5649076
Change-Id: I29e3b41d8bd1173b155f3173e65a3b45ad17a45c
Diffstat (limited to 'core/java/android/net/DhcpStateMachine.java')
-rw-r--r-- | core/java/android/net/DhcpStateMachine.java | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/core/java/android/net/DhcpStateMachine.java b/core/java/android/net/DhcpStateMachine.java index fc6a44a..397a12a 100644 --- a/core/java/android/net/DhcpStateMachine.java +++ b/core/java/android/net/DhcpStateMachine.java @@ -347,21 +347,25 @@ public class DhcpStateMachine extends StateMachine { if (success) { if (DBG) Log.d(TAG, "DHCP succeeded on " + mInterfaceName); - 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); + long leaseDuration = dhcpInfoInternal.leaseDuration; //int to long conversion + + //Sanity check for renewal + if (leaseDuration >= 0) { + //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); + } else { + //infinite lease time, no renewal needed + } mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_SUCCESS, 0, dhcpInfoInternal) .sendToTarget(); |