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

Commit 818cbe49 authored by Emilio López's avatar Emilio López
Browse files

Don't renew the leases if mDhcpInfo.leaseDuration is not positive

Some routers might give out really long or static leases, which we
shouldn't renew. mDhcpInfo.leaseDuration is -1 when this happens,
so don't try to renew the lease if it's value is not positive.

Change-Id: I8cf404347e1122489886662e2f42b10f98917d39
parent c984e3b7
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -2527,10 +2527,13 @@ public class WifiStateTracker extends NetworkStateTracker {
                            //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
                            //Don't do it if we're on an infinite lease
                            if (mDhcpInfo.leaseDuration >= 0) {
                                mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                                        SystemClock.elapsedRealtime() +
                                        mDhcpInfo.leaseDuration * 480, //in milliseconds
                                        mDhcpRenewalIntent);
                            }
                        } else {
                            event = EVENT_INTERFACE_CONFIGURATION_FAILED;
                            Log.e(TAG, "DHCP request failed: " + NetworkUtils.getDhcpError());