Make function void and remove outdated TODOs

b/236892130 has long been addressed and there is an existing integration
test (EthernetManagerTest#testRemoveInterface_whileInServerMode).

The second TODO is just wrong. removeInterface() does nothing when the
interface is currently in tethering/server mode which is expected.
EthernetTracker#removeInterface() correctly deals with both client and
tethering/server mode interfaces, and multiple tests exist that validate
the callback behavior.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ib28a762e66997b31e2085cdda418a1e6b785dfcd
This commit is contained in:
Patrick Rohr 2025-06-06 12:35:53 -07:00
commit 1a488e767d

View file

@ -219,17 +219,10 @@ public class EthernetNetworkFactory {
}
/** Removes the interface from the factory and returns whether the interface was tracked */
public boolean removeInterface(EthernetPort port) {
NetworkInterfaceState iface = mTrackingInterfaces.remove(port.getInterfaceName());
if (iface != null) {
iface.unregisterNetworkOfferAndStop();
return true;
}
// TODO(b/236892130): if an interface is currently in server mode, it may not be properly
// removed.
// TODO: when false is returned, do not send a STATE_ABSENT callback.
Log.w(TAG, "removeInterface() failed because port is not tracked " + port);
return false;
public void removeInterface(EthernetPort port) {
final NetworkInterfaceState iface = mTrackingInterfaces.remove(port.getInterfaceName());
if (iface == null) return; // interface is in tethering mode; nothing to do.
iface.unregisterNetworkOfferAndStop();
}
/** Returns true if state has been modified */