diff options
author | Roshan Pius <rpius@google.com> | 2020-05-28 22:18:16 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2020-05-28 22:36:13 -0700 |
commit | b33a1d5b8d8583628ca94b3df7ed5ededca1191d (patch) | |
tree | f4ec9a2be999e417770af4beb9749a799c682866 | |
parent | 05c32ca28760a70aca744e93c72bf9e34aa1f883 (diff) |
ConfigurationMap: Don't cache specifier ScanResultMatchInfo
WifiConfiguration's created from WifiNetworkSpecifier requests should
not be cached in the internal ScanResultMatchInfo cache maintained by
WifiConfigManager. This WifiConfiguration is truly ephemeral in nature
and is deleted after every connnection. Also, WifiNetworkSpecifier
WifiConfiguration is the only case today where we can have multiple
WifiConfiguration for the same network (because we
WifiConfiguration.shared = false for WifiNetworkSpecifier networks)
Note: A more generic fix for this will be done in b/142035508.
Since not storing cache entries for suggestions or WFA networks may
cause other side effects and too risky for R at this stage.
Bug: 157609789
Test: atest com.android.server.wifi
Test: atest ConnectedNetworkScorerTest WifiNetworkSpecifierTest
Test: act.py -c wifi_manager_cross.config -tb dut-name -tc
WifiNetworkRequestTest
Change-Id: I85cc20bd910cf3e974746653737a8fda54a27e09
3 files changed, 32 insertions, 2 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/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java b/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java index b433d94cf..02994ecad 100644 --- a/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java @@ -333,4 +333,23 @@ public class ConfigurationMapTest extends WifiBaseTest { mConfigs.clear(); assertNull(mConfigs.getByScanResultForCurrentUser(scanResult)); } + + @Test + public void testScanResultDoesNotMatchForWifiNetworkSpecifier() { + // Add regular saved network, this should create a scan result match info cache entry. + WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); + ScanResult scanResult = createScanResultForNetwork(config); + config.networkId = 5; + mConfigs.put(config); + assertNotNull(mConfigs.getByScanResultForCurrentUser(scanResult)); + + mConfigs.clear(); + + // Create WifiNetworkSpecifier network, this should not create a scan result match info + // cache entry. + config.ephemeral = true; + config.fromWifiNetworkSpecifier = true; + mConfigs.put(config); + assertNull(mConfigs.getByScanResultForCurrentUser(scanResult)); + } } |