summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-03-27 17:27:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-27 17:27:19 +0000
commite79a776da684e2ab3e5165bb442f432c2ced540b (patch)
treed692c018f4441913f41746afdd3665de426cbe5e /service
parentf22ecebd1e09c8b7a3fdf7c694ed2b43faebaa20 (diff)
parent060438fd2b162bf91a296013ce8ca91006728219 (diff)
Merge "Add or Remove WifiNetworkSuggestion with null should fail." into rvc-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java29
1 files changed, 24 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index c82539bce..d5d4e1297 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -800,15 +800,15 @@ public class WifiNetworkSuggestionsManager {
public @WifiManager.NetworkSuggestionsStatusCode int add(
List<WifiNetworkSuggestion> networkSuggestions, int uid, String packageName,
@Nullable String featureId) {
- if (mVerboseLoggingEnabled) {
- Log.v(TAG, "Adding " + networkSuggestions.size() + " networks from " + packageName);
- }
- if (networkSuggestions.isEmpty()) {
+ if (networkSuggestions == null || networkSuggestions.isEmpty()) {
Log.w(TAG, "Empty list of network suggestions for " + packageName + ". Ignoring");
return WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS;
}
+ if (mVerboseLoggingEnabled) {
+ Log.v(TAG, "Adding " + networkSuggestions.size() + " networks from " + packageName);
+ }
if (!validateNetworkSuggestions(networkSuggestions)) {
- Log.e(TAG, "Invalid suggestion from app: " + packageName);
+ Log.e(TAG, "Invalid suggestion add from app: " + packageName);
return WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID;
}
if (!validateCarrierNetworkSuggestions(networkSuggestions, uid, packageName)) {
@@ -928,6 +928,9 @@ public class WifiNetworkSuggestionsManager {
private boolean validateNetworkSuggestions(List<WifiNetworkSuggestion> networkSuggestions) {
for (WifiNetworkSuggestion wns : networkSuggestions) {
+ if (wns == null || wns.wifiConfiguration == null) {
+ return false;
+ }
if (wns.passpointConfiguration == null) {
if (!WifiConfigurationUtil.validate(wns.wifiConfiguration,
WifiConfigurationUtil.VALIDATE_FOR_ADD)) {
@@ -1037,9 +1040,18 @@ public class WifiNetworkSuggestionsManager {
*/
public @WifiManager.NetworkSuggestionsStatusCode int remove(
List<WifiNetworkSuggestion> networkSuggestions, int uid, String packageName) {
+ if (networkSuggestions == null) {
+ Log.w(TAG, "Null list of network suggestions for " + packageName + ". Ignoring");
+ return WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS;
+ }
if (mVerboseLoggingEnabled) {
Log.v(TAG, "Removing " + networkSuggestions.size() + " networks from " + packageName);
}
+
+ if (!validateNetworkSuggestions(networkSuggestions)) {
+ Log.e(TAG, "Invalid suggestion remove from app: " + packageName);
+ return WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID;
+ }
PerAppInfo perAppInfo = mActiveNetworkSuggestionsPerApp.get(packageName);
if (perAppInfo == null) {
Log.e(TAG, "Failed to remove network suggestions for " + packageName
@@ -2031,7 +2043,14 @@ public class WifiNetworkSuggestionsManager {
@NonNull List<WifiNetworkSuggestion> wifiNetworkSuggestions,
@NonNull List<ScanResult> scanResults) {
Map<WifiNetworkSuggestion, List<ScanResult>> filteredScanResults = new HashMap<>();
+ if (wifiNetworkSuggestions == null || wifiNetworkSuggestions.isEmpty()
+ || scanResults == null || scanResults.isEmpty()) {
+ return filteredScanResults;
+ }
for (WifiNetworkSuggestion suggestion : wifiNetworkSuggestions) {
+ if (suggestion == null || suggestion.wifiConfiguration == null) {
+ continue;
+ }
if (suggestion.passpointConfiguration != null) {
filteredScanResults.put(suggestion,
mWifiInjector.getPasspointManager().getMatchingScanResults(