diff options
author | Amin Shaikh <ashaikh@google.com> | 2017-04-25 20:14:42 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-04-25 20:14:42 +0000 |
commit | 1cd9e7bd982aa73b3434f1421a1c154b5384d832 (patch) | |
tree | a01627d96ea8d5ec31a405a39ad2856e45267bd3 | |
parent | eb7eaf9747051e75519bd12c93c40bca866c456c (diff) | |
parent | 5d8bb242d898fc014011fe19c56b4c039805014e (diff) |
Remove CURATE_SAVED_OPEN_NETWORKS am: 2cf3661d14
am: 5d8bb242d8
Change-Id: I46f87368b00e23216a8b61cc1a90363b27468e84
3 files changed, 22 insertions, 121 deletions
diff --git a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java index cafe24ae2..7565f7819 100644 --- a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java +++ b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java @@ -17,12 +17,8 @@ package com.android.server.wifi; import android.content.Context; -import android.database.ContentObserver; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; -import android.os.Handler; -import android.os.Looper; -import android.provider.Settings; import android.util.LocalLog; import android.util.Pair; @@ -51,12 +47,9 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat private final int mSecurityAward; private final int mThresholdSaturatedRssi24; private final int mThresholdSaturatedRssi5; - private final ContentObserver mContentObserver; - private boolean mCurateSavedOpenNetworks; SavedNetworkEvaluator(final Context context, WifiConfigManager configManager, Clock clock, - LocalLog localLog, Looper looper, final FrameworkFacade frameworkFacade, - WifiConnectivityHelper connectivityHelper) { + LocalLog localLog, WifiConnectivityHelper connectivityHelper) { mWifiConfigManager = configManager; mClock = clock; mLocalLog = localLog; @@ -80,23 +73,6 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat R.integer.config_wifi_framework_wifi_score_good_rssi_threshold_24GHz); mThresholdSaturatedRssi5 = context.getResources().getInteger( R.integer.config_wifi_framework_wifi_score_good_rssi_threshold_5GHz); - mContentObserver = new ContentObserver(new Handler(looper)) { - @Override - public void onChange(boolean selfChange) { - boolean networkRecommendationsEnabled = frameworkFacade.getIntegerSetting(context, - Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0) == 1; - boolean curateSavedOpenNetworks = frameworkFacade.getIntegerSetting(context, - Settings.Global.CURATE_SAVED_OPEN_NETWORKS, 0) == 1; - mCurateSavedOpenNetworks = networkRecommendationsEnabled && curateSavedOpenNetworks; - } - }; - mContentObserver.onChange(false /* selfChange*/); - frameworkFacade.registerContentObserver(context, - Settings.Global.getUriFor(Settings.Global.CURATE_SAVED_OPEN_NETWORKS), - false /* notifyForDescendents */, mContentObserver); - frameworkFacade.registerContentObserver(context, - Settings.Global.getUriFor(Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED), - false /* notifyForDescendents */, mContentObserver); } private void localLog(String log) { @@ -320,13 +296,6 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat continue; } - if (mCurateSavedOpenNetworks - && WifiConfigurationUtil.isConfigForOpenNetwork(network)) { - localLog("Network " + WifiNetworkSelector.toNetworkString(network) - + " is open and CURATE_SAVED_OPEN_NETWORKS is enabled."); - continue; - } - if (score > highestScoreOfScanResult) { highestScoreOfScanResult = score; candidateIdOfScanResult = network.networkId; diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index a977a4693..799f9d5a0 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -198,9 +198,8 @@ public class WifiInjector { mConnectivityLocalLog = new LocalLog(ActivityManager.isLowRamDeviceStatic() ? 256 : 512); mWifiNetworkSelector = new WifiNetworkSelector(mContext, mWifiConfigManager, mClock, mConnectivityLocalLog); - mSavedNetworkEvaluator = new SavedNetworkEvaluator(mContext, - mWifiConfigManager, mClock, mConnectivityLocalLog, wifiStateMachineLooper, - mFrameworkFacade, mWifiConnectivityHelper); + mSavedNetworkEvaluator = new SavedNetworkEvaluator(mContext, mWifiConfigManager, mClock, + mConnectivityLocalLog, mWifiConnectivityHelper); mRecommendedNetworkEvaluator = new RecommendedNetworkEvaluator(context, context.getContentResolver(), wifiStateMachineLooper, mFrameworkFacade, mNetworkScoreManager, mWifiConfigManager, mConnectivityLocalLog); diff --git a/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java index 54fc60a41..78a3a3d0f 100644 --- a/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java @@ -22,16 +22,11 @@ import static com.android.server.wifi.WifiConfigurationTestUtil.SECURITY_PSK; import static org.junit.Assert.*; import static org.mockito.Mockito.*; -import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; -import android.database.ContentObserver; -import android.net.Uri; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; -import android.os.Looper; import android.os.SystemClock; -import android.provider.Settings; import android.test.suitebuilder.annotation.SmallTest; import android.util.LocalLog; @@ -41,7 +36,6 @@ import com.android.server.wifi.WifiNetworkSelectorTestUtil.ScanDetailsAndWifiCon import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -64,10 +58,6 @@ public class SavedNetworkEvaluatorTest { when(mWifiConnectivityHelper.isFirmwareRoamingSupported()).thenReturn(false); when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime()); - when(mFrameworkFacade.getIntegerSetting(mContext, - Settings.Global.CURATE_SAVED_OPEN_NETWORKS, 0)).thenReturn(0); - when(mFrameworkFacade.getIntegerSetting(mContext, - Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0)).thenReturn(0); mThresholdMinimumRssi2G = mResource.getInteger( R.integer.config_wifi_framework_wifi_score_bad_rssi_threshold_24GHz); @@ -82,17 +72,8 @@ public class SavedNetworkEvaluatorTest { mThresholdSaturatedRssi5G = mResource.getInteger( R.integer.config_wifi_framework_wifi_score_good_rssi_threshold_5GHz); - ArgumentCaptor<ContentObserver> observerCaptor = - ArgumentCaptor.forClass(ContentObserver.class); - mSavedNetworkEvaluator = new SavedNetworkEvaluator(mContext, mWifiConfigManager, - mClock, mLocalLog, Looper.getMainLooper(), mFrameworkFacade, - mWifiConnectivityHelper); - verify(mFrameworkFacade, times(2)).registerContentObserver(eq(mContext), any(Uri.class), - eq(false), observerCaptor.capture()); - // SavedNetworkEvaluator uses a single ContentObserver for two registrations, we only need - // to get this object once. - mContentObserver = observerCaptor.getValue(); + mClock, mLocalLog, mWifiConnectivityHelper); } /** Cleans up test. */ @@ -105,8 +86,6 @@ public class SavedNetworkEvaluatorTest { @Mock private WifiConfigManager mWifiConfigManager; @Mock private WifiConnectivityHelper mWifiConnectivityHelper; @Mock private Context mContext; - @Mock private ContentResolver mContentResolver; - @Mock private FrameworkFacade mFrameworkFacade; @Mock private Resources mResource; @Mock private Clock mClock; private LocalLog mLocalLog; @@ -116,11 +95,9 @@ public class SavedNetworkEvaluatorTest { private int mThresholdQualifiedRssi5G; private int mThresholdSaturatedRssi2G; private int mThresholdSaturatedRssi5G; - private ContentObserver mContentObserver; private void setupContext() { when(mContext.getResources()).thenReturn(mResource); - when(mContext.getContentResolver()).thenReturn(mContentResolver); } private void setupResource() { @@ -195,55 +172,18 @@ public class SavedNetworkEvaluatorTest { } /** - * Do not evaluate open networks when {@link Settings.Global.CURATE_SAVED_OPEN_NETWORKS} and - * {@link Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED} are enabled. - */ - @Test - public void ignoreOpensNetworksIfCurateSavedNetworksEnabled() { - String[] ssids = {"\"test1\"", "\"test2\""}; - String[] bssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4"}; - int[] freqs = {5200, 5240}; - String[] caps = {"[ESS]", "[ESS]"}; - int[] levels = {mThresholdQualifiedRssi5G, mThresholdQualifiedRssi5G}; - int[] securities = {SECURITY_NONE, SECURITY_NONE}; - - when(mFrameworkFacade.getIntegerSetting(mContext, - Settings.Global.CURATE_SAVED_OPEN_NETWORKS, 0)).thenReturn(1); - when(mFrameworkFacade.getIntegerSetting(mContext, - Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0)).thenReturn(1); - mContentObserver.onChange(false); - - ScanDetailsAndWifiConfigs scanDetailsAndConfigs = - WifiNetworkSelectorTestUtil.setupScanDetailsAndConfigStore(ssids, bssids, - freqs, caps, levels, securities, mWifiConfigManager, mClock); - List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails(); - - WifiConfiguration candidate = mSavedNetworkEvaluator.evaluateNetworks(scanDetails, - null, null, true, false, null); - - assertNull(candidate); - } - - /** - * Set the candidate {@link ScanResult} for all {@link WifiConfiguration}s even if they have - * useExternalScores set or are open networks with - * {@link Settings.Global.CURATE_SAVED_OPEN_NETWORKS} and - * {@link Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED} enabled. + * Set the candidate {@link ScanResult} for all {@link WifiConfiguration}s regardless of + * whether they are secure saved, open saved, or {@link WifiConfiguration#useExternalScores}. */ @Test public void setCandidateScanResultsForAllSavedNetworks() { - String[] ssids = {"\"test1\"", "\"test2\""}; - String[] bssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4"}; - int[] freqs = {5200, 5240}; - String[] caps = {"[WPA2-EAP-CCMP][ESS]", "[ESS]"}; - int[] levels = {mThresholdQualifiedRssi5G, mThresholdQualifiedRssi5G}; - int[] securities = {SECURITY_PSK, SECURITY_NONE}; - - when(mFrameworkFacade.getIntegerSetting(mContext, - Settings.Global.CURATE_SAVED_OPEN_NETWORKS, 0)).thenReturn(1); - when(mFrameworkFacade.getIntegerSetting(mContext, - Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0)).thenReturn(1); - mContentObserver.onChange(false); + String[] ssids = {"\"test1\"", "\"test2\"", "\"test3\""}; + String[] bssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4", "6c:f3:7f:ae:8c:f5"}; + int[] freqs = {5200, 5220, 5240}; + String[] caps = {"[WPA2-EAP-CCMP][ESS]", "[ESS]", "[WPA2-EAP-CCMP][ESS]"}; + int[] levels = + {mThresholdQualifiedRssi5G, mThresholdQualifiedRssi5G, mThresholdQualifiedRssi5G}; + int[] securities = {SECURITY_PSK, SECURITY_NONE, SECURITY_PSK}; ScanDetailsAndWifiConfigs scanDetailsAndConfigs = WifiNetworkSelectorTestUtil.setupScanDetailsAndConfigStore(ssids, bssids, @@ -252,25 +192,27 @@ public class SavedNetworkEvaluatorTest { WifiConfiguration useExternalScoresConfig = scanDetailsAndConfigs.getWifiConfigs()[0]; useExternalScoresConfig.useExternalScores = true; WifiConfiguration openNetworkConfig = scanDetailsAndConfigs.getWifiConfigs()[1]; + WifiConfiguration secureNetworkConfig = scanDetailsAndConfigs.getWifiConfigs()[2]; - WifiConfiguration candidate = mSavedNetworkEvaluator.evaluateNetworks(scanDetails, - null, null, true, false, null); - - assertNull(candidate); + mSavedNetworkEvaluator.evaluateNetworks(scanDetails, null, null, true, false, null); - verify(mWifiConfigManager).setNetworkCandidateScanResult( + verify(mWifiConfigManager, atLeastOnce()).setNetworkCandidateScanResult( eq(useExternalScoresConfig.networkId), eq(scanDetails.get(0).getScanResult()), anyInt()); - verify(mWifiConfigManager).setNetworkCandidateScanResult( + verify(mWifiConfigManager, atLeastOnce()).setNetworkCandidateScanResult( eq(openNetworkConfig.networkId), eq(scanDetails.get(1).getScanResult()), anyInt()); + verify(mWifiConfigManager, atLeastOnce()).setNetworkCandidateScanResult( + eq(secureNetworkConfig.networkId), + eq(scanDetails.get(2).getScanResult()), + anyInt()); } /** * Between two 2G networks, choose the one with stronger RSSI value if other conditions - * are the same and the RSSI values are not satuarted. + * are the same and the RSSI values are not saturated. */ @Test public void chooseStrongerRssi2GNetwork() { @@ -299,9 +241,6 @@ public class SavedNetworkEvaluatorTest { /** * Between two 5G networks, choose the one with stronger RSSI value if other conditions * are the same and the RSSI values are not saturated. - * {@link Settings.Global.CURATE_SAVED_OPEN_NETWORKS} and - * {@link Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED} will no affect on the outcome - * because both networks are secure. */ @Test public void chooseStrongerRssi5GNetwork() { @@ -312,12 +251,6 @@ public class SavedNetworkEvaluatorTest { int[] levels = {mThresholdQualifiedRssi5G + 8, mThresholdQualifiedRssi5G + 10}; int[] securities = {SECURITY_PSK, SECURITY_PSK}; - when(mFrameworkFacade.getIntegerSetting(mContext, - Settings.Global.CURATE_SAVED_OPEN_NETWORKS, 0)).thenReturn(1); - when(mFrameworkFacade.getIntegerSetting(mContext, - Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0)).thenReturn(1); - mContentObserver.onChange(false); - ScanDetailsAndWifiConfigs scanDetailsAndConfigs = WifiNetworkSelectorTestUtil.setupScanDetailsAndConfigStore(ssids, bssids, freqs, caps, levels, securities, mWifiConfigManager, mClock); |