summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHai Shalom <haishalom@google.com>2020-02-13 15:43:43 -0800
committerHai Shalom <haishalom@google.com>2020-02-13 16:47:12 -0800
commit19e37aaefce354e74191f2df42ff50b59010ff4a (patch)
tree6ef1147d9a848236fdbfff1fae5d446058e8edc3
parentd001198b09b648457c180627fc53696686456d3b (diff)
[Passpoint] Optimize loops that iterate on Providers
Optimize getWifiConfigsForPasspointProfiles, and findBestMatchScanDetailForProviders: skip search loop if the map of providers is empty. Bug: 149517632 Test: atest PasspointManagerTest Test: atest PasspointNetworkNominateHelperTest Change-Id: I799483cf38b8df131514285855c97fc531e6eecd
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java15
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java4
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<>();