From a171b41e2c47a93408c1f867e8570330cbcf5091 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 26 Jun 2019 11:07:21 -0700 Subject: WifiNetworkSuggestionsManager: Persist enterprise credentials Enterprise credentials for suggestions were not being persisted to disk. This would prevent the device from auto-connecting to networks suggested by apps (via the new network suggestion API surface) after a reboot. Bug: 136088495 Test: atest com.android.server.wifi Test: ACTS test: NetworkSuggestionTest Test: Verified scenario mentioned in the bug (carrier wifi app suggested EAP networks not connecting). Merged-In: Ife2cff3daf84a5986cb2b63207eccf1b6faee5ae Change-Id: Ife2cff3daf84a5986cb2b63207eccf1b6faee5ae --- .../wifi/NetworkSuggestionStoreDataTest.java | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'tests/wifitests/src/com') diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java index eeaf5cd00..5c1dcb459 100644 --- a/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java @@ -19,6 +19,7 @@ package com.android.server.wifi; import static org.junit.Assert.*; import static org.mockito.Mockito.*; +import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiNetworkSuggestion; import android.util.Xml; @@ -150,15 +151,30 @@ public class NetworkSuggestionStoreDataTest { Map networkSuggestionsMap = new HashMap<>(); PerAppInfo appInfo = new PerAppInfo(TEST_PACKAGE_NAME_1); - WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( - WifiConfigurationTestUtil.createOpenNetwork(), false, false, TEST_UID_1, + + WifiConfiguration configuration = WifiConfigurationTestUtil.createEapNetwork(); + configuration.enterpriseConfig = + WifiConfigurationTestUtil.createPEAPWifiEnterpriseConfigWithGTCPhase2(); + WifiNetworkSuggestion networkSuggestion = + new WifiNetworkSuggestion(configuration, false, false, TEST_UID_1, TEST_PACKAGE_NAME_1); appInfo.hasUserApproved = false; appInfo.extNetworkSuggestions.add( ExtendedWifiNetworkSuggestion.fromWns(networkSuggestion, appInfo)); networkSuggestionsMap.put(TEST_PACKAGE_NAME_1, appInfo); - assertSerializeDeserialize(networkSuggestionsMap); + Map deserializedPerAppInfoMap = + assertSerializeDeserialize(networkSuggestionsMap); + ExtendedWifiNetworkSuggestion deserializedSuggestion = + deserializedPerAppInfoMap.get(TEST_PACKAGE_NAME_1).extNetworkSuggestions.stream() + .findAny() + .orElse(null); + + WifiConfigurationTestUtil.assertConfigurationEqual( + configuration, deserializedSuggestion.wns.wifiConfiguration); + WifiConfigurationTestUtil.assertWifiEnterpriseConfigEqualForConfigStore( + configuration.enterpriseConfig, + deserializedSuggestion.wns.wifiConfiguration.enterpriseConfig); } /** @@ -237,7 +253,7 @@ public class NetworkSuggestionStoreDataTest { deserializeData(TEST_CORRUPT_DATA_INVALID_SSID.getBytes()); } - private void assertSerializeDeserialize( + private Map assertSerializeDeserialize( Map networkSuggestionsMap) throws Exception { // Setup the data to serialize. when(mDataSource.toSerialize()).thenReturn(networkSuggestionsMap); @@ -250,5 +266,6 @@ public class NetworkSuggestionStoreDataTest { ArgumentCaptor.forClass(HashMap.class); verify(mDataSource).fromDeserialized(deserializedNetworkSuggestionsMap.capture()); assertEquals(networkSuggestionsMap, deserializedNetworkSuggestionsMap.getValue()); + return deserializedNetworkSuggestionsMap.getValue(); } } -- cgit v1.2.3