summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorMukesh Agrawal <quiche@google.com>2016-08-22 17:45:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-08-22 17:45:02 +0000
commitd792e1b8cf0d53c9e892f9e99bf88f7385bea6f1 (patch)
tree8983e9788fef23eeff3a89ecdbac593605bf5ab8 /service
parentd7783d804c40b8b75b02ef1c86f87b399114d958 (diff)
parentf11073c03746f1c79e6a316884bc59574b562a8b (diff)
Merge "WifiMetrics: add metric for alert reasons"
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiLoggerHal.java5
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java50
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java4
-rw-r--r--service/proto/wifi.proto12
4 files changed, 69 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiLoggerHal.java b/service/java/com/android/server/wifi/WifiLoggerHal.java
index 8a0276480..0294e9bf7 100644
--- a/service/java/com/android/server/wifi/WifiLoggerHal.java
+++ b/service/java/com/android/server/wifi/WifiLoggerHal.java
@@ -46,4 +46,9 @@ public class WifiLoggerHal {
public static final byte RX_PKT_FATE_DRV_DROP_INVALID = 8;
public static final byte RX_PKT_FATE_DRV_DROP_NOBUFS = 9;
public static final byte RX_PKT_FATE_DRV_DROP_OTHER = 10;
+
+ /** These aren't formally part of the HAL. But they probably should be, eventually. */
+ public static final byte WIFI_ALERT_REASON_RESERVED = 0;
+ public static final byte WIFI_ALERT_REASON_MIN = 0;
+ public static final byte WIFI_ALERT_REASON_MAX = 64;
}
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 8a7cea4c3..e9d6a5a49 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -76,11 +76,14 @@ public class WifiMetrics {
* combination. Indexed by WifiLog.WifiState * (1 + screenOn)
*/
private final SparseIntArray mWifiSystemStateEntries = new SparseIntArray();
+ /** Mapping of RSSI values to counts. */
+ private final SparseIntArray mRssiPollCounts = new SparseIntArray();
+ /** Mapping of alert reason to the respective alert count. */
+ private final SparseIntArray mWifiAlertReasonCounts = new SparseIntArray();
/**
* Records the getElapsedSinceBootMillis (in seconds) that represents the beginning of data
* capture for for this WifiMetricsProto
*/
- private final SparseIntArray mRssiPollCounts = new SparseIntArray();
private long mRecordStartTimeSec;
class RouterFingerPrint {
@@ -807,6 +810,22 @@ public class WifiMetrics {
}
/**
+ * Increments the count of alerts by alert reason.
+ *
+ * @param reason The cause of the alert. The reason values are driver-specific.
+ */
+ public void incrementAlertReasonCount(int reason) {
+ if (reason > WifiLoggerHal.WIFI_ALERT_REASON_MAX
+ || reason < WifiLoggerHal.WIFI_ALERT_REASON_MIN) {
+ reason = WifiLoggerHal.WIFI_ALERT_REASON_RESERVED;
+ }
+ synchronized (mLock) {
+ int alertCount = mWifiAlertReasonCounts.get(reason);
+ mWifiAlertReasonCounts.put(reason, alertCount + 1);
+ }
+ }
+
+ /**
* Increment count of Watchdog successes.
*/
public void incrementNumLastResortWatchdogSuccesses() {
@@ -941,6 +960,21 @@ public class WifiMetrics {
sb.append(mRssiPollCounts.get(i) + " ");
}
pw.println(" " + sb.toString());
+ pw.print("mWifiLogProto.alertReasonCounts=");
+ sb.setLength(0);
+ for (int i = WifiLoggerHal.WIFI_ALERT_REASON_MIN;
+ i <= WifiLoggerHal.WIFI_ALERT_REASON_MAX; i++) {
+ int count = mWifiAlertReasonCounts.get(i);
+ if (count > 0) {
+ sb.append("(" + i + "," + count + "),");
+ }
+ }
+ if (sb.length() > 1) {
+ sb.setLength(sb.length() - 1); // strip trailing comma
+ pw.println(sb.toString());
+ } else {
+ pw.println("()");
+ }
}
}
}
@@ -954,6 +988,7 @@ public class WifiMetrics {
private void consolidateProto(boolean incremental) {
List<WifiMetricsProto.ConnectionEvent> events = new ArrayList<>();
List<WifiMetricsProto.RssiPollCount> rssis = new ArrayList<>();
+ List<WifiMetricsProto.AlertReasonCount> alertReasons = new ArrayList<>();
synchronized (mLock) {
for (ConnectionEvent event : mConnectionEventList) {
// If this is not incremental, dump full ConnectionEvent list
@@ -1011,6 +1046,18 @@ public class WifiMetrics {
rssis.add(keyVal);
}
mWifiLogProto.rssiPollRssiCount = rssis.toArray(mWifiLogProto.rssiPollRssiCount);
+
+ /**
+ * Convert the SparseIntArray of alert reasons and counts to the proto's repeated
+ * IntKeyVal array.
+ */
+ for (int i = 0; i < mWifiAlertReasonCounts.size(); i++) {
+ WifiMetricsProto.AlertReasonCount keyVal = new WifiMetricsProto.AlertReasonCount();
+ keyVal.reason = mWifiAlertReasonCounts.keyAt(i);
+ keyVal.count = mWifiAlertReasonCounts.valueAt(i);
+ alertReasons.add(keyVal);
+ }
+ mWifiLogProto.alertReasonCount = alertReasons.toArray(mWifiLogProto.alertReasonCount);
}
}
@@ -1027,6 +1074,7 @@ public class WifiMetrics {
mWifiSystemStateEntries.clear();
mRecordStartTimeSec = mClock.getElapsedSinceBootMillis() / 1000;
mRssiPollCounts.clear();
+ mWifiAlertReasonCounts.clear();
mWifiLogProto.clear();
}
}
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 53382eb26..c1f163dce 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -3930,7 +3930,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
case CMD_FIRMWARE_ALERT:
if (mWifiDiagnostics != null) {
byte[] buffer = (byte[])message.obj;
- mWifiDiagnostics.captureAlertData(message.arg1, buffer);
+ int alertReason = message.arg1;
+ mWifiDiagnostics.captureAlertData(alertReason, buffer);
+ mWifiMetrics.incrementAlertReasonCount(alertReason);
}
break;
case CMD_GET_LINK_LAYER_STATS:
diff --git a/service/proto/wifi.proto b/service/proto/wifi.proto
index 2bd410ce1..862c8667d 100644
--- a/service/proto/wifi.proto
+++ b/service/proto/wifi.proto
@@ -193,6 +193,9 @@ message WifiLog {
// Total number of times WiFi connected immediately after a Last Resort Watchdog trigger,
// without new networks becoming available.
optional int32 num_last_resort_watchdog_successes = 36;
+
+ // Counts the occurrences of each alert reason.
+ repeated AlertReasonCount alert_reason_count = 47;
}
// Information that gets logged for every WiFi connection.
@@ -353,3 +356,12 @@ message RssiPollCount {
// Number of RSSI polls with 'rssi'
optional int32 count = 2;
}
+
+// Number of occurrences of a specific alert reason value
+message AlertReasonCount {
+ // Alert reason
+ optional int32 reason = 1;
+
+ // Number of alerts with |reason|.
+ optional int32 count = 2;
+}