diff --git a/Tethering/src/com/android/networkstack/tethering/Tethering.java b/Tethering/src/com/android/networkstack/tethering/Tethering.java index b50831d56a..56185e6c47 100644 --- a/Tethering/src/com/android/networkstack/tethering/Tethering.java +++ b/Tethering/src/com/android/networkstack/tethering/Tethering.java @@ -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: diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java index 1ddeec4d41..50ecfe1bfe 100644 --- a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java +++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java @@ -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