summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-03-23 18:43:18 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-03-23 18:43:18 +0000
commitc9b0a3060a3dc018480dc8e0a4e043090f9e25e8 (patch)
tree66629edc940a7ec1f5929a40335ce973f6c4ecd0
parentca988991bf9bd700a9b1e3e46bdf468ca2ebf851 (diff)
parentfb30401ec20fa2f82c1ae9d37efc367630bb2995 (diff)
Merge "SoftApManager: retrieve config when null"
am: fb30401ec2 Change-Id: Ib21f636ba60da874bed40d4568d6733c4a0ccecc
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java13
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java24
2 files changed, 25 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index c8a15cf36..64f4a1494 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -61,6 +61,8 @@ public class SoftApManager implements ActiveModeManager {
private final WifiMetrics mWifiMetrics;
+ private WifiConfiguration mApConfig;
+
/**
* Listener for soft AP state changes.
*/
@@ -90,18 +92,19 @@ public class SoftApManager implements ActiveModeManager {
mApInterface = apInterface;
mNwService = nms;
mWifiApConfigStore = wifiApConfigStore;
- if (config != null) {
- mWifiApConfigStore.setApConfiguration(config);
+ if (config == null) {
+ mApConfig = mWifiApConfigStore.getApConfiguration();
+ } else {
+ mApConfig = config;
}
mWifiMetrics = wifiMetrics;
}
/**
- * Start soft AP with the current saved config.
+ * Start soft AP with the supplied config.
*/
public void start() {
- mStateMachine.sendMessage(SoftApStateMachine.CMD_START,
- mWifiApConfigStore.getApConfiguration());
+ mStateMachine.sendMessage(SoftApStateMachine.CMD_START, mApConfig);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index 4420f87da..900e6a61a 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -106,6 +106,9 @@ public class SoftApManagerTest {
when(mApInterface.asBinder()).thenReturn(mApInterfaceBinder);
when(mApInterface.startHostapd()).thenReturn(true);
when(mApInterface.stopHostapd()).thenReturn(true);
+ if (config == null) {
+ when(mWifiApConfigStore.getApConfiguration()).thenReturn(mDefaultApConfig);
+ }
SoftApManager newSoftApManager = new SoftApManager(mLooper.getLooper(),
mWifiNative,
TEST_COUNTRY_CODE,
@@ -116,9 +119,6 @@ public class SoftApManagerTest {
config,
mWifiMetrics);
mLooper.dispatchAll();
- if (config != null) {
- verify(mWifiApConfigStore).setApConfiguration(config);
- }
return newSoftApManager;
}
@@ -140,10 +140,21 @@ public class SoftApManagerTest {
/** Tests softap startup if default config fails to load. **/
@Test
public void startSoftApDefaultConfigFailedToLoad() throws Exception {
- InOrder order = inOrder(mListener);
- mSoftApManager = createSoftApManager(null);
+ when(mApInterface.asBinder()).thenReturn(mApInterfaceBinder);
+ when(mApInterface.startHostapd()).thenReturn(true);
+ when(mApInterface.stopHostapd()).thenReturn(true);
when(mWifiApConfigStore.getApConfiguration()).thenReturn(null);
- mSoftApManager.start();
+ SoftApManager newSoftApManager = new SoftApManager(mLooper.getLooper(),
+ mWifiNative,
+ TEST_COUNTRY_CODE,
+ mListener,
+ mApInterface,
+ mNmService,
+ mWifiApConfigStore,
+ null,
+ mWifiMetrics);
+ mLooper.dispatchAll();
+ newSoftApManager.start();
mLooper.dispatchAll();
verify(mListener).onStateChanged(WifiManager.WIFI_AP_STATE_FAILED,
WifiManager.SAP_START_FAILURE_GENERAL);
@@ -200,7 +211,6 @@ public class SoftApManagerTest {
when(mWifiApConfigStore.getApConfiguration()).thenReturn(mDefaultApConfig);
expectedSSID = mDefaultApConfig.SSID;
} else {
- when(mWifiApConfigStore.getApConfiguration()).thenReturn(config);
expectedSSID = config.SSID;
}
mSoftApManager.start();