summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-04-30 20:38:52 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-04-30 20:38:52 +0000
commit84151d5f046698807902bbcff2b896a0ea55b71b (patch)
tree7f1384e2e2ebd4ed5a8640c69b7f97ed947ca48e /service
parent2088ffd0d55da07a7f56f7986f23ff1329a2bf74 (diff)
parent092d52862339c48d024cec4b5f4296ecd118d4fe (diff)
Merge changes I0e41dc95,If170fd4e into rvc-dev am: 329152acb0 am: 092d528623
Change-Id: I0c6ba7655760cf9da195cb6f359542b27cdddcd4
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/SavedNetworkNominator.java13
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java2
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java115
-rw-r--r--service/res/values/config.xml2
-rw-r--r--service/res/values/overlayable.xml1
5 files changed, 123 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/SavedNetworkNominator.java b/service/java/com/android/server/wifi/SavedNetworkNominator.java
index a3039096e..6480237ef 100644
--- a/service/java/com/android/server/wifi/SavedNetworkNominator.java
+++ b/service/java/com/android/server/wifi/SavedNetworkNominator.java
@@ -39,16 +39,19 @@ public class SavedNetworkNominator implements WifiNetworkSelector.NetworkNominat
private final WifiCarrierInfoManager mWifiCarrierInfoManager;
private final PasspointNetworkNominateHelper mPasspointNetworkNominateHelper;
private final WifiPermissionsUtil mWifiPermissionsUtil;
+ private final WifiNetworkSuggestionsManager mWifiNetworkSuggestionsManager;
SavedNetworkNominator(WifiConfigManager configManager,
PasspointNetworkNominateHelper nominateHelper, LocalLog localLog,
WifiCarrierInfoManager wifiCarrierInfoManager,
- WifiPermissionsUtil wifiPermissionsUtil) {
+ WifiPermissionsUtil wifiPermissionsUtil,
+ WifiNetworkSuggestionsManager wifiNetworkSuggestionsManager) {
mWifiConfigManager = configManager;
mPasspointNetworkNominateHelper = nominateHelper;
mLocalLog = localLog;
mWifiCarrierInfoManager = wifiCarrierInfoManager;
mWifiPermissionsUtil = wifiPermissionsUtil;
+ mWifiNetworkSuggestionsManager = wifiNetworkSuggestionsManager;
}
private void localLog(String log) {
@@ -155,6 +158,14 @@ public class SavedNetworkNominator implements WifiNetworkSelector.NetworkNominat
continue;
}
+ if (mWifiNetworkSuggestionsManager
+ .shouldBeIgnoredBySecureSuggestionFromSameCarrier(network,
+ scanDetails)) {
+ localLog("Open Network " + WifiNetworkSelector.toNetworkString(network)
+ + " has a secure network suggestion from same carrier.");
+ continue;
+ }
+
onConnectableListener.onConnectable(scanDetail,
mWifiConfigManager.getConfiguredNetwork(network.networkId));
}
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index b56d37a2c..5dc3296c9 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -310,7 +310,7 @@ public class WifiInjector {
mConnectivityLocalLog);
mSavedNetworkNominator = new SavedNetworkNominator(
mWifiConfigManager, nominateHelper, mConnectivityLocalLog, mWifiCarrierInfoManager,
- mWifiPermissionsUtil);
+ mWifiPermissionsUtil, mWifiNetworkSuggestionsManager);
mNetworkSuggestionNominator = new NetworkSuggestionNominator(mWifiNetworkSuggestionsManager,
mWifiConfigManager, nominateHelper, mConnectivityLocalLog, mWifiCarrierInfoManager);
mScoredNetworkNominator = new ScoredNetworkNominator(mContext, wifiHandler,
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index 685df0757..b83af52f2 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -1967,19 +1967,23 @@ public class WifiNetworkSuggestionsManager {
if (suggestion == null || suggestion.wifiConfiguration == null) {
continue;
}
- if (suggestion.passpointConfiguration != null) {
- filteredScanResults.put(suggestion,
- mWifiInjector.getPasspointManager().getMatchingScanResults(
- suggestion.passpointConfiguration, scanResults));
- } else {
- filteredScanResults.put(suggestion,
- getMatchingScanResults(suggestion.wifiConfiguration, scanResults));
- }
+ filteredScanResults.put(suggestion,
+ getMatchingScanResultsForSuggestion(suggestion, scanResults));
}
return filteredScanResults;
}
+ private List<ScanResult> getMatchingScanResultsForSuggestion(WifiNetworkSuggestion suggestion,
+ List<ScanResult> scanResults) {
+ if (suggestion.passpointConfiguration != null) {
+ return mWifiInjector.getPasspointManager().getMatchingScanResults(
+ suggestion.passpointConfiguration, scanResults);
+ } else {
+ return getMatchingScanResults(suggestion.wifiConfiguration, scanResults);
+ }
+ }
+
/**
* Get the filtered ScanResults which may be authenticated by the {@link WifiConfiguration}.
* @param wifiConfiguration The instance of {@link WifiConfiguration}
@@ -2013,6 +2017,101 @@ public class WifiNetworkSuggestionsManager {
}
/**
+ * When a saved open network has a same network suggestion which is from app has
+ * NETWORK_CARRIER_PROVISIONING permission, also that app suggested secure network suggestion
+ * for same carrier with higher or equal priority and Auto-Join enabled, also that secure
+ * network is in the range. The saved open network will be ignored during the network selection.
+ * TODO (b/142035508): revert all these changes once we build infra needed to solve this.
+ * @param configuration Saved open network to check if it should be ignored.
+ * @param scanDetails Available ScanDetail nearby.
+ * @return True if the open network should be ignored, false otherwise.
+ */
+ public boolean shouldBeIgnoredBySecureSuggestionFromSameCarrier(
+ @NonNull WifiConfiguration configuration, List<ScanDetail> scanDetails) {
+ if (!mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable)) {
+ return false;
+ }
+ if (configuration == null || scanDetails == null || !configuration.isOpenNetwork()) {
+ return false;
+ }
+ Set<ExtendedWifiNetworkSuggestion> matchedExtSuggestions =
+ getNetworkSuggestionsForWifiConfiguration(configuration, null);
+ if (matchedExtSuggestions == null || matchedExtSuggestions.isEmpty()) {
+ return false;
+ }
+ matchedExtSuggestions = matchedExtSuggestions.stream().filter(ewns ->
+ mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(ewns.perAppInfo.uid))
+ .collect(Collectors.toSet());
+ if (matchedExtSuggestions.isEmpty()) {
+ return false;
+ }
+ for (ExtendedWifiNetworkSuggestion ewns : matchedExtSuggestions) {
+ if (hasSecureSuggestionFromSameCarrierAvailable(ewns, scanDetails)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean hasSecureSuggestionFromSameCarrierAvailable(
+ ExtendedWifiNetworkSuggestion extendedWifiNetworkSuggestion,
+ List<ScanDetail> scanDetails) {
+ boolean isOpenSuggestionMetered = WifiConfiguration.isMetered(
+ extendedWifiNetworkSuggestion.wns.wifiConfiguration, null);
+ Set<ExtendedWifiNetworkSuggestion> secureExtSuggestions = new HashSet<>();
+ for (ExtendedWifiNetworkSuggestion ewns : extendedWifiNetworkSuggestion.perAppInfo
+ .extNetworkSuggestions) {
+ // Open network and auto-join disable suggestion, ignore.
+ if (isOpenSuggestion(ewns) || !ewns.isAutojoinEnabled) {
+ continue;
+ }
+ // From different carrier as open suggestion, ignore.
+ if (getCarrierIdFromSuggestion(ewns)
+ != getCarrierIdFromSuggestion(extendedWifiNetworkSuggestion)) {
+ continue;
+ }
+ // Secure and open has different meterness, ignore
+ if (WifiConfiguration.isMetered(ewns.wns.wifiConfiguration, null)
+ != isOpenSuggestionMetered) {
+ continue;
+ }
+ // Low priority than open suggestion, ignore.
+ if (ewns.wns.wifiConfiguration.priority
+ < extendedWifiNetworkSuggestion.wns.wifiConfiguration.priority) {
+ continue;
+ }
+ WifiConfiguration wcmConfig = mWifiConfigManager
+ .getConfiguredNetwork(ewns.wns.wifiConfiguration.getKey());
+ // Network selection is disabled, ignore.
+ if (wcmConfig != null && !wcmConfig.getNetworkSelectionStatus().isNetworkEnabled()) {
+ continue;
+ }
+ secureExtSuggestions.add(ewns);
+ }
+
+ if (secureExtSuggestions.isEmpty()) {
+ return false;
+ }
+ List<ScanResult> scanResults = scanDetails.stream().map(ScanDetail::getScanResult)
+ .collect(Collectors.toList());
+ // Check if the secure suggestion is in the range.
+ for (ExtendedWifiNetworkSuggestion ewns : secureExtSuggestions) {
+ if (!getMatchingScanResultsForSuggestion(ewns.wns, scanResults).isEmpty()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isOpenSuggestion(ExtendedWifiNetworkSuggestion extendedWifiNetworkSuggestion) {
+ if (extendedWifiNetworkSuggestion.wns.passpointConfiguration != null) {
+ return false;
+ }
+ return extendedWifiNetworkSuggestion.wns.wifiConfiguration.isOpenNetwork();
+ }
+
+ /**
* Dump of {@link WifiNetworkSuggestionsManager}.
*/
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index c58ab196b..5d8a47ca9 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -412,4 +412,6 @@
cause the wifi stack to turn wifi off and wait for user input.
Set to 0 to turn off recovery attempts and always turn off wifi on failures -->
<integer translatable="false" name="config_wifiMaxNativeFailureSelfRecoveryPerHour">2</integer>
+ <!-- Ignore the open saved network if from carrier provisioning app, there is a same open suggestion and a secure suggestion from same carrier available -->
+ <bool translatable="false" name="config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable">true</bool>
</resources>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 687b6b9e8..60454728d 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -129,6 +129,7 @@
<item type="bool" name="config_wifiSaeUpgradeEnabled" />
<item type="bool" name="config_wifiSaeUpgradeOffloadEnabled" />
<item type="integer" name="config_wifiMaxNativeFailureSelfRecoveryPerHour" />
+ <item type="bool" name="config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable" />
<!-- Params from config.xml that can be overlayed -->
<!-- Params from strings.xml that can be overlayed -->