diff options
author | Amin Shaikh <ashaikh@google.com> | 2017-01-20 11:07:36 -0800 |
---|---|---|
committer | Amin Shaikh <ashaikh@google.com> | 2017-01-20 16:31:51 -0800 |
commit | 5eceb34aa6a940ac079fc336209e6fd981d30dd5 (patch) | |
tree | 2e26295921f03cc7736765ba43b7d1eb6e2ca44a | |
parent | 55066b337d76f6e8eb1b8b7aacbcd4b2b9024b9a (diff) |
Populate selected network in RecommendationRequest
Bug: 34467596
Test: ./runtests.sh
Change-Id: Ide0b4cbc9114bb8f79a2671103ab7f1cf0590dd0
-rw-r--r-- | service/java/com/android/server/wifi/RecommendedNetworkEvaluator.java | 3 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/RecommendedNetworkEvaluatorTest.java | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/RecommendedNetworkEvaluator.java b/service/java/com/android/server/wifi/RecommendedNetworkEvaluator.java index e8c1ad3b6..5b5b57e61 100644 --- a/service/java/com/android/server/wifi/RecommendedNetworkEvaluator.java +++ b/service/java/com/android/server/wifi/RecommendedNetworkEvaluator.java @@ -158,10 +158,13 @@ public class RecommendedNetworkEvaluator implements WifiNetworkSelector.NetworkE ScanResult[] scanResultArray = scanResults.toArray(new ScanResult[scanResults.size()]); WifiConfiguration[] availableConfigsArray = availableConfiguredNetworks .toArray(new WifiConfiguration[availableConfiguredNetworks.size()]); + int lastSelectedNetworkId = mWifiConfigManager.getLastSelectedNetwork(); + long lastSelectedNetworkTimestamp = mWifiConfigManager.getLastSelectedTimeStamp(); RecommendationRequest request = new RecommendationRequest.Builder() .setScanResults(scanResultArray) .setConnectedWifiConfig(currentNetwork) .setConnectableConfigs(availableConfigsArray) + .setLastSelectedNetwork(lastSelectedNetworkId, lastSelectedNetworkTimestamp) // TODO: pass in currently recommended network .build(); RecommendationResult result = mNetworkScoreManager.requestRecommendation(request); diff --git a/tests/wifitests/src/com/android/server/wifi/RecommendedNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/RecommendedNetworkEvaluatorTest.java index 719412952..d5ba0961d 100644 --- a/tests/wifitests/src/com/android/server/wifi/RecommendedNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/RecommendedNetworkEvaluatorTest.java @@ -405,6 +405,23 @@ public class RecommendedNetworkEvaluatorTest { assertTrue(request.getScanResults()[0].untrusted); } + @Test + public void testEvaluateNetworks_requestContainsLastSelectedNetwork() { + int lastSelectedNetworkId = 5; + long lastSelectedTimestamp = 1000; + when(mWifiConfigManager.wasEphemeralNetworkDeleted(anyString())).thenReturn(false); + when(mWifiConfigManager.getLastSelectedNetwork()).thenReturn(lastSelectedNetworkId); + when(mWifiConfigManager.getLastSelectedTimeStamp()).thenReturn(lastSelectedTimestamp); + + mRecommendedNetworkEvaluator.evaluateNetworks(Lists.newArrayList(TRUSTED_SCAN_DETAIL), + null, null, false, false /* untrustedNetworkAllowed */, null); + + verify(mNetworkScoreManager).requestRecommendation(mRecommendationRequestCaptor.capture()); + RecommendationRequest request = mRecommendationRequestCaptor.getValue(); + assertEquals(lastSelectedNetworkId, request.getLastSelectedNetworkId()); + assertEquals(lastSelectedTimestamp, request.getLastSelectedNetworkTimestamp()); + } + private static ScanDetail buildScanDetail(String ssid) { return new ScanDetail(WifiSsid.createFromAsciiEncoded(ssid), "00:00:00:00:00:00", "", 0, 0, 0, 0); |