summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2017-10-09 10:30:50 -0700
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-02-08 04:11:52 +0000
commitb6c5459293d87b124e0e50d3d4b6cc484b7fa90e (patch)
tree21284e079715795f006c687f86aa53629d7b48c3
parent2293f56db188ccd951f78197eae4ade7af34113f (diff)
downloadandroid_frameworks_opt_net_wifi-b6c5459293d87b124e0e50d3d4b6cc484b7fa90e.tar.gz
android_frameworks_opt_net_wifi-b6c5459293d87b124e0e50d3d4b6cc484b7fa90e.tar.bz2
android_frameworks_opt_net_wifi-b6c5459293d87b124e0e50d3d4b6cc484b7fa90e.zip
[PASSPOINT] Add metrics to determine deployment/avail of Passpoint
Add metrics which will help determine Passpoint availability in the wild. The metrics measure the percentage of time a Passpoint network is visible to user - by collecting historgrams of observations per scan result. (cherry-pick of commit 9831c1a04929d8d2cadbebbc1e6843895653bd4c) Bug: 66951771 Test: unit test Change-Id: I80af113f120515d86b2b6adb3e44ce37e97d5441 Merged-In: I51e05e9a075259544008107810c4489e8111cfcd (cherry picked from commit 72ca252ebfb5d91b13627a5f95b89db7b6adc1e5)
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java103
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java88
2 files changed, 190 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 071b4f883..7254ad485 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -32,10 +32,12 @@ import android.util.Pair;
import android.util.SparseIntArray;
import com.android.server.wifi.aware.WifiAwareMetrics;
+import com.android.server.wifi.hotspot2.ANQPNetworkKey;
import com.android.server.wifi.hotspot2.NetworkDetail;
import com.android.server.wifi.hotspot2.PasspointManager;
import com.android.server.wifi.hotspot2.PasspointMatch;
import com.android.server.wifi.hotspot2.PasspointProvider;
+import com.android.server.wifi.hotspot2.Utils;
import com.android.server.wifi.nano.WifiMetricsProto;
import com.android.server.wifi.nano.WifiMetricsProto.ConnectToNetworkNotificationAndActionCount;
import com.android.server.wifi.nano.WifiMetricsProto.PnoScanMetrics;
@@ -49,9 +51,11 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Calendar;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -84,6 +88,9 @@ public class WifiMetrics {
public static final int MAX_CONNECTABLE_BSSID_NETWORK_BUCKET = 50;
public static final int MAX_TOTAL_SCAN_RESULT_SSIDS_BUCKET = 100;
public static final int MAX_TOTAL_SCAN_RESULTS_BUCKET = 250;
+ public static final int MAX_TOTAL_PASSPOINT_APS_BUCKET = 50;
+ public static final int MAX_TOTAL_PASSPOINT_UNIQUE_ESS_BUCKET = 20;
+ public static final int MAX_PASSPOINT_APS_PER_UNIQUE_ESS_BUCKET = 50;
private static final int CONNECT_TO_NETWORK_NOTIFICATION_ACTION_KEY_MULTIPLIER = 1000;
private Clock mClock;
private boolean mScreenOn;
@@ -161,6 +168,13 @@ public class WifiMetrics {
private int mNumOpenNetworkConnectMessageFailedToSend = 0;
private int mNumOpenNetworkRecommendationUpdates = 0;
+ private final SparseIntArray mObservedHotspotR1ApInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mObservedHotspotR2ApInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mObservedHotspotR1EssInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mObservedHotspotR2EssInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mObservedHotspotR1ApsPerEssInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mObservedHotspotR2ApsPerEssInScanHistogram = new SparseIntArray();
+
class RouterFingerPrint {
private WifiMetricsProto.RouterFingerPrint mRouterFingerPrintProto;
RouterFingerPrint() {
@@ -1192,6 +1206,10 @@ public class WifiMetrics {
Set<PasspointProvider> savedPasspointProviderProfiles =
new HashSet<PasspointProvider>();
int savedPasspointProviderBssids = 0;
+ int passpointR1Aps = 0;
+ int passpointR2Aps = 0;
+ Map<ANQPNetworkKey, Integer> passpointR1UniqueEss = new HashMap<>();
+ Map<ANQPNetworkKey, Integer> passpointR2UniqueEss = new HashMap<>();
for (ScanDetail scanDetail : scanDetails) {
NetworkDetail networkDetail = scanDetail.getNetworkDetail();
ScanResult scanResult = scanDetail.getScanResult();
@@ -1205,6 +1223,36 @@ public class WifiMetrics {
providerMatch =
mPasspointManager.matchProvider(scanResult);
passpointProvider = providerMatch != null ? providerMatch.first : null;
+
+ if (networkDetail.getHSRelease() == NetworkDetail.HSRelease.R1) {
+ passpointR1Aps++;
+ } else if (networkDetail.getHSRelease() == NetworkDetail.HSRelease.R2) {
+ passpointR2Aps++;
+ }
+
+ long bssid = 0;
+ boolean validBssid = false;
+ try {
+ bssid = Utils.parseMac(scanResult.BSSID);
+ validBssid = true;
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG,
+ "Invalid BSSID provided in the scan result: " + scanResult.BSSID);
+ }
+ if (validBssid) {
+ ANQPNetworkKey uniqueEss = ANQPNetworkKey.buildKey(scanResult.SSID, bssid,
+ scanResult.hessid, networkDetail.getAnqpDomainID());
+ if (networkDetail.getHSRelease() == NetworkDetail.HSRelease.R1) {
+ Integer countObj = passpointR1UniqueEss.get(uniqueEss);
+ int count = countObj == null ? 0 : countObj;
+ passpointR1UniqueEss.put(uniqueEss, count + 1);
+ } else if (networkDetail.getHSRelease() == NetworkDetail.HSRelease.R2) {
+ Integer countObj = passpointR2UniqueEss.get(uniqueEss);
+ int count = countObj == null ? 0 : countObj;
+ passpointR2UniqueEss.put(uniqueEss, count + 1);
+ }
+ }
+
}
ssids.add(matchInfo);
bssids++;
@@ -1245,6 +1293,18 @@ public class WifiMetrics {
savedPasspointProviderProfiles.size());
incrementBssid(mAvailableSavedPasspointProviderBssidsInScanHistogram,
savedPasspointProviderBssids);
+ incrementTotalPasspointAps(mObservedHotspotR1ApInScanHistogram, passpointR1Aps);
+ incrementTotalPasspointAps(mObservedHotspotR2ApInScanHistogram, passpointR2Aps);
+ incrementTotalUniquePasspointEss(mObservedHotspotR1EssInScanHistogram,
+ passpointR1UniqueEss.size());
+ incrementTotalUniquePasspointEss(mObservedHotspotR2EssInScanHistogram,
+ passpointR2UniqueEss.size());
+ for (Integer count : passpointR1UniqueEss.values()) {
+ incrementPasspointPerUniqueEss(mObservedHotspotR1ApsPerEssInScanHistogram, count);
+ }
+ for (Integer count : passpointR2UniqueEss.values()) {
+ incrementPasspointPerUniqueEss(mObservedHotspotR2ApsPerEssInScanHistogram, count);
+ }
}
}
@@ -1561,6 +1621,19 @@ public class WifiMetrics {
+ mNumOpenNetworkRecommendationUpdates);
pw.println("mWifiLogProto.numOpenNetworkConnectMessageFailedToSend="
+ mNumOpenNetworkConnectMessageFailedToSend);
+
+ pw.println("mWifiLogProto.observedHotspotR1ApInScanHistogram="
+ + mObservedHotspotR1ApInScanHistogram);
+ pw.println("mWifiLogProto.observedHotspotR2ApInScanHistogram="
+ + mObservedHotspotR2ApInScanHistogram);
+ pw.println("mWifiLogProto.observedHotspotR1EssInScanHistogram="
+ + mObservedHotspotR1EssInScanHistogram);
+ pw.println("mWifiLogProto.observedHotspotR2EssInScanHistogram="
+ + mObservedHotspotR2EssInScanHistogram);
+ pw.println("mWifiLogProto.observedHotspotR1ApsPerEssInScanHistogram="
+ + mObservedHotspotR1ApsPerEssInScanHistogram);
+ pw.println("mWifiLogProto.observedHotspotR2ApsPerEssInScanHistogram="
+ + mObservedHotspotR2ApsPerEssInScanHistogram);
}
}
}
@@ -1818,6 +1891,21 @@ public class WifiMetrics {
mNumOpenNetworkRecommendationUpdates;
mWifiLogProto.numOpenNetworkConnectMessageFailedToSend =
mNumOpenNetworkConnectMessageFailedToSend;
+
+ mWifiLogProto.observedHotspotR1ApsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mObservedHotspotR1ApInScanHistogram);
+ mWifiLogProto.observedHotspotR2ApsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mObservedHotspotR2ApInScanHistogram);
+ mWifiLogProto.observedHotspotR1EssInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mObservedHotspotR1EssInScanHistogram);
+ mWifiLogProto.observedHotspotR2EssInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mObservedHotspotR2EssInScanHistogram);
+ mWifiLogProto.observedHotspotR1ApsPerEssInScanHistogram =
+ makeNumConnectableNetworksBucketArray(
+ mObservedHotspotR1ApsPerEssInScanHistogram);
+ mWifiLogProto.observedHotspotR2ApsPerEssInScanHistogram =
+ makeNumConnectableNetworksBucketArray(
+ mObservedHotspotR2ApsPerEssInScanHistogram);
}
}
@@ -1872,6 +1960,12 @@ public class WifiMetrics {
mConnectToNetworkNotificationActionCount.clear();
mNumOpenNetworkRecommendationUpdates = 0;
mNumOpenNetworkConnectMessageFailedToSend = 0;
+ mObservedHotspotR1ApInScanHistogram.clear();
+ mObservedHotspotR2ApInScanHistogram.clear();
+ mObservedHotspotR1EssInScanHistogram.clear();
+ mObservedHotspotR2EssInScanHistogram.clear();
+ mObservedHotspotR1ApsPerEssInScanHistogram.clear();
+ mObservedHotspotR2ApsPerEssInScanHistogram.clear();
}
}
@@ -2272,6 +2366,15 @@ public class WifiMetrics {
private void incrementTotalScanSsids(SparseIntArray sia, int element) {
increment(sia, Math.min(element, MAX_TOTAL_SCAN_RESULT_SSIDS_BUCKET));
}
+ private void incrementTotalPasspointAps(SparseIntArray sia, int element) {
+ increment(sia, Math.min(element, MAX_TOTAL_PASSPOINT_APS_BUCKET));
+ }
+ private void incrementTotalUniquePasspointEss(SparseIntArray sia, int element) {
+ increment(sia, Math.min(element, MAX_TOTAL_PASSPOINT_UNIQUE_ESS_BUCKET));
+ }
+ private void incrementPasspointPerUniqueEss(SparseIntArray sia, int element) {
+ increment(sia, Math.min(element, MAX_PASSPOINT_APS_PER_UNIQUE_ESS_BUCKET));
+ }
private void increment(SparseIntArray sia, int element) {
int count = sia.get(element);
sia.put(element, count + 1);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 65427beb2..6e0b7759c 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -18,7 +18,9 @@ package com.android.server.wifi;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import android.net.NetworkAgent;
import android.net.wifi.ScanResult;
@@ -311,6 +313,23 @@ public class WifiMetricsTest {
return mockScanDetail;
}
+ private ScanDetail buildMockScanDetailPasspoint(String ssid, String bssid, long hessid,
+ int anqpDomainId, NetworkDetail.HSRelease hsRelease) {
+ ScanDetail mockScanDetail = mock(ScanDetail.class);
+ NetworkDetail mockNetworkDetail = mock(NetworkDetail.class);
+ ScanResult scanResult = new ScanResult();
+ scanResult.SSID = ssid;
+ scanResult.BSSID = bssid;
+ scanResult.hessid = hessid;
+ scanResult.capabilities = "PSK";
+ when(mockScanDetail.getNetworkDetail()).thenReturn(mockNetworkDetail);
+ when(mockScanDetail.getScanResult()).thenReturn(scanResult);
+ when(mockNetworkDetail.getHSRelease()).thenReturn(hsRelease);
+ when(mockNetworkDetail.getAnqpDomainID()).thenReturn(anqpDomainId);
+ when(mockNetworkDetail.isInterworking()).thenReturn(true);
+ return mockScanDetail;
+ }
+
private List<ScanDetail> buildMockScanDetailList() {
List<ScanDetail> mockScanDetails = new ArrayList<ScanDetail>();
mockScanDetails.add(buildMockScanDetail(true, null, "[ESS]"));
@@ -1271,6 +1290,73 @@ public class WifiMetricsTest {
}
/**
+ * Test that Hotspot 2.0 (Passpoint) scan results are collected correctly and that relevant
+ * bounds are observed.
+ */
+ @Test
+ public void testObservedHotspotAps() throws Exception {
+ List<ScanDetail> scan = new ArrayList<ScanDetail>();
+ // 2 R1 (Unknown AP isn't counted) passpoint APs belonging to a single provider: hessid1
+ long hessid1 = 10;
+ int anqpDomainId1 = 5;
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_XX", "00:02:03:04:05:06", hessid1,
+ anqpDomainId1, NetworkDetail.HSRelease.R1));
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_XY", "01:02:03:04:05:06", hessid1,
+ anqpDomainId1, NetworkDetail.HSRelease.R1));
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_XYZ", "02:02:03:04:05:06", hessid1,
+ anqpDomainId1, NetworkDetail.HSRelease.Unknown));
+ // 2 R2 passpoint APs belonging to a single provider: hessid2
+ long hessid2 = 12;
+ int anqpDomainId2 = 6;
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_Y", "AA:02:03:04:05:06", hessid2,
+ anqpDomainId2, NetworkDetail.HSRelease.R2));
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_Z", "AB:02:03:04:05:06", hessid2,
+ anqpDomainId2, NetworkDetail.HSRelease.R2));
+ mWifiMetrics.incrementAvailableNetworksHistograms(scan, true);
+ scan = new ArrayList<ScanDetail>();
+ // 3 R2 passpoint APs belonging to a single provider: hessid3 (in next scan)
+ long hessid3 = 15;
+ int anqpDomainId3 = 8;
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_Y", "AA:02:03:04:05:06", hessid3,
+ anqpDomainId3, NetworkDetail.HSRelease.R2));
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_Y", "AA:02:03:04:05:06", hessid3,
+ anqpDomainId3, NetworkDetail.HSRelease.R2));
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_Z", "AB:02:03:04:05:06", hessid3,
+ anqpDomainId3, NetworkDetail.HSRelease.R2));
+ mWifiMetrics.incrementAvailableNetworksHistograms(scan, true);
+ dumpProtoAndDeserialize();
+
+ verifyHist(mDecodedProto.observedHotspotR1ApsInScanHistogram, 2, a(0, 2), a(1, 1));
+ verifyHist(mDecodedProto.observedHotspotR2ApsInScanHistogram, 2, a(2, 3), a(1, 1));
+ verifyHist(mDecodedProto.observedHotspotR1EssInScanHistogram, 2, a(0, 1), a(1, 1));
+ verifyHist(mDecodedProto.observedHotspotR2EssInScanHistogram, 1, a(1), a(2));
+ verifyHist(mDecodedProto.observedHotspotR1ApsPerEssInScanHistogram, 1, a(2), a(1));
+ verifyHist(mDecodedProto.observedHotspotR2ApsPerEssInScanHistogram, 2, a(2, 3), a(1, 1));
+
+ // check bounds
+ scan.clear();
+ int lotsOfSSids = Math.max(WifiMetrics.MAX_TOTAL_PASSPOINT_APS_BUCKET,
+ WifiMetrics.MAX_TOTAL_PASSPOINT_UNIQUE_ESS_BUCKET) + 5;
+ for (int i = 0; i < lotsOfSSids; i++) {
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_XX" + i, "00:02:03:04:05:06", i,
+ i + 10, NetworkDetail.HSRelease.R1));
+ scan.add(buildMockScanDetailPasspoint("PASSPOINT_XY" + i, "AA:02:03:04:05:06", 1000 * i,
+ i + 10, NetworkDetail.HSRelease.R2));
+ }
+ mWifiMetrics.incrementAvailableNetworksHistograms(scan, true);
+ dumpProtoAndDeserialize();
+ verifyHist(mDecodedProto.observedHotspotR1ApsInScanHistogram, 1,
+ a(WifiMetrics.MAX_TOTAL_PASSPOINT_APS_BUCKET), a(1));
+ verifyHist(mDecodedProto.observedHotspotR2ApsInScanHistogram, 1,
+ a(WifiMetrics.MAX_TOTAL_PASSPOINT_APS_BUCKET), a(1));
+ verifyHist(mDecodedProto.observedHotspotR1EssInScanHistogram, 1,
+ a(WifiMetrics.MAX_TOTAL_PASSPOINT_UNIQUE_ESS_BUCKET), a(1));
+ verifyHist(mDecodedProto.observedHotspotR2EssInScanHistogram, 1,
+ a(WifiMetrics.MAX_TOTAL_PASSPOINT_UNIQUE_ESS_BUCKET), a(1));
+
+ }
+
+ /**
* Test Open Network Notification blacklist size and feature state are not cleared when proto
* is dumped.
*/