summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorQuang Luong <qal@google.com>2019-10-22 17:29:40 -0700
committerQuang Luong <qal@google.com>2019-10-29 16:10:38 -0700
commit7ec2b55a3686cc7a999fa136c68df93e69d5f685 (patch)
tree8018ad3f62bae6eddfdeafa3ae7f6a130c6a7f38 /libs
parent1824c4a65f417262013219d01a69a8a9034cd862 (diff)
Notify listener for changes to getNumSavedNetworks()
Bug: 70983952 Test: atest WifiPickerTrackerTest Change-Id: I66405ab1791c2b21ba4b45ebc54afa2ecf1c3dfe
Diffstat (limited to 'libs')
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java2
-rw-r--r--libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java41
2 files changed, 35 insertions, 8 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
index e6c17a4cb..8993cdfeb 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
@@ -176,6 +176,7 @@ public class WifiPickerTracker extends BaseWifiTracker {
@WorkerThread
@Override
protected void handleConfiguredNetworksChangedAction(@NonNull Intent intent) {
+ // TODO(b/70983952): Handle Passpoint configurations here
checkNotNull(intent, "Intent cannot be null!");
final WifiConfiguration config =
@@ -186,6 +187,7 @@ public class WifiPickerTracker extends BaseWifiTracker {
} else {
updateStandardWifiEntryConfigs(mWifiManager.getConfiguredNetworks());
}
+ notifyOnNumSavedNetworksChanged();
updateWifiEntries();
}
diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
index 4e5104851..3fd18f98c 100644
--- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
+++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
@@ -57,13 +57,20 @@ public class WifiPickerTrackerTest {
private static final long MAX_SCAN_AGE_MILLIS = 15_000;
private static final long SCAN_INTERVAL_MILLIS = 10_000;
- @Mock private Lifecycle mMockLifecycle;
- @Mock private Context mMockContext;
- @Mock private WifiManager mMockWifiManager;
- @Mock private ConnectivityManager mMockConnectivityManager;
- @Mock private NetworkScoreManager mMockNetworkScoreManager;
- @Mock private Clock mMockClock;
- @Mock private WifiPickerTracker.WifiPickerTrackerCallback mMockWifiTrackerCallback;
+ @Mock
+ private Lifecycle mMockLifecycle;
+ @Mock
+ private Context mMockContext;
+ @Mock
+ private WifiManager mMockWifiManager;
+ @Mock
+ private ConnectivityManager mMockConnectivityManager;
+ @Mock
+ private NetworkScoreManager mMockNetworkScoreManager;
+ @Mock
+ private Clock mMockClock;
+ @Mock
+ private WifiPickerTracker.WifiPickerTrackerCallback mMockWifiTrackerCallback;
private TestLooper mTestLooper;
@@ -125,7 +132,7 @@ public class WifiPickerTrackerTest {
* Tests that receiving a wifi state change broadcast notifies the listener.
*/
@Test
- public void testWifiStateChangeBroadcast_NotifiesListener() {
+ public void testWifiStateChangeBroadcast_notifiesListener() {
final WifiPickerTracker wifiPickerTracker = createTestWifiTracker2();
wifiPickerTracker.onStart();
verify(mMockContext).registerReceiver(mBroadcastReceiverCaptor.capture(),
@@ -139,6 +146,24 @@ public class WifiPickerTrackerTest {
}
/**
+ * Tests that a CONFIGURED_NETWORKS_CHANGED broadcast notifies the listener for
+ * numSavedNetworksChanged.
+ */
+ @Test
+ public void testConfiguredNetworksChanged_notifiesListener() {
+ final WifiPickerTracker wifiPickerTracker = createTestWifiTracker2();
+ wifiPickerTracker.onStart();
+ verify(mMockContext).registerReceiver(mBroadcastReceiverCaptor.capture(),
+ any(), any(), any());
+
+ mBroadcastReceiverCaptor.getValue().onReceive(mMockContext,
+ new Intent(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION));
+ mTestLooper.dispatchAll();
+
+ verify(mMockWifiTrackerCallback, atLeastOnce()).onNumSavedNetworksChanged();
+ }
+
+ /**
* Tests that the wifi state is set correctly after onStart, even if no broadcast was received.
*/
@Test