summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmed ElArabawy <arabawy@google.com>2020-04-08 15:08:25 -0700
committerAhmed ElArabawy <arabawy@google.com>2020-04-09 18:31:15 -0700
commit427cd448103907a947fb09c26ba3ce93cb4dd40b (patch)
treea61c7ead45d7a73a7e7efe2f4a703ef265685e67
parentb9e042d647ff9f0249151d774db05d1c44c026f9 (diff)
Add metrics for initial partial scan feature
This commit adds the metrics for initial partial scan feature Bug: 153509887 Test: atest com.android.server.wifi Change-Id: I2cbefaa64331ef14c532a48594cebe29d5c3aced
-rw-r--r--service/java/com/android/server/wifi/WifiConnectivityManager.java18
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java65
-rw-r--r--service/proto/src/metrics.proto22
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java47
4 files changed, 151 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java
index 3d2f3c58a..030121efd 100644
--- a/service/java/com/android/server/wifi/WifiConnectivityManager.java
+++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java
@@ -182,6 +182,11 @@ public class WifiConnectivityManager {
private boolean mPnoScanStarted = false;
private boolean mPeriodicScanTimerSet = false;
private boolean mDelayedPartialScanTimerSet = false;
+
+ // Used for Initial Scan metrics
+ private boolean mFailedInitialPartialScan = false;
+ private int mInitialPartialScanChannelCount;
+
// Device configs
private boolean mWaitForFullBandScanResults = false;
@@ -522,10 +527,20 @@ public class WifiConnectivityManager {
Log.i(TAG, "Connection attempted with the reduced initial scans");
schedulePeriodicScanTimer(
getScheduledSingleScanIntervalMs(mCurrentSingleScanScheduleIndex));
+ mWifiMetrics.reportInitialPartialScan(mInitialPartialScanChannelCount, true);
+ mInitialPartialScanChannelCount = 0;
} else {
Log.i(TAG, "Connection was not attempted, issuing a full scan");
startConnectivityScan(SCAN_IMMEDIATELY);
+ mFailedInitialPartialScan = true;
}
+ } else if (mInitialScanState == INITIAL_SCAN_STATE_COMPLETE) {
+ if (mFailedInitialPartialScan && wasConnectAttempted) {
+ // Initial scan failed, but following full scan succeeded
+ mWifiMetrics.reportInitialPartialScan(mInitialPartialScanChannelCount, false);
+ }
+ mFailedInitialPartialScan = false;
+ mInitialPartialScanChannelCount = 0;
}
}
@@ -1135,6 +1150,7 @@ public class WifiConnectivityManager {
// Hence, we verify state before changing to AWIATING_RESPONSE
if (mInitialScanState == INITIAL_SCAN_STATE_START) {
setInitialScanState(INITIAL_SCAN_STATE_AWAITING_RESPONSE);
+ mWifiMetrics.incrementInitialPartialScanCount();
}
// No scheduling for another scan (until we get the results)
return;
@@ -1239,6 +1255,8 @@ public class WifiConnectivityManager {
isFullBandScan = true;
// Skip the initial scan since no channel history available
setInitialScanState(INITIAL_SCAN_STATE_COMPLETE);
+ } else {
+ mInitialPartialScanChannelCount = settings.channels.length;
}
}
settings.type = WifiScanner.SCAN_TYPE_HIGH_ACCURACY; // always do high accuracy scans.
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 3f13e99fc..409293f9c 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -64,6 +64,7 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.ConnectToNetworkNotif
import com.android.server.wifi.proto.nano.WifiMetricsProto.DeviceMobilityStatePnoScanStats;
import com.android.server.wifi.proto.nano.WifiMetricsProto.ExperimentValues;
import com.android.server.wifi.proto.nano.WifiMetricsProto.HealthMonitorMetrics;
+import com.android.server.wifi.proto.nano.WifiMetricsProto.InitPartialScanStats;
import com.android.server.wifi.proto.nano.WifiMetricsProto.LinkProbeStats;
import com.android.server.wifi.proto.nano.WifiMetricsProto.LinkProbeStats.ExperimentProbeCounts;
import com.android.server.wifi.proto.nano.WifiMetricsProto.LinkProbeStats.LinkProbeFailureReasonCount;
@@ -463,6 +464,17 @@ public class WifiMetrics {
private final IntHistogram mRxThroughputMbpsHistogramAbove2G =
new IntHistogram(THROUGHPUT_MBPS_BUCKETS);
+ // Init partial scan metrics
+ private int mInitPartialScanTotalCount;
+ private int mInitPartialScanSuccessCount;
+ private int mInitPartialScanFailureCount;
+ private static final int[] INIT_PARTIAL_SCAN_HISTOGRAM_BUCKETS =
+ {1, 3, 5, 10};
+ private final IntHistogram mInitPartialScanSuccessHistogram =
+ new IntHistogram(INIT_PARTIAL_SCAN_HISTOGRAM_BUCKETS);
+ private final IntHistogram mInitPartialScanFailureHistogram =
+ new IntHistogram(INIT_PARTIAL_SCAN_HISTOGRAM_BUCKETS);
+
// Wi-Fi off metrics
private final WifiOffMetrics mWifiOffMetrics = new WifiOffMetrics();
@@ -3515,10 +3527,20 @@ public class WifiMetrics {
+ mTxThroughputMbpsHistogramAbove2G);
pw.println("mRxThroughputMbpsHistogramAbove2G:\n"
+ mRxThroughputMbpsHistogramAbove2G);
+
+ dumpInitPartialScanMetrics(pw);
}
}
}
+ private void dumpInitPartialScanMetrics(PrintWriter pw) {
+ pw.println("mInitPartialScanTotalCount:\n" + mInitPartialScanTotalCount);
+ pw.println("mInitPartialScanSuccessCount:\n" + mInitPartialScanSuccessCount);
+ pw.println("mInitPartialScanFailureCount:\n" + mInitPartialScanFailureCount);
+ pw.println("mInitPartialScanSuccessHistogram:\n" + mInitPartialScanSuccessHistogram);
+ pw.println("mInitPartialScanFailureHistogram:\n" + mInitPartialScanFailureHistogram);
+ }
+
private void printWifiUsabilityStatsEntry(PrintWriter pw, WifiUsabilityStatsEntry entry) {
StringBuilder line = new StringBuilder();
line.append("timestamp_ms=" + entry.timeStampMs);
@@ -3691,6 +3713,32 @@ public class WifiMetrics {
}
/**
+ * Increment initial partial scan count
+ */
+ public void incrementInitialPartialScanCount() {
+ synchronized (mLock) {
+ mInitPartialScanTotalCount++;
+ }
+ }
+
+ /**
+ * Report of initial partial scan
+ * @param channelCount number of channels used in this scan
+ * @param status true if scan resulted in a network connection attempt, false otherwise
+ */
+ public void reportInitialPartialScan(int channelCount, boolean status) {
+ synchronized (mLock) {
+ if (status) {
+ mInitPartialScanSuccessCount++;
+ mInitPartialScanSuccessHistogram.increment(channelCount);
+ } else {
+ mInitPartialScanFailureCount++;
+ mInitPartialScanFailureHistogram.increment(channelCount);
+ }
+ }
+ }
+
+ /**
* Put all metrics that were being tracked separately into mWifiLogProto
*/
private void consolidateProto() {
@@ -4102,6 +4150,16 @@ public class WifiMetrics {
mRxThroughputMbpsHistogram2G.toProto();
mWifiLogProto.throughputMbpsHistogram.rxAbove2G =
mRxThroughputMbpsHistogramAbove2G.toProto();
+
+ InitPartialScanStats initialPartialScanStats = new InitPartialScanStats();
+ initialPartialScanStats.numScans = mInitPartialScanTotalCount;
+ initialPartialScanStats.numSuccessScans = mInitPartialScanSuccessCount;
+ initialPartialScanStats.numFailureScans = mInitPartialScanFailureCount;
+ initialPartialScanStats.successfulScanChannelCountHistogram =
+ mInitPartialScanSuccessHistogram.toProto();
+ initialPartialScanStats.failedScanChannelCountHistogram =
+ mInitPartialScanFailureHistogram.toProto();
+ mWifiLogProto.initPartialScanStats = initialPartialScanStats;
}
}
@@ -4307,7 +4365,12 @@ public class WifiMetrics {
mWifiLogProto.isExternalWifiScorerOn = false;
mWifiOffMetrics.clear();
mSoftApConfigLimitationMetrics.clear();
-
+ //Initial partial scan metrics
+ mInitPartialScanTotalCount = 0;
+ mInitPartialScanSuccessCount = 0;
+ mInitPartialScanFailureCount = 0;
+ mInitPartialScanSuccessHistogram.clear();
+ mInitPartialScanFailureHistogram.clear();
}
}
diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto
index e0061f44d..04682db21 100644
--- a/service/proto/src/metrics.proto
+++ b/service/proto/src/metrics.proto
@@ -655,6 +655,9 @@ message WifiLog {
// Total number of scan results from 6GHz band
optional int32 num_6g_network_scan_results = 183;
+
+ // Initial partial scan stats
+ optional InitPartialScanStats init_partial_scan_stats = 184;
}
// Information that gets logged for every WiFi connection.
@@ -3122,3 +3125,22 @@ message ThroughputMbpsHistogram {
// Rx histogram above 2G
repeated HistogramBucketInt32 rx_above_2g = 4;
}
+
+// Initial Partial Scan stats
+message InitPartialScanStats {
+ // Total number of partial scans
+ optional int32 num_scans = 1;
+
+ // Number of instances a partial scan results in finding a network
+ optional int32 num_success_scans = 2;
+
+ // Number of instances a patial scan does not result in finding a network
+ // and a follow up full scan finds a network.
+ optional int32 num_failure_scans = 3;
+
+ // Histogram of number of channels used in a successful partial scan
+ repeated HistogramBucketInt32 successful_scan_channel_count_histogram = 4;
+
+ // Histogram of number of channels used in a failed partial scan
+ repeated HistogramBucketInt32 failed_scan_channel_count_histogram = 5;
+}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index ab02f0fc8..d9a435705 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -4680,4 +4680,51 @@ public class WifiMetricsTest extends WifiBaseTest {
assertHistogramBucketsEqual(expectedRxAbove2GHistogramMbps,
mDecodedProto.throughputMbpsHistogram.rxAbove2G);
}
+
+ /**
+ * Test the Initial partial scan statistics
+ */
+ @Test
+ public void testInitPartialScan() throws Exception {
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.reportInitialPartialScan(4, true);
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.reportInitialPartialScan(2, false);
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.reportInitialPartialScan(1, false);
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.reportInitialPartialScan(7, true);
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.reportInitialPartialScan(15, false);
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.reportInitialPartialScan(2, true);
+ mWifiMetrics.incrementInitialPartialScanCount();
+ mWifiMetrics.reportInitialPartialScan(10, true);
+
+ dumpProtoAndDeserialize();
+
+ assertEquals(9, mDecodedProto.initPartialScanStats.numScans);
+ assertEquals(4, mDecodedProto.initPartialScanStats.numSuccessScans);
+ assertEquals(3, mDecodedProto.initPartialScanStats.numFailureScans);
+
+ HistogramBucketInt32[] expectedSuccessScanHistogram = {
+ buildHistogramBucketInt32(1, 3, 1),
+ buildHistogramBucketInt32(3, 5, 1),
+ buildHistogramBucketInt32(5, 10, 1),
+ buildHistogramBucketInt32(10, Integer.MAX_VALUE, 1),
+ };
+
+ HistogramBucketInt32[] expectedFailureScanHistogram = {
+ buildHistogramBucketInt32(1, 3, 2),
+ buildHistogramBucketInt32(10, Integer.MAX_VALUE, 1),
+ };
+
+ assertHistogramBucketsEqual(expectedSuccessScanHistogram,
+ mDecodedProto.initPartialScanStats.successfulScanChannelCountHistogram);
+
+ assertHistogramBucketsEqual(expectedFailureScanHistogram,
+ mDecodedProto.initPartialScanStats.failedScanChannelCountHistogram);
+ }
}