Loading services/core/java/com/android/server/connectivity/Tethering.java +4 −0 Original line number Diff line number Diff line Loading @@ -846,6 +846,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering } if (!TextUtils.isEmpty(ifname)) { maybeTrackNewInterfaceLocked(ifname, ConnectivityManager.TETHERING_WIFI); changeInterfaceState(ifname, ipServingMode); } else { mLog.e(String.format( Loading Loading @@ -1876,7 +1877,10 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering mLog.log(iface + " is not a tetherable iface, ignoring"); return; } maybeTrackNewInterfaceLocked(iface, interfaceType); } private void maybeTrackNewInterfaceLocked(final String iface, int interfaceType) { // If we have already started a TISM for this interface, skip. if (mTetherStates.containsKey(iface)) { mLog.log("active iface (" + iface + ") reported as added, ignoring"); Loading tests/net/java/com/android/server/connectivity/TetheringTest.java +39 −7 Original line number Diff line number Diff line Loading @@ -235,32 +235,51 @@ public class TetheringTest { mIntents.remove(bcast); } @Test public void failingLocalOnlyHotspotLegacyApBroadcast() throws Exception { public void failingLocalOnlyHotspotLegacyApBroadcast( boolean emulateInterfaceStatusChanged) throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); // Emulate externally-visible WifiManager effects, causing the // per-interface state machine to start up, and telling us that // hotspot mode is to be started. if (emulateInterfaceStatusChanged) { mTethering.interfaceStatusChanged(mTestIfname, true); } sendWifiApStateChanged(WIFI_AP_STATE_ENABLED); mLooper.dispatchAll(); // If, and only if, Tethering received an interface status changed // then it creates a TetherInterfaceStateMachine and sends out a // broadcast indicating that the interface is "available". if (emulateInterfaceStatusChanged) { verify(mConnectivityManager, atLeastOnce()).isTetheringSupported(); verifyTetheringBroadcast(mTestIfname, ConnectivityManager.EXTRA_AVAILABLE_TETHER); } verifyNoMoreInteractions(mConnectivityManager); verifyNoMoreInteractions(mNMService); verifyNoMoreInteractions(mWifiManager); } @Test public void workingLocalOnlyHotspotEnrichedApBroadcast() throws Exception { public void failingLocalOnlyHotspotLegacyApBroadcastWithIfaceStatusChanged() throws Exception { failingLocalOnlyHotspotLegacyApBroadcast(true); } @Test public void failingLocalOnlyHotspotLegacyApBroadcastSansIfaceStatusChanged() throws Exception { failingLocalOnlyHotspotLegacyApBroadcast(false); } public void workingLocalOnlyHotspotEnrichedApBroadcast( boolean emulateInterfaceStatusChanged) throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); // Emulate externally-visible WifiManager effects, causing the // per-interface state machine to start up, and telling us that // hotspot mode is to be started. if (emulateInterfaceStatusChanged) { mTethering.interfaceStatusChanged(mTestIfname, true); } sendWifiApStateChanged(WIFI_AP_STATE_ENABLED, mTestIfname, IFACE_IP_MODE_LOCAL_ONLY); mLooper.dispatchAll(); Loading Loading @@ -304,6 +323,17 @@ public class TetheringTest { mTethering.getLastTetherError(mTestIfname)); } @Test public void workingLocalOnlyHotspotEnrichedApBroadcastWithIfaceChanged() throws Exception { workingLocalOnlyHotspotEnrichedApBroadcast(true); } @Test public void workingLocalOnlyHotspotEnrichedApBroadcastSansIfaceChanged() throws Exception { workingLocalOnlyHotspotEnrichedApBroadcast(false); } // TODO: Test with and without interfaceStatusChanged(). @Test public void failingWifiTetheringLegacyApBroadcast() throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); Loading Loading @@ -331,6 +361,7 @@ public class TetheringTest { verifyNoMoreInteractions(mWifiManager); } // TODO: Test with and without interfaceStatusChanged(). @Test public void workingWifiTetheringEnrichedApBroadcast() throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); Loading Loading @@ -412,6 +443,7 @@ public class TetheringTest { mTethering.getLastTetherError(mTestIfname)); } // TODO: Test with and without interfaceStatusChanged(). @Test public void failureEnablingIpForwarding() throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); Loading Loading
services/core/java/com/android/server/connectivity/Tethering.java +4 −0 Original line number Diff line number Diff line Loading @@ -846,6 +846,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering } if (!TextUtils.isEmpty(ifname)) { maybeTrackNewInterfaceLocked(ifname, ConnectivityManager.TETHERING_WIFI); changeInterfaceState(ifname, ipServingMode); } else { mLog.e(String.format( Loading Loading @@ -1876,7 +1877,10 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering mLog.log(iface + " is not a tetherable iface, ignoring"); return; } maybeTrackNewInterfaceLocked(iface, interfaceType); } private void maybeTrackNewInterfaceLocked(final String iface, int interfaceType) { // If we have already started a TISM for this interface, skip. if (mTetherStates.containsKey(iface)) { mLog.log("active iface (" + iface + ") reported as added, ignoring"); Loading
tests/net/java/com/android/server/connectivity/TetheringTest.java +39 −7 Original line number Diff line number Diff line Loading @@ -235,32 +235,51 @@ public class TetheringTest { mIntents.remove(bcast); } @Test public void failingLocalOnlyHotspotLegacyApBroadcast() throws Exception { public void failingLocalOnlyHotspotLegacyApBroadcast( boolean emulateInterfaceStatusChanged) throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); // Emulate externally-visible WifiManager effects, causing the // per-interface state machine to start up, and telling us that // hotspot mode is to be started. if (emulateInterfaceStatusChanged) { mTethering.interfaceStatusChanged(mTestIfname, true); } sendWifiApStateChanged(WIFI_AP_STATE_ENABLED); mLooper.dispatchAll(); // If, and only if, Tethering received an interface status changed // then it creates a TetherInterfaceStateMachine and sends out a // broadcast indicating that the interface is "available". if (emulateInterfaceStatusChanged) { verify(mConnectivityManager, atLeastOnce()).isTetheringSupported(); verifyTetheringBroadcast(mTestIfname, ConnectivityManager.EXTRA_AVAILABLE_TETHER); } verifyNoMoreInteractions(mConnectivityManager); verifyNoMoreInteractions(mNMService); verifyNoMoreInteractions(mWifiManager); } @Test public void workingLocalOnlyHotspotEnrichedApBroadcast() throws Exception { public void failingLocalOnlyHotspotLegacyApBroadcastWithIfaceStatusChanged() throws Exception { failingLocalOnlyHotspotLegacyApBroadcast(true); } @Test public void failingLocalOnlyHotspotLegacyApBroadcastSansIfaceStatusChanged() throws Exception { failingLocalOnlyHotspotLegacyApBroadcast(false); } public void workingLocalOnlyHotspotEnrichedApBroadcast( boolean emulateInterfaceStatusChanged) throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); // Emulate externally-visible WifiManager effects, causing the // per-interface state machine to start up, and telling us that // hotspot mode is to be started. if (emulateInterfaceStatusChanged) { mTethering.interfaceStatusChanged(mTestIfname, true); } sendWifiApStateChanged(WIFI_AP_STATE_ENABLED, mTestIfname, IFACE_IP_MODE_LOCAL_ONLY); mLooper.dispatchAll(); Loading Loading @@ -304,6 +323,17 @@ public class TetheringTest { mTethering.getLastTetherError(mTestIfname)); } @Test public void workingLocalOnlyHotspotEnrichedApBroadcastWithIfaceChanged() throws Exception { workingLocalOnlyHotspotEnrichedApBroadcast(true); } @Test public void workingLocalOnlyHotspotEnrichedApBroadcastSansIfaceChanged() throws Exception { workingLocalOnlyHotspotEnrichedApBroadcast(false); } // TODO: Test with and without interfaceStatusChanged(). @Test public void failingWifiTetheringLegacyApBroadcast() throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); Loading Loading @@ -331,6 +361,7 @@ public class TetheringTest { verifyNoMoreInteractions(mWifiManager); } // TODO: Test with and without interfaceStatusChanged(). @Test public void workingWifiTetheringEnrichedApBroadcast() throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); Loading Loading @@ -412,6 +443,7 @@ public class TetheringTest { mTethering.getLastTetherError(mTestIfname)); } // TODO: Test with and without interfaceStatusChanged(). @Test public void failureEnablingIpForwarding() throws Exception { when(mConnectivityManager.isTetheringSupported()).thenReturn(true); Loading