summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorOscar Shu <xshu@google.com>2018-05-23 21:47:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-05-23 21:47:44 +0000
commitb8ccf8e846d73180792b76d74e6c124262cc2f16 (patch)
tree2fb6c1ca4bbfb7aefc6be7790803e8012ab594ff /service
parent8b8c239ae1190a8055b378cfdb503df9823dba16 (diff)
parent04012eb3e692202b25095f7afc1eda40b63e3e0f (diff)
Merge "Separates RSSI poll histogram by channel frequency" into pi-dev
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();