From 4c783d941d4b7dd4c22dc94bcd7bd338678bf59a Mon Sep 17 00:00:00 2001 From: Nate Jiang Date: Fri, 1 May 2020 14:36:50 -0700 Subject: [Suggestion] Add or remove suggestion before userData loaded will fail. Bug: 155416628 Test: atest com.android.server.wifi Change-Id: I302b6513e1ac359ad7aedc5097cb6e880cfa39ba --- .../wifi/WifiNetworkSuggestionsManagerTest.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index 8fa2fa1aa..17670a440 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -262,6 +262,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { verify(mWifiInjector).makeNetworkSuggestionStoreData(dataSourceArgumentCaptor.capture()); mDataSource = dataSourceArgumentCaptor.getValue(); assertNotNull(mDataSource); + mDataSource.fromDeserialized(Collections.EMPTY_MAP); verify(mWifiCarrierInfoManager).addImsiExemptionUserApprovalListener( mUserApproveCarrierListenerArgumentCaptor.capture()); @@ -374,6 +375,24 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { assertEquals(maxSizesCaptor.getValue(), new ArrayList() {{ add(1); add(1); }}); } + /** + * Add or remove suggestion before user data store loaded will fail. + */ + @Test + public void testAddRemoveSuggestionBeforeUserDataLoaded() { + // Clear the data source, and user data store is not loaded + mDataSource.reset(); + WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( + WifiConfigurationTestUtil.createOpenNetwork(), null, false, false, true, true); + List networkSuggestionList = Arrays.asList(networkSuggestion); + assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL, + mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1, + TEST_PACKAGE_1, TEST_FEATURE)); + assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL, + mWifiNetworkSuggestionsManager.remove(networkSuggestionList, TEST_UID_1, + TEST_PACKAGE_1)); + } + @Test public void testAddRemoveEnterpriseNetworkSuggestion() { WifiNetworkSuggestion networkSuggestion1 = new WifiNetworkSuggestion( @@ -3676,7 +3695,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { .add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1, TEST_FEATURE)); mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1); when(mLruConnectionTracker.isMostRecentlyConnected(any())).thenReturn(true); - Map suggestionStore = mDataSource.toSerialize(); + Map suggestionStore = new HashMap<>(mDataSource.toSerialize()); PerAppInfo perAppInfo = suggestionStore.get(TEST_PACKAGE_1); ExtendedWifiNetworkSuggestion ewns = perAppInfo.extNetworkSuggestions.iterator().next(); assertTrue(ewns.wns.wifiConfiguration.isMostRecentlyConnected); -- cgit v1.2.3