ethernet: add early return for server mode interfaces
Server mode interfaces can be handled earlier in addInterface, which
avoids a bunch of objects from being created and makes the code more
readable by removing the large if / else block.
Test: atest EthernetManagerTest
Change-Id: I23e68d3532e69f5486f4d4b0edb6eaac8145ed23
diff --git a/service-t/src/com/android/server/ethernet/EthernetTracker.java b/service-t/src/com/android/server/ethernet/EthernetTracker.java
index 7f353a3..ba367cf 100644
--- a/service-t/src/com/android/server/ethernet/EthernetTracker.java
+++ b/service-t/src/com/android/server/ethernet/EthernetTracker.java
@@ -584,6 +584,11 @@
return;
}
+ if (getInterfaceMode(iface) == INTERFACE_MODE_SERVER) {
+ maybeUpdateServerModeInterfaceState(iface, true);
+ return;
+ }
+
final String hwAddress = config.hwAddr;
NetworkCapabilities nc = mNetworkCapabilities.get(iface);
@@ -596,14 +601,9 @@
}
}
- final int mode = getInterfaceMode(iface);
- if (mode == INTERFACE_MODE_CLIENT) {
- IpConfiguration ipConfiguration = getOrCreateIpConfiguration(iface);
- Log.d(TAG, "Tracking interface in client mode: " + iface);
- mFactory.addInterface(iface, hwAddress, ipConfiguration, nc);
- } else {
- maybeUpdateServerModeInterfaceState(iface, true);
- }
+ IpConfiguration ipConfiguration = getOrCreateIpConfiguration(iface);
+ Log.d(TAG, "Tracking interface in client mode: " + iface);
+ mFactory.addInterface(iface, hwAddress, ipConfiguration, nc);
// Note: if the interface already has link (e.g., if we crashed and got
// restarted while it was running), we need to fake a link up notification so we