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

Commit efeba018 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

EthernetDataTracker: Don't run DHCP or set network available until link is up



Previously we were starting DHCP as soon as the interface was added,
which is at boot on devices with builtin ethernet.

Signed-off-by: default avatarMike Lockwood <lockwood@google.com>
parent 1ce5b26d
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class EthernetDataTracker implements NetworkStateTracker {
            if (mIface.equals(iface) && mLinkUp != up) {
                Log.d(TAG, "Interface " + iface + " link " + (up ? "up" : "down"));
                mLinkUp = up;
                mTracker.mNetworkInfo.setIsAvailable(up);

                // use DHCP
                if (up) {
@@ -102,11 +103,6 @@ public class EthernetDataTracker implements NetworkStateTracker {
        mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_ETHERNET, 0, NETWORKTYPE, "");
        mLinkProperties = new LinkProperties();
        mLinkCapabilities = new LinkCapabilities();
        mLinkUp = false;
        mHwAddr = null;

        mNetworkInfo.setIsAvailable(false);
        setTeardownRequested(false);
    }

    private void interfaceAdded(String iface) {
@@ -115,7 +111,7 @@ public class EthernetDataTracker implements NetworkStateTracker {

        Log.d(TAG, "Adding " + iface);

        synchronized(mIface) {
        synchronized(this) {
            if(!mIface.isEmpty())
                return;
            mIface = iface;
@@ -124,8 +120,6 @@ public class EthernetDataTracker implements NetworkStateTracker {
        mNetworkInfo.setIsAvailable(true);
        Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
        msg.sendToTarget();

        runDhcp();
    }

    public void disconnect() {
@@ -218,10 +212,11 @@ public class EthernetDataTracker implements NetworkStateTracker {
            for (String iface : ifaces) {
                if (iface.matches(sIfaceMatch)) {
                    mIface = iface;
                    service.setInterfaceUp(iface);
                    InterfaceConfiguration config = service.getInterfaceConfig(iface);
                    mLinkUp = config.isActive();
                    if (config != null && mHwAddr == null) {
                        mHwAddr = config.hwAddr;
                        mHwAddr = config.getHardwareAddress();
                        if (mHwAddr != null) {
                            mNetworkInfo.setExtraInfo(mHwAddr);
                        }
@@ -255,9 +250,11 @@ public class EthernetDataTracker implements NetworkStateTracker {
     * Re-enable connectivity to a network after a {@link #teardown()}.
     */
    public boolean reconnect() {
        if (mLinkUp) {
            mTeardownRequested.set(false);
            runDhcp();
        return true;
        }
        return mLinkUp;
    }

    /**