Ignore calls to tether() where the interface type is invalid.

It looks like the code was already trying to ignore this (it
reported an error to the caller), but it then continued on to
create a request and call tetherInternal on it. This is still a
no-op because the code will never create an IpServer for an
interface that has type INVALID: IpServers are only ever created
in ensureIpServerStartedForType, and the only callers are:

- ensureIpServerStartedForInterface, which returns early if the
  type is INVALID.
- enableIpServing:
  - enableWifiP2pIpServing: returns early if type is INVALID
  - enableWifiIpServing: returns early if type is INVALID
  - enableUsbIpServing: can only pass in USB or NCM
  - BluetoothCallback#onAvailable: passes in BLUETOOTH
  - EthernetCallback#onAvailable: passes in ETHERNET
  - setVirtualMachineTethering: only called with VIRTUAL
  - StartTetheringSoftApCallback#onStateChanged: passes in the
    request previously passed to it by setWifiTethering, which
    is always WIFI.

Bug: 408087033
Test: covered by existing tests
Flag: EXEMPT dead code
Change-Id: I8ebba3edde93677c54488803fe4b573d78ad25a9
This commit is contained in:
Lorenzo Colitti 2025-05-13 15:47:13 +09:00
commit 81cdc02a63

View file

@ -1134,6 +1134,7 @@ public class Tethering {
if (type == TETHERING_INVALID) {
Log.e(TAG, "Ignoring call to legacy tether for unknown iface " + iface);
sendTetherResult(listener, TETHER_ERROR_UNKNOWN_IFACE);
return;
}
TetheringRequest request = mRequestTracker.getNextPendingRequest(type);