From 71c181382708abc0f87648924fdb29507ea5411b Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Fri, 16 May 2025 13:16:03 +0900 Subject: [PATCH] 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 --- .../networkstack/tethering/Tethering.java | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/Tethering/src/com/android/networkstack/tethering/Tethering.java b/Tethering/src/com/android/networkstack/tethering/Tethering.java index 8c1167cb32..4bbe130a8a 100644 --- a/Tethering/src/com/android/networkstack/tethering/Tethering.java +++ b/Tethering/src/com/android/networkstack/tethering/Tethering.java @@ -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)) {