diff options
author | Amin Shaikh <ashaikh@google.com> | 2016-12-19 18:01:20 -0800 |
---|---|---|
committer | Amin Shaikh <ashaikh@google.com> | 2016-12-21 11:45:04 -0800 |
commit | cdd04fa4eacf1b3e1979c28b4086c723d20b72e8 (patch) | |
tree | 2b4ba09bc6efb2ead7118d570b30e39adb35fa3d /src/com/android | |
parent | fded490e27e7d1b0d4539e31e5f7db4f8a85fe0b (diff) | |
download | NetworkRecommendation-cdd04fa4eacf1b3e1979c28b4086c723d20b72e8.tar.gz |
Update NetworkRecommendation to use the new api.
Bug: 33490132
Test: runtest --path runtest --path DefaultNetworkRecommendation{Provider,Service}Test.java
Change-Id: I3ac1cf7bcba647db8969e207af37da2af2167de0
Merged-In: I3ac1cf7bcba647db8969e207af37da2af2167de0
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/networkrecommendation/DefaultNetworkRecommendationService.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/com/android/networkrecommendation/DefaultNetworkRecommendationService.java b/src/com/android/networkrecommendation/DefaultNetworkRecommendationService.java index d3fbdfb..da7936c 100644 --- a/src/com/android/networkrecommendation/DefaultNetworkRecommendationService.java +++ b/src/com/android/networkrecommendation/DefaultNetworkRecommendationService.java @@ -206,22 +206,29 @@ public class DefaultNetworkRecommendationService extends Service { // If we ended up without a recommendation, recommend the provided configuration // instead. If we wanted the platform to avoid this network, too, we could send back an // empty recommendation. - WifiConfiguration recommendedConfig; + RecommendationResult recommendationResult; if (recommendedScanResult == null) { - recommendedConfig = request.getCurrentSelectedConfig(); + if (request.getCurrentSelectedConfig() != null) { + recommendationResult = RecommendationResult + .createConnectRecommendation(request.getCurrentSelectedConfig()); + } else { + recommendationResult = RecommendationResult.createDoNotConnectRecommendation(); + } } else { // Build a configuration based on the scan. - recommendedConfig = new WifiConfiguration(); + WifiConfiguration recommendedConfig = new WifiConfiguration(); recommendedConfig.SSID = quoteSsid(recommendedScanResult); recommendedConfig.BSSID = recommendedScanResult.BSSID; recommendedConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); + recommendationResult = RecommendationResult + .createConnectRecommendation(recommendedConfig); } synchronized (mStatsLock) { - mLastRecommended = recommendedConfig; + mLastRecommended = recommendationResult.getWifiConfiguration(); mRecommendationCounter++; } - if (DEBUG) Log.d(TAG, "Recommending network: " + configToString(recommendedConfig)); - callback.onResult(new RecommendationResult(recommendedConfig)); + if (DEBUG) Log.d(TAG, "Recommending network: " + configToString(mLastRecommended)); + callback.onResult(recommendationResult); } /** Score networks based on a few properties ... */ |