summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorGlen Kuhne <kuh@google.com>2017-07-24 17:16:06 -0700
committerGlen Kuhne <kuh@google.com>2017-08-08 20:24:24 +0000
commit08631913ff641047b1d56288bd194a1fa7c390e1 (patch)
tree298c1b7c9c2220c8a572fa9e3a7a3d3c22b9a10b /service
parentd493cd415eaf76851f17e186b9066e89340d9a2f (diff)
METRICS: histograms of scanresult sums in scan
Generate histograms counting the size of 5 different ScanResults subsets within a scan. Subsets include: total, open, saved, open-or-saved, or passpoint related scan results. The size is counted for unique BSSIDs & unique SSIDS, generating two histograms. This metric is useful for determining the frequency of N-way network-selection decisions (where N is the number of connectable networks). Exempt-From-Owner-Approval: Prior approval by owners (rpius) Bug: 36819798 Test: Added unit test frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: I4825a778d45f9306f3e83b2418a047b8809c1802
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiConnectivityManager.java5
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java3
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java221
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSelector.java13
5 files changed, 234 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 8d37746e9..d8b4237a3 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -1938,7 +1938,7 @@ public class WifiConfigManager {
* @return WifiConfiguration object representing the network corresponding to the scanDetail,
* null if none exists.
*/
- private WifiConfiguration getConfiguredNetworkForScanDetail(ScanDetail scanDetail) {
+ public WifiConfiguration getConfiguredNetworkForScanDetail(ScanDetail scanDetail) {
ScanResult scanResult = scanDetail.getScanResult();
if (scanResult == null) {
Log.e(TAG, "No scan result found in scan detail");
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java
index 4a729e0c5..344242a14 100644
--- a/service/java/com/android/server/wifi/WifiConnectivityManager.java
+++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java
@@ -321,7 +321,10 @@ public class WifiConnectivityManager {
mWaitForFullBandScanResults = false;
}
}
-
+ if (results.length > 0) {
+ mWifiMetrics.incrementAvailableNetworksHistograms(mScanDetails,
+ results[0].isAllChannelsScanned());
+ }
boolean wasConnectAttempted = handleScanResults(mScanDetails, "AllSingleScanListener");
clearScanDetails();
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index f7d2e3096..80daaeaa1 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -205,10 +205,12 @@ public class WifiInjector {
mWifiKeyStore, mWifiConfigStore, mWifiConfigStoreLegacy, mWifiPermissionsUtil,
mWifiPermissionsWrapper, new NetworkListStoreData(),
new DeletedEphemeralSsidsStoreData());
+ mWifiMetrics.setWifiConfigManager(mWifiConfigManager);
mWifiConnectivityHelper = new WifiConnectivityHelper(mWifiNative);
mConnectivityLocalLog = new LocalLog(ActivityManager.isLowRamDeviceStatic() ? 256 : 512);
mWifiNetworkSelector = new WifiNetworkSelector(mContext, mWifiConfigManager, mClock,
mConnectivityLocalLog);
+ mWifiMetrics.setWifiNetworkSelector(mWifiNetworkSelector);
mSavedNetworkEvaluator = new SavedNetworkEvaluator(mContext,
mWifiConfigManager, mClock, mConnectivityLocalLog, mWifiConnectivityHelper);
mScoredNetworkEvaluator = new ScoredNetworkEvaluator(context, wifiStateMachineLooper,
@@ -220,6 +222,7 @@ public class WifiInjector {
mWifiMetrics);
mPasspointNetworkEvaluator = new PasspointNetworkEvaluator(
mPasspointManager, mWifiConfigManager, mConnectivityLocalLog);
+ mWifiMetrics.setPasspointManager(mPasspointManager);
// mWifiStateMachine has an implicit dependency on mJavaRuntime due to WifiDiagnostics.
mJavaRuntime = Runtime.getRuntime();
mWifiStateMachine = new WifiStateMachine(mContext, mFrameworkFacade,
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index d317f8386..7dfdb86d3 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -28,10 +28,14 @@ import android.os.Looper;
import android.os.Message;
import android.util.Base64;
import android.util.Log;
+import android.util.Pair;
import android.util.SparseIntArray;
import com.android.server.wifi.aware.WifiAwareMetrics;
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.nano.WifiMetricsProto;
import com.android.server.wifi.nano.WifiMetricsProto.StaEvent;
import com.android.server.wifi.nano.WifiMetricsProto.StaEvent.ConfigInfo;
@@ -43,8 +47,10 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Calendar;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
/**
* Provides storage for wireless connectivity metrics, as they are generated.
@@ -70,11 +76,20 @@ public class WifiMetrics {
private static final int MAX_WIFI_SCORE = NetworkAgent.WIFI_BASE_SCORE;
private final Object mLock = new Object();
private static final int MAX_CONNECTION_EVENTS = 256;
+ // Largest bucket in the NumConnectableNetworkCount histogram,
+ // anything large will be stored in this bucket
+ public static final int MAX_CONNECTABLE_SSID_NETWORK_BUCKET = 20;
+ 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;
private Clock mClock;
private boolean mScreenOn;
private int mWifiState;
private WifiAwareMetrics mWifiAwareMetrics;
private Handler mHandler;
+ private WifiConfigManager mWifiConfigManager;
+ private WifiNetworkSelector mWifiNetworkSelector;
+ private PasspointManager mPasspointManager;
/**
* Metrics are stored within an instance of the WifiLog proto during runtime,
* The ConnectionEvent, SystemStateEntries & ScanReturnEntries metrics are stored during
@@ -119,6 +134,20 @@ public class WifiMetrics {
private final SparseIntArray mWifiScoreCounts = new SparseIntArray();
/** Mapping of SoftApManager start SoftAp return codes to counts */
private final SparseIntArray mSoftApManagerReturnCodeCounts = new SparseIntArray();
+
+ private final SparseIntArray mTotalSsidsInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mTotalBssidsInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mAvailableOpenSsidsInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mAvailableOpenBssidsInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mAvailableSavedSsidsInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mAvailableSavedBssidsInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mAvailableOpenOrSavedSsidsInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mAvailableOpenOrSavedBssidsInScanHistogram = new SparseIntArray();
+ private final SparseIntArray mAvailableSavedPasspointProviderProfilesInScanHistogram =
+ new SparseIntArray();
+ private final SparseIntArray mAvailableSavedPasspointProviderBssidsInScanHistogram =
+ new SparseIntArray();
+
class RouterFingerPrint {
private WifiMetricsProto.RouterFingerPrint mRouterFingerPrintProto;
RouterFingerPrint() {
@@ -363,6 +392,21 @@ public class WifiMetrics {
};
}
+ /** Sets internal WifiConfigManager member */
+ public void setWifiConfigManager(WifiConfigManager wifiConfigManager) {
+ mWifiConfigManager = wifiConfigManager;
+ }
+
+ /** Sets internal WifiNetworkSelector member */
+ public void setWifiNetworkSelector(WifiNetworkSelector wifiNetworkSelector) {
+ mWifiNetworkSelector = wifiNetworkSelector;
+ }
+
+ /** Sets internal PasspointManager member */
+ public void setPasspointManager(PasspointManager passpointManager) {
+ mPasspointManager = passpointManager;
+ }
+
// Values used for indexing SystemStateEntries
private static final int SCREEN_ON = 1;
private static final int SCREEN_OFF = 0;
@@ -1061,6 +1105,91 @@ public class WifiMetrics {
}
}
+ /**
+ * Increment N-Way network selection decision histograms:
+ * Counts the size of various sets of scanDetails within a scan, and increment the occurrence
+ * of that size for the associated histogram. There are ten histograms generated for each
+ * combination of: {SSID, BSSID} *{Total, Saved, Open, Saved_or_Open, Passpoint}
+ * Only performs this count if isFullBand is true, otherwise, increments the partial scan count
+ */
+ public void incrementAvailableNetworksHistograms(List<ScanDetail> scanDetails,
+ boolean isFullBand) {
+ synchronized (mLock) {
+ if (mWifiConfigManager == null || mWifiNetworkSelector == null
+ || mPasspointManager == null) {
+ return;
+ }
+ if (!isFullBand) {
+ mWifiLogProto.partialAllSingleScanListenerResults++;
+ return;
+ }
+ Set<ScanResultMatchInfo> ssids = new HashSet<ScanResultMatchInfo>();
+ int bssids = 0;
+ Set<ScanResultMatchInfo> openSsids = new HashSet<ScanResultMatchInfo>();
+ int openBssids = 0;
+ Set<ScanResultMatchInfo> savedSsids = new HashSet<ScanResultMatchInfo>();
+ int savedBssids = 0;
+ // openOrSavedSsids calculated from union of savedSsids & openSsids
+ int openOrSavedBssids = 0;
+ Set<PasspointProvider> savedPasspointProviderProfiles =
+ new HashSet<PasspointProvider>();
+ int savedPasspointProviderBssids = 0;
+ for (ScanDetail scanDetail : scanDetails) {
+ NetworkDetail networkDetail = scanDetail.getNetworkDetail();
+ ScanResult scanResult = scanDetail.getScanResult();
+ if (mWifiNetworkSelector.isSignalTooWeak(scanResult)) {
+ continue;
+ }
+ ScanResultMatchInfo matchInfo = ScanResultMatchInfo.fromScanResult(scanResult);
+ Pair<PasspointProvider, PasspointMatch> providerMatch = null;
+ PasspointProvider passpointProvider = null;
+ if (networkDetail.isInterworking()) {
+ providerMatch =
+ mPasspointManager.matchProvider(scanResult);
+ passpointProvider = providerMatch != null ? providerMatch.first : null;
+ }
+ ssids.add(matchInfo);
+ bssids++;
+ boolean isOpen = matchInfo.networkType == ScanResultMatchInfo.NETWORK_TYPE_OPEN;
+ WifiConfiguration config =
+ mWifiConfigManager.getConfiguredNetworkForScanDetail(scanDetail);
+ boolean isSaved = (config != null) && !config.isEphemeral()
+ && !config.isPasspoint();
+ boolean isSavedPasspoint = passpointProvider != null;
+ if (isOpen) {
+ openSsids.add(matchInfo);
+ openBssids++;
+ }
+ if (isSaved) {
+ savedSsids.add(matchInfo);
+ savedBssids++;
+ }
+ if (isOpen || isSaved) {
+ openOrSavedBssids++;
+ // Calculate openOrSavedSsids union later
+ }
+ if (isSavedPasspoint) {
+ savedPasspointProviderProfiles.add(passpointProvider);
+ savedPasspointProviderBssids++;
+ }
+ }
+ mWifiLogProto.fullBandAllSingleScanListenerResults++;
+ incrementTotalScanSsids(mTotalSsidsInScanHistogram, ssids.size());
+ incrementTotalScanResults(mTotalBssidsInScanHistogram, bssids);
+ incrementSsid(mAvailableOpenSsidsInScanHistogram, openSsids.size());
+ incrementBssid(mAvailableOpenBssidsInScanHistogram, openBssids);
+ incrementSsid(mAvailableSavedSsidsInScanHistogram, savedSsids.size());
+ incrementBssid(mAvailableSavedBssidsInScanHistogram, savedBssids);
+ openSsids.addAll(savedSsids); // openSsids = Union(openSsids, savedSsids)
+ incrementSsid(mAvailableOpenOrSavedSsidsInScanHistogram, openSsids.size());
+ incrementBssid(mAvailableOpenOrSavedBssidsInScanHistogram, openOrSavedBssids);
+ incrementSsid(mAvailableSavedPasspointProviderProfilesInScanHistogram,
+ savedPasspointProviderProfiles.size());
+ incrementBssid(mAvailableSavedPasspointProviderBssidsInScanHistogram,
+ savedPasspointProviderBssids);
+ }
+ }
+
public static final String PROTO_DUMP_ARG = "wifiMetricsProto";
public static final String CLEAN_DUMP_ARG = "clean";
@@ -1275,14 +1404,36 @@ public class WifiMetrics {
+ mWifiLogProto.numPasspointProviderUninstallSuccess);
pw.println("mWifiLogProto.numPasspointProvidersSuccessfullyConnected="
+ mWifiLogProto.numPasspointProvidersSuccessfullyConnected);
-
+ pw.println("mTotalSsidsInScanHistogram:"
+ + mTotalSsidsInScanHistogram.toString());
+ pw.println("mTotalBssidsInScanHistogram:"
+ + mTotalBssidsInScanHistogram.toString());
+ pw.println("mAvailableOpenSsidsInScanHistogram:"
+ + mAvailableOpenSsidsInScanHistogram.toString());
+ pw.println("mAvailableOpenBssidsInScanHistogram:"
+ + mAvailableOpenBssidsInScanHistogram.toString());
+ pw.println("mAvailableSavedSsidsInScanHistogram:"
+ + mAvailableSavedSsidsInScanHistogram.toString());
+ pw.println("mAvailableSavedBssidsInScanHistogram:"
+ + mAvailableSavedBssidsInScanHistogram.toString());
+ pw.println("mAvailableOpenOrSavedSsidsInScanHistogram:"
+ + mAvailableOpenOrSavedSsidsInScanHistogram.toString());
+ pw.println("mAvailableOpenOrSavedBssidsInScanHistogram:"
+ + mAvailableOpenOrSavedBssidsInScanHistogram.toString());
+ pw.println("mAvailableSavedPasspointProviderProfilesInScanHistogram:"
+ + mAvailableSavedPasspointProviderProfilesInScanHistogram.toString());
+ pw.println("mAvailableSavedPasspointProviderBssidsInScanHistogram:"
+ + mAvailableSavedPasspointProviderBssidsInScanHistogram.toString());
+ pw.println("mWifiLogProto.partialAllSingleScanListenerResults="
+ + mWifiLogProto.partialAllSingleScanListenerResults);
+ pw.println("mWifiLogProto.fullBandAllSingleScanListenerResults="
+ + mWifiLogProto.fullBandAllSingleScanListenerResults);
pw.println("mWifiAwareMetrics:");
mWifiAwareMetrics.dump(fd, pw, args);
}
}
}
-
/**
* Update various counts of saved network types
* @param networks List of WifiConfigurations representing all saved networks, must not be null
@@ -1454,13 +1605,49 @@ public class WifiMetrics {
mWifiLogProto.softApReturnCode[sapCode].count =
mSoftApManagerReturnCodeCounts.valueAt(sapCode);
}
-
+ mWifiLogProto.totalSsidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mTotalSsidsInScanHistogram);
+ mWifiLogProto.totalBssidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mTotalBssidsInScanHistogram);
+ mWifiLogProto.availableOpenSsidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mAvailableOpenSsidsInScanHistogram);
+ mWifiLogProto.availableOpenBssidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mAvailableOpenBssidsInScanHistogram);
+ mWifiLogProto.availableSavedSsidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mAvailableSavedSsidsInScanHistogram);
+ mWifiLogProto.availableSavedBssidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(mAvailableSavedBssidsInScanHistogram);
+ mWifiLogProto.availableOpenOrSavedSsidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(
+ mAvailableOpenOrSavedSsidsInScanHistogram);
+ mWifiLogProto.availableOpenOrSavedBssidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(
+ mAvailableOpenOrSavedBssidsInScanHistogram);
+ mWifiLogProto.availableSavedPasspointProviderProfilesInScanHistogram =
+ makeNumConnectableNetworksBucketArray(
+ mAvailableSavedPasspointProviderProfilesInScanHistogram);
+ mWifiLogProto.availableSavedPasspointProviderBssidsInScanHistogram =
+ makeNumConnectableNetworksBucketArray(
+ mAvailableSavedPasspointProviderBssidsInScanHistogram);
mWifiLogProto.staEventList = mStaEventList.toArray(mWifiLogProto.staEventList);
-
mWifiLogProto.wifiAwareLog = mWifiAwareMetrics.consolidateProto();
}
}
+ private WifiMetricsProto.NumConnectableNetworksBucket[] makeNumConnectableNetworksBucketArray(
+ SparseIntArray sia) {
+ WifiMetricsProto.NumConnectableNetworksBucket[] array =
+ new WifiMetricsProto.NumConnectableNetworksBucket[sia.size()];
+ for (int i = 0; i < sia.size(); i++) {
+ WifiMetricsProto.NumConnectableNetworksBucket keyVal =
+ new WifiMetricsProto.NumConnectableNetworksBucket();
+ keyVal.numConnectableNetworks = sia.keyAt(i);
+ keyVal.count = sia.valueAt(i);
+ array[i] = keyVal;
+ }
+ return array;
+ }
+
/**
* Clear all WifiMetrics, except for currentConnectionEvent.
*/
@@ -1482,6 +1669,16 @@ public class WifiMetrics {
mSoftApManagerReturnCodeCounts.clear();
mStaEventList.clear();
mWifiAwareMetrics.clear();
+ mTotalSsidsInScanHistogram.clear();
+ mTotalBssidsInScanHistogram.clear();
+ mAvailableOpenSsidsInScanHistogram.clear();
+ mAvailableOpenBssidsInScanHistogram.clear();
+ mAvailableSavedSsidsInScanHistogram.clear();
+ mAvailableSavedBssidsInScanHistogram.clear();
+ mAvailableOpenOrSavedSsidsInScanHistogram.clear();
+ mAvailableOpenOrSavedBssidsInScanHistogram.clear();
+ mAvailableSavedPasspointProviderProfilesInScanHistogram.clear();
+ mAvailableSavedPasspointProviderBssidsInScanHistogram.clear();
}
}
@@ -1872,4 +2069,20 @@ public class WifiMetrics {
}
return value;
}
+ private void incrementSsid(SparseIntArray sia, int element) {
+ increment(sia, Math.min(element, MAX_CONNECTABLE_SSID_NETWORK_BUCKET));
+ }
+ private void incrementBssid(SparseIntArray sia, int element) {
+ increment(sia, Math.min(element, MAX_CONNECTABLE_BSSID_NETWORK_BUCKET));
+ }
+ private void incrementTotalScanResults(SparseIntArray sia, int element) {
+ increment(sia, Math.min(element, MAX_TOTAL_SCAN_RESULTS_BUCKET));
+ }
+ private void incrementTotalScanSsids(SparseIntArray sia, int element) {
+ increment(sia, Math.min(element, MAX_TOTAL_SCAN_RESULT_SSIDS_BUCKET));
+ }
+ private void increment(SparseIntArray sia, int element) {
+ int count = sia.get(element);
+ sia.put(element, count + 1);
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java
index 5e9e4ef01..fe2470535 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSelector.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java
@@ -258,6 +258,14 @@ public class WifiNetworkSelector {
return (network.SSID + ":" + network.networkId);
}
+ /**
+ * Compares ScanResult level against the minimum threshold for its band, returns true if lower
+ */
+ public boolean isSignalTooWeak(ScanResult scanResult) {
+ return ((scanResult.is24GHz() && scanResult.level < mThresholdMinimumRssi24)
+ || (scanResult.is5GHz() && scanResult.level < mThresholdMinimumRssi5));
+ }
+
private List<ScanDetail> filterScanResults(List<ScanDetail> scanDetails,
HashSet<String> bssidBlacklist, boolean isConnected, String currentBssid) {
ArrayList<NetworkKey> unscoredNetworks = new ArrayList<NetworkKey>();
@@ -288,10 +296,7 @@ public class WifiNetworkSelector {
}
// Skip network with too weak signals.
- if ((scanResult.is24GHz() && scanResult.level
- < mThresholdMinimumRssi24)
- || (scanResult.is5GHz() && scanResult.level
- < mThresholdMinimumRssi5)) {
+ if (isSignalTooWeak(scanResult)) {
lowRssi.append(scanId).append("(")
.append(scanResult.is24GHz() ? "2.4GHz" : "5GHz")
.append(")").append(scanResult.level).append(" / ");