Remove ensureIpServerStartedLegacy.

Fold the method into its only caller. This is a no-op change.

The only types that could previously make it to this method are
BLUETOOTH pre-T and WIGIG pre-S. Therefore the call to
checkTetherableType is mostly redundant, except for the check
that WIGIG should not be brought up if the device does not
have FEATURE_WIFI. Put that check into the caller as well.

Bug: 408087033
Flag: EXEMPT refactor
Test: no-op covered by existing tests
Change-Id: I380d649c2fd8af8b00a55a5bb7d2254c8b126a34
This commit is contained in:
Lorenzo Colitti 2025-05-16 13:16:03 +09:00
commit 71c1813827

View file

@ -614,7 +614,10 @@ public class Tethering {
if (type == TETHERING_BLUETOOTH && SdkLevel.isAtLeastT()) return;
// Cannot happen: on S+, tetherableWigigRegexps is always empty.
if (type == TETHERING_WIGIG && SdkLevel.isAtLeastS()) return;
if (type == TETHERING_WIGIG
&& (SdkLevel.isAtLeastS() || !hasSystemFeature(PackageManager.FEATURE_WIFI))) {
return;
}
// After V, don't allow this legacy codepath to create IpServers for any tethering type:
// everything must call ensureIpServerStarted directly. Also, on any release, don't create
@ -644,7 +647,7 @@ public class Tethering {
if (enabled && type == TETHERING_INVALID) return;
if (enabled) {
ensureIpServerStartedLegacy(iface, type);
ensureIpServerStarted(iface, type, false /* isNcm */);
} else {
ensureIpServerStopped(iface);
}
@ -3057,22 +3060,6 @@ public class Tethering {
return type != TETHERING_INVALID;
}
/**
* Creates an IpServer, but does not enable it. Only used by legacy codepaths:
* - Pre-T BLUETOOTH
* - (Pre-S) WIGIG
*/
private void ensureIpServerStartedLegacy(final String iface, int interfaceType) {
// If we don't care about this type of interface, ignore.
if (!checkTetherableType(interfaceType)) {
mLog.log(iface + " is used for " + interfaceType + " which is not tetherable"
+ " (-1 == INVALID is expected on upstream interface)");
return;
}
ensureIpServerStarted(iface, interfaceType, false /* isNcm */);
}
private void ensureIpServerStarted(final String iface, int interfaceType, boolean isNcm) {
// If we have already started a TISM for this interface, skip.
if (mTetherStates.containsKey(iface)) {