From df01391f63407ea6611a02befd600efe4dd80c0f Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 10 Feb 2020 12:39:43 -0800 Subject: WifiApConfigStore: Store the shutdown enabled flag in config store Changes: a) Don't use the Settings.Global value to store the feature toggle. Store the info in config store file along with other softap configuration. b) Use the new WifiOemMigrationHook class to migrate the data out of the existing Settings value (for both backup/restore & config store). Also, fixed a bug in the ApConfigUtil.checkConfigurationChangeNeedToRestart() (was checking for object instance equality) Bug: 147779354 Bug: 148514485 Test: atest com.android.server.wifi Test: Manually verified the toggle from Settings. Change-Id: I84dd00ae112223b271e5fdbe4b25ea4ba8b1c9be --- .../server/wifi/SoftApBackupRestoreTest.java | 129 +++++++++++++++++++-- .../com/android/server/wifi/SoftApManagerTest.java | 51 +++----- .../android/server/wifi/SoftApStoreDataTest.java | 79 ++++++++++++- 3 files changed, 213 insertions(+), 46 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApBackupRestoreTest.java index 331ba92e4..c7565c6ca 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApBackupRestoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApBackupRestoreTest.java @@ -21,22 +21,32 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.*; import static org.mockito.Mockito.*; +import android.content.Context; import android.net.MacAddress; import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiOemMigrationHook; import android.util.BackupUtils; import androidx.test.filters.SmallTest; +import com.android.dx.mockito.inline.extended.ExtendedMockito; import com.android.server.wifi.util.ApConfigUtil; +import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.MockitoSession; +import org.mockito.quality.Strictness; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; /** * Unit tests for {@link com.android.server.wifi.SoftApBackupRestore}. @@ -44,15 +54,25 @@ import java.util.ArrayList; @SmallTest public class SoftApBackupRestoreTest extends WifiBaseTest { + @Mock private Context mContext; + @Mock private WifiOemMigrationHook.SettingsMigrationData mOemMigrationData; private SoftApBackupRestore mSoftApBackupRestore; + private final ArrayList mTestBlockedList = new ArrayList<>(); + private final ArrayList mTestAllowedList = new ArrayList<>(); private static final int LAST_WIFICOFIGURATION_BACKUP_VERSION = 3; private static final boolean TEST_CLIENTCONTROLENABLE = false; private static final int TEST_MAXNUMBEROFCLIENTS = 10; private static final int TEST_SHUTDOWNTIMEOUTMILLIS = 600_000; - private static final ArrayList TEST_BLOCKEDLIST = new ArrayList<>(); private static final String TEST_BLOCKED_CLIENT = "11:22:33:44:55:66"; - private static final ArrayList TEST_ALLOWEDLIST = new ArrayList<>(); private static final String TEST_ALLOWED_CLIENT = "aa:bb:cc:dd:ee:ff"; + private static final String TEST_SSID = "TestAP"; + private static final String TEST_PASSPHRASE = "TestPskPassphrase"; + private static final int TEST_SECURITY = SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION; + private static final int TEST_BAND = SoftApConfiguration.BAND_5GHZ; + private static final int TEST_CHANNEL = 40; + private static final boolean TEST_HIDDEN = false; + + MockitoSession mSession; /** * Asserts that the WifiConfigurations equal to SoftApConfiguration. @@ -76,10 +96,24 @@ public class SoftApBackupRestoreTest extends WifiBaseTest { assertEquals(backup.hiddenSSID, restore.isHiddenSsid()); } - @Before public void setUp() throws Exception { - mSoftApBackupRestore = new SoftApBackupRestore(); + MockitoAnnotations.initMocks(this); + + mSession = ExtendedMockito.mockitoSession() + .mockStatic(WifiOemMigrationHook.class, withSettings().lenient()) + .strictness(Strictness.LENIENT) + .startMocking(); + when(WifiOemMigrationHook.loadFromSettings(any(Context.class))) + .thenReturn(mOemMigrationData); + when(mOemMigrationData.isSoftApTimeoutEnabled()).thenReturn(true); + + mSoftApBackupRestore = new SoftApBackupRestore(mContext); + } + + @After + public void tearDown() throws Exception { + mSession.finishMocking(); } /** @@ -169,6 +203,7 @@ public class SoftApBackupRestoreTest extends WifiBaseTest { configBuilder.setPassphrase("TestPskPassphrase", SoftApConfiguration.SECURITY_TYPE_WPA3_SAE); configBuilder.setHiddenSsid(true); + configBuilder.setAutoShutdownEnabled(true); SoftApConfiguration config = configBuilder.build(); byte[] data = mSoftApBackupRestore.retrieveBackupDataFromSoftApConfiguration(config); @@ -190,6 +225,7 @@ public class SoftApBackupRestoreTest extends WifiBaseTest { configBuilder.setPassphrase("TestPskPassphrase", SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION); configBuilder.setHiddenSsid(true); + configBuilder.setAutoShutdownEnabled(false); SoftApConfiguration config = configBuilder.build(); byte[] data = mSoftApBackupRestore.retrieveBackupDataFromSoftApConfiguration(config); @@ -203,20 +239,19 @@ public class SoftApBackupRestoreTest extends WifiBaseTest { * Verifies that the serialization/de-serialization for wpa3-sae-transition softap config. */ @Test - public void testSoftApConfigBackupAndRestoreWithMaxShutDonwClientList() throws Exception { - TEST_BLOCKEDLIST.add(MacAddress.fromString(TEST_BLOCKED_CLIENT)); - TEST_ALLOWEDLIST.add(MacAddress.fromString(TEST_ALLOWED_CLIENT)); + public void testSoftApConfigBackupAndRestoreWithMaxShutDownClientList() throws Exception { + mTestBlockedList.add(MacAddress.fromString(TEST_BLOCKED_CLIENT)); + mTestAllowedList.add(MacAddress.fromString(TEST_ALLOWED_CLIENT)); SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(); - configBuilder.setSsid("TestAP"); + configBuilder.setSsid(TEST_SSID); configBuilder.setBand(SoftApConfiguration.BAND_5GHZ); configBuilder.setChannel(40, SoftApConfiguration.BAND_5GHZ); - configBuilder.setPassphrase("TestPskPassphrase", - SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION); - configBuilder.setHiddenSsid(true); + configBuilder.setPassphrase(TEST_PASSPHRASE, TEST_SECURITY); + configBuilder.setHiddenSsid(TEST_HIDDEN); configBuilder.setMaxNumberOfClients(TEST_MAXNUMBEROFCLIENTS); configBuilder.setShutdownTimeoutMillis(TEST_SHUTDOWNTIMEOUTMILLIS); configBuilder.enableClientControlByUser(TEST_CLIENTCONTROLENABLE); - configBuilder.setClientList(TEST_BLOCKEDLIST, TEST_ALLOWEDLIST); + configBuilder.setClientList(mTestBlockedList, mTestAllowedList); SoftApConfiguration config = configBuilder.build(); byte[] data = mSoftApBackupRestore.retrieveBackupDataFromSoftApConfiguration(config); @@ -225,4 +260,74 @@ public class SoftApBackupRestoreTest extends WifiBaseTest { assertThat(config).isEqualTo(restoredConfig); } + + /** + * Verifies that the restore of version 5 backup data will read the auto shutdown enable/disable + * tag from {@link WifiOemMigrationHook#loadFromSettings(Context)} + */ + @Test + public void testSoftApConfigRestoreFromVersion5() throws Exception { + mTestBlockedList.add(MacAddress.fromString(TEST_BLOCKED_CLIENT)); + mTestAllowedList.add(MacAddress.fromString(TEST_ALLOWED_CLIENT)); + SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(); + configBuilder.setSsid(TEST_SSID); + configBuilder.setBand(TEST_BAND); + configBuilder.setChannel(TEST_CHANNEL, TEST_BAND); + configBuilder.setPassphrase(TEST_PASSPHRASE, TEST_SECURITY); + configBuilder.setHiddenSsid(TEST_HIDDEN); + configBuilder.setMaxNumberOfClients(TEST_MAXNUMBEROFCLIENTS); + configBuilder.setShutdownTimeoutMillis(TEST_SHUTDOWNTIMEOUTMILLIS); + configBuilder.enableClientControlByUser(TEST_CLIENTCONTROLENABLE); + configBuilder.setClientList(mTestBlockedList, mTestAllowedList); + + // Toggle on when migrating. + when(mOemMigrationData.isSoftApTimeoutEnabled()).thenReturn(true); + SoftApConfiguration expectedConfig = configBuilder.setAutoShutdownEnabled(true).build(); + SoftApConfiguration restoredConfig = + mSoftApBackupRestore.retrieveSoftApConfigurationFromBackupData( + retrieveVersion5BackupDataFromSoftApConfiguration(expectedConfig)); + assertEquals(expectedConfig, restoredConfig); + + // Toggle off when migrating. + when(mOemMigrationData.isSoftApTimeoutEnabled()).thenReturn(false); + expectedConfig = configBuilder.setAutoShutdownEnabled(false).build(); + restoredConfig = mSoftApBackupRestore.retrieveSoftApConfigurationFromBackupData( + retrieveVersion5BackupDataFromSoftApConfiguration(expectedConfig)); + assertEquals(expectedConfig, restoredConfig); + } + + /** + * This is a copy of the old serialization code (version 5) + * + * Changes: Version = 5, AutoShutdown tag is missing. + */ + private byte[] retrieveVersion5BackupDataFromSoftApConfiguration(SoftApConfiguration config) + throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream out = new DataOutputStream(baos); + + out.writeInt(5); + BackupUtils.writeString(out, config.getSsid()); + out.writeInt(config.getBand()); + out.writeInt(config.getChannel()); + BackupUtils.writeString(out, config.getPassphrase()); + out.writeInt(config.getSecurityType()); + out.writeBoolean(config.isHiddenSsid()); + out.writeInt(config.getMaxNumberOfClients()); + out.writeInt(config.getShutdownTimeoutMillis()); + out.writeBoolean(config.isClientControlByUserEnabled()); + writeMacAddressList(out, config.getBlockedClientList()); + writeMacAddressList(out, config.getAllowedClientList()); + return baos.toByteArray(); + } + + private void writeMacAddressList(DataOutputStream out, List macList) + throws IOException { + out.writeInt(macList.size()); + Iterator iterator = macList.iterator(); + while (iterator.hasNext()) { + byte[] mac = iterator.next().toByteArray(); + out.write(mac, 0, 6); + } + } } diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java index a66480978..c5e90c5e6 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java @@ -54,9 +54,7 @@ import android.app.test.TestAlarmManager; import android.content.Context; import android.content.Intent; import android.content.res.Resources; -import android.database.ContentObserver; import android.net.MacAddress; -import android.net.Uri; import android.net.wifi.SoftApCapability; import android.net.wifi.SoftApConfiguration; import android.net.wifi.SoftApConfiguration.Builder; @@ -111,9 +109,8 @@ public class SoftApManagerTest extends WifiBaseTest { SoftApInfo.CHANNEL_WIDTH_20MHZ_NOHT; private static final int TEST_AP_BANDWIDTH_IN_SOFTAPINFO = SoftApInfo.CHANNEL_WIDTH_20MHZ_NOHT; private static final int[] EMPTY_CHANNEL_ARRAY = {}; - private final SoftApConfiguration mDefaultApConfig = createDefaultApConfig(); + private SoftApConfiguration mDefaultApConfig = createDefaultApConfig(); - private ContentObserver mContentObserver; private TestLooper mLooper; private TestAlarmManager mAlarmManager; private SoftApInfo mTestSoftApInfo; @@ -1473,9 +1470,10 @@ public class SoftApManagerTest extends WifiBaseTest { mTestSoftApCapability); startSoftApAndVerifyEnabled(apConfig); - when(mFrameworkFacade.getIntegerSetting( - mContext, Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 1)).thenReturn(0); - mContentObserver.onChange(false); + SoftApConfiguration newConfig = new SoftApConfiguration.Builder(mDefaultApConfig) + .setAutoShutdownEnabled(false) + .build(); + mSoftApManager.updateConfiguration(newConfig); mLooper.dispatchAll(); // Verify timer is canceled @@ -1485,16 +1483,18 @@ public class SoftApManagerTest extends WifiBaseTest { @Test public void schedulesTimeoutTimerOnTimeoutToggleChangeWhenNoClients() throws Exception { // start with timeout toggle disabled - when(mFrameworkFacade.getIntegerSetting( - mContext, Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 1)).thenReturn(0); + mDefaultApConfig = new SoftApConfiguration.Builder(mDefaultApConfig) + .setAutoShutdownEnabled(false) + .build(); SoftApModeConfiguration apConfig = new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null, mTestSoftApCapability); startSoftApAndVerifyEnabled(apConfig); - when(mFrameworkFacade.getIntegerSetting( - mContext, Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 1)).thenReturn(1); - mContentObserver.onChange(false); + SoftApConfiguration newConfig = new SoftApConfiguration.Builder(mDefaultApConfig) + .setAutoShutdownEnabled(true) + .build(); + mSoftApManager.updateConfiguration(newConfig); mLooper.dispatchAll(); // Verify timer is scheduled @@ -1505,8 +1505,9 @@ public class SoftApManagerTest extends WifiBaseTest { @Test public void doesNotScheduleTimeoutTimerOnStartWhenTimeoutIsDisabled() throws Exception { // start with timeout toggle disabled - when(mFrameworkFacade.getIntegerSetting( - mContext, Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 1)).thenReturn(0); + mDefaultApConfig = new SoftApConfiguration.Builder(mDefaultApConfig) + .setAutoShutdownEnabled(false) + .build(); SoftApModeConfiguration apConfig = new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null, mTestSoftApCapability); @@ -1521,8 +1522,9 @@ public class SoftApManagerTest extends WifiBaseTest { public void doesNotScheduleTimeoutTimerWhenAllClientsDisconnectButTimeoutIsDisabled() throws Exception { // start with timeout toggle disabled - when(mFrameworkFacade.getIntegerSetting( - mContext, Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 1)).thenReturn(0); + mDefaultApConfig = new SoftApConfiguration.Builder(mDefaultApConfig) + .setAutoShutdownEnabled(false) + .build(); SoftApModeConfiguration apConfig = new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null, mTestSoftApCapability); @@ -1540,18 +1542,6 @@ public class SoftApManagerTest extends WifiBaseTest { eq(mSoftApManager.SOFT_AP_SEND_MESSAGE_TIMEOUT_TAG), any(), any()); } - @Test - public void unregistersSettingsObserverOnStop() throws Exception { - SoftApModeConfiguration apConfig = - new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null, - mTestSoftApCapability); - startSoftApAndVerifyEnabled(apConfig); - mSoftApManager.stop(); - mLooper.dispatchAll(); - - verify(mFrameworkFacade).unregisterContentObserver(eq(mContext), eq(mContentObserver)); - } - @Test public void resetsFactoryMacWhenRandomizationOff() throws Exception { Builder configBuilder = new SoftApConfiguration.Builder(); @@ -1751,8 +1741,6 @@ public class SoftApManagerTest extends WifiBaseTest { .build(); } - ArgumentCaptor observerCaptor = ArgumentCaptor.forClass( - ContentObserver.class); ArgumentCaptor intentCaptor = ArgumentCaptor.forClass(Intent.class); when(mWifiNative.setupInterfaceForSoftApMode(any())) @@ -1787,9 +1775,6 @@ public class SoftApManagerTest extends WifiBaseTest { softApConfig.getTargetMode()); verify(mListener).onStarted(); verify(mWifiMetrics).addSoftApUpChangedEvent(true, softApConfig.getTargetMode()); - verify(mFrameworkFacade).registerContentObserver(eq(mContext), any(Uri.class), eq(true), - observerCaptor.capture()); - mContentObserver = observerCaptor.getValue(); } private void checkApStateChangedBroadcast(Intent intent, int expectedCurrentState, diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java index 62e20cc18..4275518a9 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java @@ -17,20 +17,26 @@ package com.android.server.wifi; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; +import android.content.Context; import android.net.MacAddress; import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiOemMigrationHook; import android.util.Xml; import androidx.test.filters.SmallTest; +import com.android.dx.mockito.inline.extended.ExtendedMockito; import com.android.internal.util.FastXmlSerializer; import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil; @@ -40,6 +46,8 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.mockito.MockitoSession; +import org.mockito.quality.Strictness; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlSerializer; @@ -63,6 +71,7 @@ public class SoftApStoreDataTest extends WifiBaseTest { private static final int TEST_OLD_BAND = WifiConfiguration.AP_BAND_ANY; private static final int TEST_SECURITY = SoftApConfiguration.SECURITY_TYPE_WPA2_PSK; private static final boolean TEST_CLIENT_CONTROL_BY_USER = false; + private static final boolean TEST_AUTO_SHUTDOWN_ENABLED = true; private static final int TEST_MAX_NUMBER_OF_CLIENTS = 10; private static final int TEST_SHUTDOWN_TIMEOUT_MILLIS = 600_000; private static final ArrayList TEST_BLOCKEDLIST = new ArrayList<>(); @@ -97,6 +106,8 @@ public class SoftApStoreDataTest extends WifiBaseTest { + TEST_MAX_NUMBER_OF_CLIENTS + "\" />\n" + "\n" + + "\n" + "\n" + "\n" @@ -106,6 +117,27 @@ public class SoftApStoreDataTest extends WifiBaseTest { + "" + TEST_ALLOWED_CLIENT + "\n" + "\n"; + private static final String TEST_SOFTAP_CONFIG_XML_STRING_WITH_ALL_CONFIG_EXCEPT_AUTO_SHUTDOWN = + "" + TEST_SSID + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "" + TEST_PASSPHRASE + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "" + TEST_BLOCKED_CLIENT + "\n" + + "\n" + + "\n" + + "" + TEST_ALLOWED_CLIENT + "\n" + + "\n"; + + @Mock private Context mContext; @Mock SoftApStoreData.DataSource mDataSource; @Mock WifiOemConfigStoreMigrationDataHolder mWifiOemConfigStoreMigrationDataHolder; SoftApStoreData mSoftApStoreData; @@ -113,7 +145,8 @@ public class SoftApStoreDataTest extends WifiBaseTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mSoftApStoreData = new SoftApStoreData(mDataSource, mWifiOemConfigStoreMigrationDataHolder); + mSoftApStoreData = + new SoftApStoreData(mContext, mDataSource, mWifiOemConfigStoreMigrationDataHolder); TEST_BLOCKEDLIST.add(MacAddress.fromString(TEST_BLOCKED_CLIENT)); TEST_ALLOWEDLIST.add(MacAddress.fromString(TEST_ALLOWED_CLIENT)); } @@ -150,6 +183,7 @@ public class SoftApStoreDataTest extends WifiBaseTest { softApConfigBuilder.setBand(TEST_BAND); softApConfigBuilder.enableClientControlByUser(TEST_CLIENT_CONTROL_BY_USER); softApConfigBuilder.setMaxNumberOfClients(TEST_MAX_NUMBER_OF_CLIENTS); + softApConfigBuilder.setAutoShutdownEnabled(true); softApConfigBuilder.setShutdownTimeoutMillis(TEST_SHUTDOWN_TIMEOUT_MILLIS); softApConfigBuilder.setClientList(TEST_BLOCKEDLIST, TEST_ALLOWEDLIST); return softApConfigBuilder.build(); @@ -229,6 +263,7 @@ public class SoftApStoreDataTest extends WifiBaseTest { assertEquals(softApConfig.getBand(), TEST_BAND); assertEquals(softApConfig.isClientControlByUserEnabled(), TEST_CLIENT_CONTROL_BY_USER); assertEquals(softApConfig.getMaxNumberOfClients(), TEST_MAX_NUMBER_OF_CLIENTS); + assertTrue(softApConfig.isAutoShutdownEnabled()); assertEquals(softApConfig.getShutdownTimeoutMillis(), TEST_SHUTDOWN_TIMEOUT_MILLIS); assertEquals(softApConfig.getBlockedClientList(), TEST_BLOCKEDLIST); assertEquals(softApConfig.getAllowedClientList(), TEST_ALLOWEDLIST); @@ -419,4 +454,46 @@ public class SoftApStoreDataTest extends WifiBaseTest { assertEquals(softApConfig.getAllowedClientList(), TEST_ALLOWEDLIST); } + /** + * Verify that the store data is deserialized correctly using the predefined test XML data + * when the auto shutdown tag is retrieved from + * {@link WifiOemMigrationHook.loadFromSettings(Context)}. + * + * @throws Exception + */ + @Test + public void deserializeSoftApWithNoAutoShutdownTag() throws Exception { + MockitoSession session = ExtendedMockito.mockitoSession() + .mockStatic(WifiConfigStore.class, withSettings().lenient()) + .strictness(Strictness.LENIENT) + .startMocking(); + WifiOemMigrationHook.SettingsMigrationData migrationData = mock( + WifiOemMigrationHook.SettingsMigrationData.class); + when(WifiOemMigrationHook.loadFromSettings(any())).thenReturn(migrationData); + + // Toggle on when migrating. + when(migrationData.isSoftApTimeoutEnabled()).thenReturn(true); + deserializeData( + TEST_SOFTAP_CONFIG_XML_STRING_WITH_ALL_CONFIG_EXCEPT_AUTO_SHUTDOWN.getBytes()); + ArgumentCaptor softapConfigCaptor = + ArgumentCaptor.forClass(SoftApConfiguration.class); + verify(mDataSource).fromDeserialized(softapConfigCaptor.capture()); + SoftApConfiguration softApConfig = softapConfigCaptor.getValue(); + assertNotNull(softApConfig); + assertEquals(softApConfig.getSsid(), TEST_SSID); + assertTrue(softApConfig.isAutoShutdownEnabled()); + + // Toggle off when migrating. + when(migrationData.isSoftApTimeoutEnabled()).thenReturn(false); + deserializeData( + TEST_SOFTAP_CONFIG_XML_STRING_WITH_ALL_CONFIG_EXCEPT_AUTO_SHUTDOWN.getBytes()); + verify(mDataSource).fromDeserialized(softapConfigCaptor.capture()); + softApConfig = softapConfigCaptor.getValue(); + assertNotNull(softApConfig); + assertEquals(softApConfig.getSsid(), TEST_SSID); + assertFalse(softApConfig.isAutoShutdownEnabled()); + + session.finishMocking(); + } + } -- cgit v1.2.3