diff options
author | Roshan Pius <rpius@google.com> | 2020-05-29 22:12:46 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-05-29 22:12:46 +0000 |
commit | 47d386420fb3e3523f643f0d1e1fd3496c5f6aeb (patch) | |
tree | e99cec188d8b1fde599c80004b30d4f714346a71 /service | |
parent | 6230ee509760f2351d5ec99547522e79de0c5f8a (diff) | |
parent | ec1025373054e637e3b0e4e25ecafb18a4086e29 (diff) |
Merge changes I88af4e2d,I85cc20bd into rvc-dev
* changes:
WifiNetworkFactory: Stop scanning once user selects a network
ConfigurationMap: Don't cache specifier ScanResultMatchInfo
Diffstat (limited to 'service')
3 files changed, 25 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/ConfigurationMap.java b/service/java/com/android/server/wifi/ConfigurationMap.java index 1f21891e3..a050b9cd8 100644 --- a/service/java/com/android/server/wifi/ConfigurationMap.java +++ b/service/java/com/android/server/wifi/ConfigurationMap.java @@ -49,8 +49,12 @@ public class ConfigurationMap { if (config.shared || currentUser.equals(creatorUser) || mUserManager.isSameProfileGroup(currentUser, creatorUser)) { mPerIDForCurrentUser.put(config.networkId, config); - mScanResultMatchInfoMapForCurrentUser.put( - ScanResultMatchInfo.fromWifiConfiguration(config), config); + // TODO (b/142035508): Add a more generic fix. This cache should only hold saved + // networks. + if (!config.fromWifiNetworkSpecifier) { + mScanResultMatchInfoMapForCurrentUser.put( + ScanResultMatchInfo.fromWifiConfiguration(config), config); + } } return current; } diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 209044a65..d607b7893 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -2364,6 +2364,9 @@ public class WifiConfigManager { * @param scanDetail ScanDetail instance to use for looking up the network. * @return WifiConfiguration object representing the network corresponding to the scanDetail, * null if none exists. + * + * TODO (b/142035508): This should only return saved networks (and rename to + * getSavedNetworkForScanDetail()). */ public WifiConfiguration getConfiguredNetworkForScanDetail(ScanDetail scanDetail) { ScanResult scanResult = scanDetail.getScanResult(); @@ -2391,6 +2394,8 @@ public class WifiConfigManager { * {@link #mScanDetailCaches} for the retrieved network. * * @param scanDetail input a scanDetail from the scan result + * TODO (b/142035508): This should only return saved networks (and rename to + * updateScanDetailCacheFromScanDetail()). */ public void updateScanDetailCacheFromScanDetail(ScanDetail scanDetail) { WifiConfiguration network = getConfiguredNetworkForScanDetail(scanDetail); @@ -2407,6 +2412,8 @@ public class WifiConfigManager { * @param scanDetail input a scanDetail from the scan result * @return WifiConfiguration object representing the network corresponding to the scanDetail, * null if none exists. + * TODO (b/142035508): This should only return saved networks (and rename to + * getSavedNetworkForScanDetailAndCache()). */ public WifiConfiguration getConfiguredNetworkForScanDetailAndCache(ScanDetail scanDetail) { WifiConfiguration network = getConfiguredNetworkForScanDetail(scanDetail); diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java index 98ba5bc94..9dc89addc 100644 --- a/service/java/com/android/server/wifi/WifiNetworkFactory.java +++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java @@ -146,6 +146,7 @@ public class WifiNetworkFactory extends NetworkFactory { private boolean mVerboseLoggingEnabled = false; private boolean mPeriodicScanTimerSet = false; private boolean mConnectionTimeoutSet = false; + private boolean mIsPeriodicScanEnabled = false; private boolean mIsPeriodicScanPaused = false; // We sent a new connection request and are waiting for connection success. private boolean mPendingConnectionSuccess = false; @@ -256,6 +257,7 @@ public class WifiNetworkFactory extends NetworkFactory { public void onAlarm() { // Trigger the next scan. startScan(); + mPeriodicScanTimerSet = false; } } @@ -264,6 +266,7 @@ public class WifiNetworkFactory extends NetworkFactory { public void onAlarm() { Log.e(TAG, "Timed-out connecting to network"); handleNetworkConnectionFailure(mUserSelectedNetwork); + mConnectionTimeoutSet = false; } } @@ -819,6 +822,7 @@ public class WifiNetworkFactory extends NetworkFactory { // Cancel the ongoing scans after user selection. cancelPeriodicScans(); + mIsPeriodicScanEnabled = false; // Trigger connection attempts. handleConnectToNetworkUserSelectionInternal(network); @@ -918,13 +922,13 @@ public class WifiNetworkFactory extends NetworkFactory { public void handleScreenStateChanged(boolean screenOn) { // If there is no active request or if the user has already selected a network, // ignore screen state changes. - if (mActiveSpecificNetworkRequest == null || mUserSelectedNetwork != null) return; + if (mActiveSpecificNetworkRequest == null || !mIsPeriodicScanEnabled) return; // Pause periodic scans when the screen is off & resume when the screen is on. if (screenOn) { if (mVerboseLoggingEnabled) Log.v(TAG, "Resuming scans on screen on"); - startScan(); mIsPeriodicScanPaused = false; + startScan(); } else { if (mVerboseLoggingEnabled) Log.v(TAG, "Pausing scans on screen off"); cancelPeriodicScans(); @@ -971,6 +975,7 @@ public class WifiNetworkFactory extends NetworkFactory { mActiveSpecificNetworkRequestSpecifier = null; mUserSelectedNetwork = null; mUserSelectedNetworkConnectRetryCount = 0; + mIsPeriodicScanEnabled = false; mIsPeriodicScanPaused = false; mActiveMatchedScanResults = null; mPendingConnectionSuccess = false; @@ -1075,6 +1080,7 @@ public class WifiNetworkFactory extends NetworkFactory { mScanSettings.hiddenNetworks.add(new WifiScanner.ScanSettings.HiddenNetwork( addEnclosingQuotes(wns.ssidPatternMatcher.getPath()))); } + mIsPeriodicScanEnabled = true; startScan(); } @@ -1103,6 +1109,10 @@ public class WifiNetworkFactory extends NetworkFactory { Log.e(TAG, "Scan triggered when there is no active network request. Ignoring..."); return; } + if (!mIsPeriodicScanEnabled) { + Log.e(TAG, "Scan triggered after user selected network. Ignoring..."); + return; + } if (mVerboseLoggingEnabled) { Log.v(TAG, "Starting the next scan for " + mActiveSpecificNetworkRequestSpecifier); } |