Use pending request when legacy tethering

Legacy tethering was changed to use it's own tethering requests
with REQUEST_TYPE_LEGACY in aosp/3465235 instead of using the pending
request as it was thought that pending requests (from startTethering)
and legacy tethering would always be mutually exclusive.

However, pre-T Bluetooth tethering actually relies on
startTethering(request) to add the pending request, and then BT service
directly calls legacyTether(iface) to start tethering. Thus we should
continue to use pending requests even for legacyTether.

Bug: 216524590
Test: atest TetheringTest
Change-Id: I0aa7b5cc6d6d54f516a07b0e89259c61e1d05f69
This commit is contained in:
Quang Anh Luong 2025-02-18 13:44:52 +09:00
commit e87bf658c4
2 changed files with 9 additions and 7 deletions

View file

@ -1152,7 +1152,10 @@ public class Tethering {
} catch (RemoteException e) { }
}
final TetheringRequest request = createLegacyGlobalScopeTetheringRequest(type);
TetheringRequest request = getPendingTetheringRequest(type);
if (request == null) {
request = createLegacyGlobalScopeTetheringRequest(type);
}
int result = tetherInternal(request, iface);
switch (type) {
case TETHERING_WIFI:

View file

@ -89,7 +89,6 @@ import static com.android.testutils.TestPermissionUtil.runAsShell;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@ -2881,7 +2880,7 @@ public class TetheringTest {
@Test
@IgnoreAfter(Build.VERSION_CODES.VANILLA_ICE_CREAM)
public void testRequestStaticIpLegacyTetherFailure() throws Exception {
public void testRequestStaticIpLegacyTether() throws Exception {
initTetheringOnTestThread();
// Call startTethering with static ip
@ -2907,14 +2906,14 @@ public class TetheringTest {
mLooper.dispatchAll();
tetherResult.assertHasResult();
// Verify that the static ip set in startTethering is not used
verify(mNetd).interfaceSetCfg(argThat(cfg -> !serverAddr.equals(cfg.ipv4Addr)));
// Verify that the static ip set in startTethering is used
verify(mNetd).interfaceSetCfg(argThat(cfg -> serverAddr.equals(cfg.ipv4Addr)));
verify(mIpServerDependencies, times(1)).makeDhcpServer(any(), dhcpParamsCaptor.capture(),
any());
final DhcpServingParamsParcel params = dhcpParamsCaptor.getValue();
assertNotEquals(serverAddr, intToInet4AddressHTH(params.serverAddr).getHostAddress());
assertEquals(serverAddr, intToInet4AddressHTH(params.serverAddr).getHostAddress());
assertEquals(24, params.serverAddrPrefixLength);
assertNotEquals(clientAddrParceled, params.singleClientAddr);
assertEquals(clientAddrParceled, params.singleClientAddr);
}
@Test