summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlen Kuhne <kuh@google.com>2016-06-22 19:55:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-06-22 19:55:45 +0000
commitaf2c07c305e33b759b3b0e707fdc264b193626c4 (patch)
treecef91b6e48de8866bcc7e4bdb2c91814297f4818
parenta780a159b70cb9a72ea1adc47ab7dbb458914d5a (diff)
parent7a0b9ffe794113c4a5ed528d8aadeb3303d1b089 (diff)
Merge "Wifi Metrics: Log RSSI polls" into nyc-mr1-dev
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java53
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java4
-rw-r--r--service/proto/wifi.proto12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java11
4 files changed, 72 insertions, 8 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index cc6fe000f..0dc5ccf2e 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -42,6 +42,11 @@ import java.util.List;
public class WifiMetrics {
private static final String TAG = "WifiMetrics";
private static final boolean DBG = false;
+ /**
+ * Clamp the RSSI poll counts to values between [MIN,MAX]_RSSI_POLL
+ */
+ private static final int MAX_RSSI_POLL = 0;
+ private static final int MIN_RSSI_POLL = -127;
private final Object mLock = new Object();
private static final int MAX_CONNECTION_EVENTS = 256;
private Clock mClock;
@@ -53,11 +58,11 @@ public class WifiMetrics {
* runtime in member lists of this WifiMetrics class, with the final WifiLog proto being pieced
* together at dump-time
*/
- private final WifiMetricsProto.WifiLog mWifiLogProto;
+ private final WifiMetricsProto.WifiLog mWifiLogProto = new WifiMetricsProto.WifiLog();
/**
* Session information that gets logged for every Wifi connection attempt.
*/
- private final List<ConnectionEvent> mConnectionEventList;
+ private final List<ConnectionEvent> mConnectionEventList = new ArrayList<>();
/**
* The latest started (but un-ended) connection attempt
*/
@@ -65,16 +70,17 @@ public class WifiMetrics {
/**
* Count of number of times each scan return code, indexed by WifiLog.ScanReturnCode
*/
- private SparseIntArray mScanReturnEntries;
+ private final SparseIntArray mScanReturnEntries = new SparseIntArray();
/**
* Mapping of system state to the counts of scans requested in that wifi state * screenOn
* combination. Indexed by WifiLog.WifiState * (1 + screenOn)
*/
- private SparseIntArray mWifiSystemStateEntries;
+ private final SparseIntArray mWifiSystemStateEntries = new SparseIntArray();
/**
* Records the elapsedRealtime (in seconds) that represents the beginning of data
* capture for for this WifiMetricsProto
*/
+ private final SparseIntArray mRssiPollCounts = new SparseIntArray();
private long mRecordStartTimeSec;
class RouterFingerPrint {
@@ -304,10 +310,6 @@ public class WifiMetrics {
public WifiMetrics(Clock clock) {
mClock = clock;
- mWifiLogProto = new WifiMetricsProto.WifiLog();
- mConnectionEventList = new ArrayList<>();
- mScanReturnEntries = new SparseIntArray();
- mWifiSystemStateEntries = new SparseIntArray();
mCurrentConnectionEvent = null;
mScreenOn = true;
mWifiState = WifiMetricsProto.WifiLog.WIFI_DISABLED;
@@ -790,6 +792,20 @@ public class WifiMetrics {
}
}
+ /**
+ * Increment occurence count of RSSI level from RSSI poll.
+ * Ignores rssi values outside the bounds of [MIN_RSSI_POLL, MAX_RSSI_POLL]
+ */
+ public void incrementRssiPollRssiCount(int rssi) {
+ if (!(rssi >= MIN_RSSI_POLL && rssi <= MAX_RSSI_POLL)) {
+ return;
+ }
+ synchronized (mLock) {
+ int count = mRssiPollCounts.get(rssi);
+ mRssiPollCounts.put(rssi, count + 1);
+ }
+ }
+
public static final String PROTO_DUMP_ARG = "wifiMetricsProto";
/**
* Dump all WifiMetrics. Collects some metrics from ConfigStore, Settings and WifiManager
@@ -907,6 +923,13 @@ public class WifiMetrics {
+ mWifiLogProto.numLastResortWatchdogTriggersWithBadOther);
pw.println("mWifiLogProto.recordDurationSec="
+ ((mClock.elapsedRealtime() / 1000) - mRecordStartTimeSec));
+ pw.println("mWifiLogProto.rssiPollRssiCount: Printing counts for [" + MIN_RSSI_POLL
+ + ", " + MAX_RSSI_POLL + "]");
+ StringBuilder sb = new StringBuilder();
+ for (int i = MIN_RSSI_POLL; i <= MAX_RSSI_POLL; i++) {
+ sb.append(mRssiPollCounts.get(i) + " ");
+ }
+ pw.println(" " + sb.toString());
}
}
}
@@ -919,6 +942,7 @@ public class WifiMetrics {
*/
private void consolidateProto(boolean incremental) {
List<WifiMetricsProto.ConnectionEvent> events = new ArrayList<>();
+ List<WifiMetricsProto.RssiPollCount> rssis = new ArrayList<>();
synchronized (mLock) {
for (ConnectionEvent event : mConnectionEventList) {
// If this is not incremental, dump full ConnectionEvent list
@@ -964,6 +988,18 @@ public class WifiMetrics {
}
mWifiLogProto.recordDurationSec = (int) ((mClock.elapsedRealtime() / 1000)
- mRecordStartTimeSec);
+
+ /**
+ * Convert the SparseIntArray of RSSI poll rssi's and counts to the proto's repeated
+ * IntKeyVal array.
+ */
+ for (int i = 0; i < mRssiPollCounts.size(); i++) {
+ WifiMetricsProto.RssiPollCount keyVal = new WifiMetricsProto.RssiPollCount();
+ keyVal.rssi = mRssiPollCounts.keyAt(i);
+ keyVal.count = mRssiPollCounts.valueAt(i);
+ rssis.add(keyVal);
+ }
+ mWifiLogProto.rssiPollRssiCount = rssis.toArray(mWifiLogProto.rssiPollRssiCount);
}
}
@@ -979,6 +1015,7 @@ public class WifiMetrics {
mScanReturnEntries.clear();
mWifiSystemStateEntries.clear();
mRecordStartTimeSec = mClock.elapsedRealtime() / 1000;
+ mRssiPollCounts.clear();
mWifiLogProto.clear();
}
}
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 4032c84a0..7fa739f38 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -3143,6 +3143,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
if (newRssi > 0) newRssi -= 256;
mWifiInfo.setRssi(newRssi);
/*
+ * Log the rssi poll value in metrics
+ */
+ mWifiMetrics.incrementRssiPollRssiCount(newRssi);
+ /*
* Rather then sending the raw RSSI out every time it
* changes, we precalculate the signal level that would
* be displayed in the status bar, and only send the
diff --git a/service/proto/wifi.proto b/service/proto/wifi.proto
index 43a4166dc..3b0e8544b 100644
--- a/service/proto/wifi.proto
+++ b/service/proto/wifi.proto
@@ -186,6 +186,9 @@ message WifiLog {
// The time duration represented by this wifi log, from start to end of capture
optional int32 record_duration_sec = 34;
+
+ // Counts the occurrences of each individual RSSI poll level
+ repeated RssiPollCount rssi_poll_rssi_count = 35;
}
// Information that gets logged for every WiFi connection.
@@ -337,3 +340,12 @@ message ConnectionEvent {
// Has bug report been taken.
optional bool automatic_bug_report_taken = 9;
}
+
+// Number of occurrences of a specific RSSI poll rssi value
+message RssiPollCount {
+ // RSSI
+ optional int32 rssi = 1;
+
+ // Number of RSSI polls with 'rssi'
+ optional int32 count = 2;
+}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 530b2180b..011682b81 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -154,6 +154,8 @@ public class WifiMetricsTest {
private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_AUTHENTICATION = 8;
private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_DHCP = 9;
private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_OTHER = 10;
+ private static final int NUM_RSSI_LEVELS_TO_INCREMENT = 20;
+ private static final int FIRST_RSSI_LEVEL = -80;
/**
* Set simple metrics, increment others
*/
@@ -236,6 +238,11 @@ public class WifiMetricsTest {
for (int i = 0; i < NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_OTHER; i++) {
mWifiMetrics.incrementNumLastResortWatchdogTriggersWithBadOther();
}
+ for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) {
+ for (int j = 0; j <= i; j++) {
+ mWifiMetrics.incrementRssiPollRssiCount(FIRST_RSSI_LEVEL + i);
+ }
+ }
}
/**
@@ -313,6 +320,10 @@ public class WifiMetricsTest {
mDeserializedWifiMetrics.numLastResortWatchdogTriggersWithBadOther);
assertEquals(TEST_RECORD_DURATION_SEC,
mDeserializedWifiMetrics.recordDurationSec);
+ for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) {
+ assertEquals(FIRST_RSSI_LEVEL + i, mDeserializedWifiMetrics.rssiPollRssiCount[i].rssi);
+ assertEquals(i + 1, mDeserializedWifiMetrics.rssiPollRssiCount[i].count);
+ }
}
/**