Merge "Update wifi interface ip state upon receiving ap disable event" am: 25d4c75c26

am: 8e27bc49d4

Change-Id: I0ae8f80c9a4019977e3a26d1f3ef4270a069137e
This commit is contained in:
Jianpeng Li
2019-08-15 22:56:22 -07:00
committed by android-build-merger
2 changed files with 19 additions and 1 deletions

View File

@@ -1314,11 +1314,15 @@ public class Tethering extends BaseNetworkObserver {
mOffload.excludeDownstreamInterface(who.interfaceName()); mOffload.excludeDownstreamInterface(who.interfaceName());
mForwardedDownstreams.remove(who); mForwardedDownstreams.remove(who);
// If this is a Wi-Fi interface, tell WifiManager of any errors. // If this is a Wi-Fi interface, tell WifiManager of any errors
// or the inactive serving state.
if (who.interfaceType() == TETHERING_WIFI) { if (who.interfaceType() == TETHERING_WIFI) {
if (who.lastError() != TETHER_ERROR_NO_ERROR) { if (who.lastError() != TETHER_ERROR_NO_ERROR) {
getWifiManager().updateInterfaceIpState( getWifiManager().updateInterfaceIpState(
who.interfaceName(), IFACE_IP_MODE_CONFIGURATION_ERROR); who.interfaceName(), IFACE_IP_MODE_CONFIGURATION_ERROR);
} else {
getWifiManager().updateInterfaceIpState(
who.interfaceName(), IFACE_IP_MODE_UNSPECIFIED);
} }
} }
} }

View File

@@ -469,6 +469,8 @@ public class TetheringTest {
if (emulateInterfaceStatusChanged) { if (emulateInterfaceStatusChanged) {
assertEquals(1, mTetheringDependencies.isTetheringSupportedCalls); assertEquals(1, mTetheringDependencies.isTetheringSupportedCalls);
verifyTetheringBroadcast(TEST_WLAN_IFNAME, EXTRA_AVAILABLE_TETHER); verifyTetheringBroadcast(TEST_WLAN_IFNAME, EXTRA_AVAILABLE_TETHER);
verify(mWifiManager).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_UNSPECIFIED);
} }
verifyNoMoreInteractions(mNMService); verifyNoMoreInteractions(mNMService);
verifyNoMoreInteractions(mWifiManager); verifyNoMoreInteractions(mWifiManager);
@@ -533,6 +535,8 @@ public class TetheringTest {
verify(mNMService, times(1)).setIpForwardingEnabled(true); verify(mNMService, times(1)).setIpForwardingEnabled(true);
verify(mNMService, times(1)).startTethering(any(String[].class)); verify(mNMService, times(1)).startTethering(any(String[].class));
verifyNoMoreInteractions(mNMService); verifyNoMoreInteractions(mNMService);
verify(mWifiManager).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_UNSPECIFIED);
verify(mWifiManager).updateInterfaceIpState( verify(mWifiManager).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_LOCAL_ONLY); TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_LOCAL_ONLY);
verifyNoMoreInteractions(mWifiManager); verifyNoMoreInteractions(mWifiManager);
@@ -554,6 +558,8 @@ public class TetheringTest {
.setInterfaceConfig(eq(TEST_WLAN_IFNAME), any(InterfaceConfiguration.class)); .setInterfaceConfig(eq(TEST_WLAN_IFNAME), any(InterfaceConfiguration.class));
verify(mNMService, times(1)).stopTethering(); verify(mNMService, times(1)).stopTethering();
verify(mNMService, times(1)).setIpForwardingEnabled(false); verify(mNMService, times(1)).setIpForwardingEnabled(false);
verify(mWifiManager, times(3)).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_UNSPECIFIED);
verifyNoMoreInteractions(mNMService); verifyNoMoreInteractions(mNMService);
verifyNoMoreInteractions(mWifiManager); verifyNoMoreInteractions(mWifiManager);
// Asking for the last error after the per-interface state machine // Asking for the last error after the per-interface state machine
@@ -739,6 +745,8 @@ public class TetheringTest {
assertEquals(1, mTetheringDependencies.isTetheringSupportedCalls); assertEquals(1, mTetheringDependencies.isTetheringSupportedCalls);
verifyTetheringBroadcast(TEST_WLAN_IFNAME, EXTRA_AVAILABLE_TETHER); verifyTetheringBroadcast(TEST_WLAN_IFNAME, EXTRA_AVAILABLE_TETHER);
verify(mWifiManager).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_UNSPECIFIED);
verifyNoMoreInteractions(mNMService); verifyNoMoreInteractions(mNMService);
verifyNoMoreInteractions(mWifiManager); verifyNoMoreInteractions(mWifiManager);
} }
@@ -767,6 +775,8 @@ public class TetheringTest {
verify(mNMService, times(1)).setIpForwardingEnabled(true); verify(mNMService, times(1)).setIpForwardingEnabled(true);
verify(mNMService, times(1)).startTethering(any(String[].class)); verify(mNMService, times(1)).startTethering(any(String[].class));
verifyNoMoreInteractions(mNMService); verifyNoMoreInteractions(mNMService);
verify(mWifiManager).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_UNSPECIFIED);
verify(mWifiManager).updateInterfaceIpState( verify(mWifiManager).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_TETHERED); TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_TETHERED);
verifyNoMoreInteractions(mWifiManager); verifyNoMoreInteractions(mWifiManager);
@@ -805,6 +815,8 @@ public class TetheringTest {
.setInterfaceConfig(eq(TEST_WLAN_IFNAME), any(InterfaceConfiguration.class)); .setInterfaceConfig(eq(TEST_WLAN_IFNAME), any(InterfaceConfiguration.class));
verify(mNMService, times(1)).stopTethering(); verify(mNMService, times(1)).stopTethering();
verify(mNMService, times(1)).setIpForwardingEnabled(false); verify(mNMService, times(1)).setIpForwardingEnabled(false);
verify(mWifiManager, times(3)).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_UNSPECIFIED);
verifyNoMoreInteractions(mNMService); verifyNoMoreInteractions(mNMService);
verifyNoMoreInteractions(mWifiManager); verifyNoMoreInteractions(mWifiManager);
// Asking for the last error after the per-interface state machine // Asking for the last error after the per-interface state machine
@@ -841,6 +853,8 @@ public class TetheringTest {
.setInterfaceConfig(eq(TEST_WLAN_IFNAME), any(InterfaceConfiguration.class)); .setInterfaceConfig(eq(TEST_WLAN_IFNAME), any(InterfaceConfiguration.class));
verify(mNetd, times(1)).interfaceSetCfg(argThat(p -> TEST_WLAN_IFNAME.equals(p.ifName))); verify(mNetd, times(1)).interfaceSetCfg(argThat(p -> TEST_WLAN_IFNAME.equals(p.ifName)));
verify(mNMService, times(1)).tetherInterface(TEST_WLAN_IFNAME); verify(mNMService, times(1)).tetherInterface(TEST_WLAN_IFNAME);
verify(mWifiManager).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_UNSPECIFIED);
verify(mWifiManager).updateInterfaceIpState( verify(mWifiManager).updateInterfaceIpState(
TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_TETHERED); TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_TETHERED);
// TODO: Figure out why this isn't exactly once, for sendTetherStateChangedBroadcast(). // TODO: Figure out why this isn't exactly once, for sendTetherStateChangedBroadcast().