diff options
author | Rebecca Silberstein <silberst@google.com> | 2018-05-11 13:41:07 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-05-11 13:41:07 -0700 |
commit | c34614a12d12ac6bde619c580001be8d6ddee569 (patch) | |
tree | c73434e49eb44559f3f5166da666d130d4f46b5b | |
parent | ff0d90d78cb077ffbf2d927409ab3127f811fff5 (diff) | |
parent | ac532d206250b85a6a605ded31d5b1439d829112 (diff) |
Merge "WifiServiceImpl: stop softap when ip config fails" into pi-dev
am: ac532d2062
Change-Id: I88c499e3b484eabdd49baad89cdc99956b4461b2
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 15 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 14 |
2 files changed, 25 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index eb1746e87..c2913ea73 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -966,10 +966,17 @@ public class WifiServiceImpl extends IWifiManager.Stub { LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE); break; case WifiManager.IFACE_IP_MODE_CONFIGURATION_ERROR: - // there was an error setting up the hotspot... trigger onFailed for the - // registered LOHS requestors - sendHotspotFailedMessageToAllLOHSRequestInfoEntriesLocked( - LocalOnlyHotspotCallback.ERROR_GENERIC); + Slog.d(TAG, "IP mode config error - need to clean up"); + if (mLocalOnlyHotspotRequests.isEmpty()) { + Slog.d(TAG, "no LOHS requests, stop softap"); + stopSoftAp(); + } else { + Slog.d(TAG, "we have LOHS requests, clean them up"); + // there was an error setting up the hotspot... trigger onFailed for the + // registered LOHS requestors + sendHotspotFailedMessageToAllLOHSRequestInfoEntriesLocked( + LocalOnlyHotspotCallback.ERROR_GENERIC); + } updateInterfaceIpStateInternal(null, WifiManager.IFACE_IP_MODE_UNSPECIFIED); break; case WifiManager.IFACE_IP_MODE_UNSPECIFIED: diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 46b29a46b..102ebca15 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -2013,6 +2013,8 @@ public class WifiServiceImplTest { assertEquals(HOTSPOT_FAILED, message.what); assertEquals(ERROR_GENERIC, message.arg1); + verify(mWifiController, never()).sendMessage(eq(CMD_SET_AP), eq(0), eq(0)); + // sendMessage should only happen once since the requestor should be unregistered reset(mHandler); @@ -2024,6 +2026,18 @@ public class WifiServiceImplTest { } /** + * Verify that softap mode is stopped for tethering if we receive an update with an ip mode + * configuration error. + */ + @Test + public void testStopSoftApWhenIpConfigFails() throws Exception { + mWifiServiceImpl.updateInterfaceIpState(WIFI_IFACE_NAME, IFACE_IP_MODE_CONFIGURATION_ERROR); + mLooper.dispatchAll(); + + verify(mWifiController).sendMessage(eq(CMD_SET_AP), eq(0), eq(0)); + } + + /** * Verify that if a LOHS request is active and tethering starts, callers are notified on the * incompatible mode and are unregistered. */ |