From 7abed5d4cf741aca02836d06664263dc1e3aa699 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Tue, 2 Jul 2019 12:26:41 -0700 Subject: WifiNetworkSuggestionsManager: Persist user approval immediately User approval decisions are not currently triggering a disk persistence. If the app does not modify any of it's suggestions, then this approval bit may not get persisted. Bug: 136565650 Test: atest com.android.server.wifi Test: NetworkSuggestion ACTS test Change-Id: I8796132fa3cc6356b9f4d43c9d3ffcdd72f7c89a --- .../com/android/server/wifi/WifiNetworkSuggestionsManager.java | 1 + .../android/server/wifi/WifiNetworkSuggestionsManagerTest.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java index c2aade90b..6a5db5d23 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java +++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java @@ -714,6 +714,7 @@ public class WifiNetworkSuggestionsManager { Log.v(TAG, "Setting the app " + (approved ? "approved" : "not approved")); } perAppInfo.hasUserApproved = approved; + saveToStore(); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index ca7c13e31..ade54bd14 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -1817,6 +1817,10 @@ public class WifiNetworkSuggestionsManagerTest { // Cancel the notification. verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE); + // Verify config store interactions. + verify(mWifiConfigManager, times(2)).saveToStore(true); + assertTrue(mDataSource.hasNewDataToSerialize()); + reset(mNotificationManger); // We should not resend the notification next time the network is found in scan results. mWifiNetworkSuggestionsManager.getNetworkSuggestionsForScanDetail( @@ -1858,6 +1862,10 @@ public class WifiNetworkSuggestionsManagerTest { // Cancel the notification. verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE); + // Verify config store interactions. + verify(mWifiConfigManager, times(2)).saveToStore(true); + assertTrue(mDataSource.hasNewDataToSerialize()); + reset(mNotificationManger); // Now trigger the app-ops callback to ensure we remove all of their suggestions. -- cgit v1.2.3