summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
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.java111
3 files changed, 116 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..fc1b32d05 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,97 @@ 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 (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) {