summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2018-05-16 15:41:19 -0700
committerxshu <xshu@google.com>2018-05-22 16:12:26 -0700
commit04012eb3e692202b25095f7afc1eda40b63e3e0f (patch)
tree0d3d7f442a43c08d45fe21a2035df8e5b439dc3d /service
parent76b64fecb6dd8ef593582295f01e543eb41f46a7 (diff)
Separates RSSI poll histogram by channel frequency
Putting RSSI poll for each frequency into a different histogram. Will be merging the histograms that have similar properties in the metric aggregation code. (i.e. combine frequencies from 5150 - 5250 into a single histogram because they have similar max power usage) Bug: 79864669 Test: compile, unit tests Manual test: flash connect to "Google Guest" and wait 15s Connect to "Boingo GOolge Open" and wait 15s adb shell dumpsys wifi verify that histograms are dumped out for 2 different channel frequencies: mWifiLogProto.rssiPollCount: Printing counts for [-127, 0] {"5540":[{"-57":1},{"-54":1},{"-53":2},{"-52":3},{"-51":1}],"5640":[{"-49":5},{"-48":9},{"-47":3},{"-45":1}]} Change-Id: I1a4ec8ea23f4641905b5ea82fdc0100c3d55d92e
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java79
1 files changed, 56 insertions, 23 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 39266a638..a3bd1697c 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -50,6 +50,10 @@ import com.android.server.wifi.rtt.RttMetrics;
import com.android.server.wifi.util.InformationElementUtil;
import com.android.server.wifi.util.ScanResultUtil;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -137,8 +141,8 @@ 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 channel frequency to its RSSI distribution histogram **/
+ private final Map<Integer, SparseIntArray> mRssiPollCountsMap = new HashMap<>();
/** Mapping of RSSI scan-poll delta values to counts. */
private final SparseIntArray mRssiDeltaCounts = new SparseIntArray();
/** RSSI of the scan result for the last connection event*/
@@ -1095,20 +1099,26 @@ public class WifiMetrics {
mLastPollRssi = wifiInfo.getRssi();
mLastPollLinkSpeed = wifiInfo.getLinkSpeed();
mLastPollFreq = wifiInfo.getFrequency();
- incrementRssiPollRssiCount(mLastPollRssi);
+ incrementRssiPollRssiCount(mLastPollFreq, mLastPollRssi);
}
/**
- * Increment occurence count of RSSI level from RSSI poll.
- * Ignores rssi values outside the bounds of [MIN_RSSI_POLL, MAX_RSSI_POLL]
+ * Increment occurence count of RSSI level from RSSI poll for the given frequency.
+ * @param frequency (MHz)
+ * @param rssi
*/
- public void incrementRssiPollRssiCount(int rssi) {
+ @VisibleForTesting
+ public void incrementRssiPollRssiCount(int frequency, int rssi) {
if (!(rssi >= MIN_RSSI_POLL && rssi <= MAX_RSSI_POLL)) {
return;
}
synchronized (mLock) {
- int count = mRssiPollCounts.get(rssi);
- mRssiPollCounts.put(rssi, count + 1);
+ if (!mRssiPollCountsMap.containsKey(frequency)) {
+ mRssiPollCountsMap.put(frequency, new SparseIntArray());
+ }
+ SparseIntArray sparseIntArray = mRssiPollCountsMap.get(frequency);
+ int count = sparseIntArray.get(rssi);
+ sparseIntArray.put(rssi, count + 1);
maybeIncrementRssiDeltaCount(rssi - mScanResultRssi);
}
}
@@ -1907,16 +1917,32 @@ public class WifiMetrics {
+ mWifiLogProto.numLastResortWatchdogSuccesses);
pw.println("mWifiLogProto.recordDurationSec="
+ ((mClock.getElapsedSinceBootMillis() / 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) + " ");
+
+ try {
+ JSONObject rssiMap = new JSONObject();
+ for (Map.Entry<Integer, SparseIntArray> entry : mRssiPollCountsMap.entrySet()) {
+ int frequency = entry.getKey();
+ final SparseIntArray histogram = entry.getValue();
+ JSONArray histogramElements = new JSONArray();
+ for (int i = MIN_RSSI_POLL; i <= MAX_RSSI_POLL; i++) {
+ int count = histogram.get(i);
+ if (count == 0) {
+ continue;
+ }
+ JSONObject histogramElement = new JSONObject();
+ histogramElement.put(Integer.toString(i), count);
+ histogramElements.put(histogramElement);
+ }
+ rssiMap.put(Integer.toString(frequency), histogramElements);
+ }
+ pw.println("mWifiLogProto.rssiPollCount: " + rssiMap.toString());
+ } catch (JSONException e) {
+ pw.println("JSONException occurred: " + e.getMessage());
}
- pw.println(" " + sb.toString());
+
pw.println("mWifiLogProto.rssiPollDeltaCount: Printing counts for ["
+ MIN_RSSI_DELTA + ", " + MAX_RSSI_DELTA + "]");
- sb.setLength(0);
+ StringBuilder sb = new StringBuilder();
for (int i = MIN_RSSI_DELTA; i <= MAX_RSSI_DELTA; i++) {
sb.append(mRssiDeltaCounts.get(i) + " ");
}
@@ -2238,14 +2264,19 @@ public class WifiMetrics {
- mRecordStartTimeSec);
/**
- * Convert the SparseIntArray of RSSI poll rssi's and counts to the proto's repeated
- * IntKeyVal array.
+ * Convert the SparseIntArrays of RSSI poll rssi, counts, and frequency to the
+ * proto's repeated ntKeyVal 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);
+ for (Map.Entry<Integer, SparseIntArray> entry : mRssiPollCountsMap.entrySet()) {
+ int frequency = entry.getKey();
+ SparseIntArray histogram = entry.getValue();
+ for (int i = 0; i < histogram.size(); i++) {
+ WifiMetricsProto.RssiPollCount keyVal = new WifiMetricsProto.RssiPollCount();
+ keyVal.rssi = histogram.keyAt(i);
+ keyVal.count = histogram.valueAt(i);
+ keyVal.frequency = frequency;
+ rssis.add(keyVal);
+ }
}
mWifiLogProto.rssiPollRssiCount = rssis.toArray(mWifiLogProto.rssiPollRssiCount);
@@ -2261,6 +2292,8 @@ public class WifiMetrics {
}
mWifiLogProto.rssiPollDeltaCount = rssiDeltas.toArray(mWifiLogProto.rssiPollDeltaCount);
+
+
/**
* Convert the SparseIntArray of alert reasons and counts to the proto's repeated
* IntKeyVal array.
@@ -2460,7 +2493,7 @@ public class WifiMetrics {
mScanReturnEntries.clear();
mWifiSystemStateEntries.clear();
mRecordStartTimeSec = mClock.getElapsedSinceBootMillis() / 1000;
- mRssiPollCounts.clear();
+ mRssiPollCountsMap.clear();
mRssiDeltaCounts.clear();
mWifiAlertReasonCounts.clear();
mWifiScoreCounts.clear();