Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41b35884 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

Revert "DO NOT MERGE Revert "Fix lease duration handling""

This reverts commit 7dd12005.
parent 914ed90f
Loading
Loading
Loading
Loading
+18 −7
Original line number Original line Diff line number Diff line
@@ -66,6 +66,9 @@ public class DhcpStateMachine extends HierarchicalStateMachine {
    private static final int DHCP_RENEW = 0;
    private static final int DHCP_RENEW = 0;
    private static final String ACTION_DHCP_RENEW = "android.net.wifi.DHCP_RENEW";
    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 {
    private enum DhcpAction {
        START,
        START,
        RENEW
        RENEW
@@ -331,12 +334,20 @@ public class DhcpStateMachine extends HierarchicalStateMachine {


        if (success) {
        if (success) {
            Log.d(TAG, "DHCP succeeded on " + mInterfaceName);
            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
           //Do it a bit earlier than half the lease duration time
           //to beat the native DHCP client and avoid extra packets
           //to beat the native DHCP client and avoid extra packets
           //48% for one hour lease time = 29 minutes
           //48% for one hour lease time = 29 minutes
           mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
           mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                   SystemClock.elapsedRealtime() +
                   SystemClock.elapsedRealtime() +
                    dhcpInfoInternal.leaseDuration * 480, //in milliseconds
                   leaseDuration * 480, //in milliseconds
                   mDhcpRenewalIntent);
                   mDhcpRenewalIntent);


            mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_SUCCESS, 0, dhcpInfoInternal)
            mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_SUCCESS, 0, dhcpInfoInternal)