diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-05-25 04:48:43 -0700 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2017-06-06 11:14:55 -0700 |
commit | 1f6626d7488bba014b42bab8bbcd4720694df485 (patch) | |
tree | 546240ddc94ad22de73db2ed3ff6ea65c6abfcf6 /tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | |
parent | 2f47b2755faffaa1a011ddeb8527bd9c99bb6106 (diff) | |
download | android_frameworks_opt_net_wifi-1f6626d7488bba014b42bab8bbcd4720694df485.tar.gz android_frameworks_opt_net_wifi-1f6626d7488bba014b42bab8bbcd4720694df485.tar.bz2 android_frameworks_opt_net_wifi-1f6626d7488bba014b42bab8bbcd4720694df485.zip |
WifiStateMachine: add mode to softap update
Plumb the softap target mode in to WifiStateMachine so we can add it to
the softap state change broadcast.
Also cleaned up some of the error and stopping states noticed due to the
mode updates and tests. This removes extra calls to clear the requests
and uses the ap state change broadcast to notify registered callers
about the LOHS stopping instead of attempting to get intermediate state.
Bug: 62076211
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: Icff0a9b30e1eb9e5aa945d289d274da7ec8910eb
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 86bf62fe5..2a30b671b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -19,6 +19,7 @@ package com.android.server.wifi; import static android.net.wifi.WifiManager.EXTRA_PREVIOUS_WIFI_AP_STATE; import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_FAILURE_REASON; import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME; +import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_MODE; import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_STATE; import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLED; import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLING; @@ -495,20 +496,23 @@ public class WifiStateMachineTest { } private void checkApStateChangedBroadcast(Intent intent, int expectedCurrentState, - int expectedPrevState, int expectedErrorCode, String expectedIfaceName) { + int expectedPrevState, int expectedErrorCode, String expectedIfaceName, + int expectedMode) { int currentState = intent.getIntExtra(EXTRA_WIFI_AP_STATE, WIFI_AP_STATE_DISABLED); int prevState = intent.getIntExtra(EXTRA_PREVIOUS_WIFI_AP_STATE, WIFI_AP_STATE_DISABLED); int errorCode = intent.getIntExtra(EXTRA_WIFI_AP_FAILURE_REASON, HOTSPOT_NO_ERROR); String ifaceName = intent.getStringExtra(EXTRA_WIFI_AP_INTERFACE_NAME); + int mode = intent.getIntExtra(EXTRA_WIFI_AP_MODE, WifiManager.IFACE_IP_MODE_UNSPECIFIED); assertEquals(expectedCurrentState, currentState); assertEquals(expectedPrevState, prevState); assertEquals(expectedErrorCode, errorCode); assertEquals(expectedIfaceName, ifaceName); + assertEquals(expectedMode, mode); } - @Test - public void loadComponentsInApMode() throws Exception { - mWsm.setHostApRunning(new WifiConfiguration(), true); + private void loadComponentsInApMode(int mode) throws Exception { + SoftApModeConfiguration config = new SoftApModeConfiguration(mode, new WifiConfiguration()); + mWsm.setHostApRunning(config, true); mLooper.dispatchAll(); assertEquals("SoftApState", getCurrentState().getName()); @@ -532,13 +536,23 @@ public class WifiStateMachineTest { List<Intent> capturedIntents = intentCaptor.getAllValues(); checkApStateChangedBroadcast(capturedIntents.get(0), WIFI_AP_STATE_ENABLING, - WIFI_AP_STATE_DISABLED, HOTSPOT_NO_ERROR, WIFI_IFACE_NAME); + WIFI_AP_STATE_DISABLED, HOTSPOT_NO_ERROR, WIFI_IFACE_NAME, mode); checkApStateChangedBroadcast(capturedIntents.get(1), WIFI_AP_STATE_ENABLED, - WIFI_AP_STATE_ENABLING, HOTSPOT_NO_ERROR, WIFI_IFACE_NAME); + WIFI_AP_STATE_ENABLING, HOTSPOT_NO_ERROR, WIFI_IFACE_NAME, mode); checkApStateChangedBroadcast(capturedIntents.get(2), WIFI_AP_STATE_DISABLING, - WIFI_AP_STATE_ENABLED, HOTSPOT_NO_ERROR, WIFI_IFACE_NAME); + WIFI_AP_STATE_ENABLED, HOTSPOT_NO_ERROR, WIFI_IFACE_NAME, mode); checkApStateChangedBroadcast(capturedIntents.get(3), WIFI_AP_STATE_DISABLED, - WIFI_AP_STATE_DISABLING, HOTSPOT_NO_ERROR, WIFI_IFACE_NAME); + WIFI_AP_STATE_DISABLING, HOTSPOT_NO_ERROR, WIFI_IFACE_NAME, mode); + } + + @Test + public void loadComponentsInApModeForTethering() throws Exception { + loadComponentsInApMode(WifiManager.IFACE_IP_MODE_TETHERED); + } + + @Test + public void loadComponentsInApModeForLOHS() throws Exception { + loadComponentsInApMode(WifiManager.IFACE_IP_MODE_LOCAL_ONLY); } @Test @@ -662,7 +676,9 @@ public class WifiStateMachineTest { mWsm.setSupplicantRunning(false); mWsm.sendMessage(WifiStateMachine.CMD_DISABLE_P2P_RSP); mWsm.sendMessage(WifiMonitor.SUP_DISCONNECTION_EVENT); - mWsm.setHostApRunning(new WifiConfiguration(), true); + SoftApModeConfiguration config = new SoftApModeConfiguration( + WifiManager.IFACE_IP_MODE_TETHERED, new WifiConfiguration()); + mWsm.setHostApRunning(config, true); mLooper.dispatchAll(); assertEquals("SoftApState", getCurrentState().getName()); assertEquals(WifiManager.WIFI_STATE_DISABLED, mWsm.syncGetWifiState()); |