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

Commit c96a6671 authored by Mike J. Chen's avatar Mike J. Chen
Browse files

Handle always present wired ethernet interfaces at boot.



Devices with always present wired ethernet interfaces (as opposed
to usb ethernet dongles) don't have the interface added and removed.
Instead, it is present already at boot time.  Change EthernetDataTracker
to support the already existing at boot time case.

Change-Id: I7b8e938f6b07aabd14f00ace55b35b7a05ea5a38
Signed-off-by: default avatarMike J. Chen <mjchen@google.com>
parent a934219c
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class EthernetDataTracker implements NetworkStateTracker {
    private Context mContext;

    private static EthernetDataTracker sInstance;
    private static String sIfaceMatch = "";
    private static String mIface = "";

    private static class InterfaceObserver extends INetworkManagementEventObserver.Stub {
@@ -96,7 +97,7 @@ public class EthernetDataTracker implements NetworkStateTracker {
    }

    private void interfaceAdded(String iface) {
        if (!iface.matches("eth\\d"))
        if (!iface.matches(sIfaceMatch))
            return;

        Log.d(TAG, "Adding " + iface);
@@ -187,6 +188,22 @@ public class EthernetDataTracker implements NetworkStateTracker {
        } catch (RemoteException e) {
            Log.e(TAG, "Could not register InterfaceObserver " + e);
        }

        // connect to an ethernet interface that already exists
        sIfaceMatch = context.getResources().getString(
            com.android.internal.R.string.config_ethernet_iface_regex);
        try {
            final String[] ifaces = service.listInterfaces();
            for (String iface : ifaces) {
                if (iface.matches(sIfaceMatch)) {
                    mIface = iface;
                    reconnect();
                    break;
                }
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Could not get list of interfaces " + e);
        }
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -160,6 +160,9 @@
    <string-array translatable="false" name="config_tether_upstream_regexs">
    </string-array>

    <!-- Regex of wired ethernet ifaces -->
    <string translatable="false" name="config_ethernet_iface_regex">eth\\d</string>

    <!-- Boolean indicating if we require the use of DUN on mobile for tethering.
         Note that this defaults to false so that if you move to a carrier that
         hasn't configured anything tethering will still work.  If you'd rather