diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-02-14 01:58:29 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-02-14 01:58:29 +0000 |
commit | 2171d5f65d932602b632aaf010af9fa6830f1f38 (patch) | |
tree | 8090634e7348c6ab506c96ce8501338ec1061ece /service | |
parent | 2cafabed0ac47dcade78c12564a2111d446f161d (diff) | |
parent | 19e37aaefce354e74191f2df42ff50b59010ff4a (diff) |
Merge "[Passpoint] Optimize loops that iterate on Providers"
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/PasspointManager.java | 15 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java index 755a9b3a9..02c691cce 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java @@ -67,6 +67,7 @@ import com.android.server.wifi.util.TelephonyUtil; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -1010,9 +1011,12 @@ public class PasspointManager { * @return List of {@link WifiConfiguration} converted from {@link PasspointProvider} */ public List<WifiConfiguration> getWifiConfigsForPasspointProfiles(List<String> idList) { + if (mProviders.isEmpty()) { + return Collections.emptyList(); + } + List<WifiConfiguration> configs = new ArrayList<>(); Set<String> uniqueIdSet = new HashSet<>(); uniqueIdSet.addAll(idList); - List<WifiConfiguration> configs = new ArrayList<>(); for (String uniqueId : uniqueIdSet) { PasspointProvider provider = mProviders.get(uniqueId); if (provider == null) { @@ -1192,4 +1196,13 @@ public class PasspointManager { return filteredScanResults; } + + /** + * Check if the providers list is empty + * + * @return true if the providers list is empty, false otherwise + */ + public boolean isProvidersListEmpty() { + return mProviders.isEmpty(); + } } diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java index 0fadd3c84..e319c0014 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java @@ -32,6 +32,7 @@ import com.android.server.wifi.hotspot2.anqp.HSWanMetricsElement; import com.android.server.wifi.util.ScanResultUtil; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -135,6 +136,9 @@ public class PasspointNetworkNominateHelper { */ private @NonNull List<Pair<ScanDetail, WifiConfiguration>> findBestMatchScanDetailForProviders( List<ScanDetail> scanDetails, boolean isFromSuggestion) { + if (mPasspointManager.isProvidersListEmpty()) { + return Collections.emptyList(); + } List<Pair<ScanDetail, WifiConfiguration>> results = new ArrayList<>(); Map<PasspointProvider, List<PasspointNetworkCandidate>> candidatesPerProvider = new HashMap<>(); |