summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-05-14 11:23:12 -0700
committerNate Jiang <qiangjiang@google.com>2020-05-15 16:16:32 -0700
commit7b4125f23cb847b53f6cacbe67050a16c688c6a4 (patch)
tree751893967e5a5613b946cf0d64718d0a8a676cdd /service
parent38facc3b2590107a404f2e824fca867afbdd2b92 (diff)
[Metrics] Add Rtt measurement duration metrics
Updated-PDD: TRUE Bug: 131708995 Test: atest com.android.server.wifi Change-Id: Ib12fd6c730df726df7b3c80dd8f685df4e245922
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/rtt/RttMetrics.java35
-rw-r--r--service/java/com/android/server/wifi/rtt/RttServiceImpl.java5
-rw-r--r--service/proto/src/metrics.proto6
3 files changed, 43 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/rtt/RttMetrics.java b/service/java/com/android/server/wifi/rtt/RttMetrics.java
index da5cd9ee6..c2ee4ddb5 100644
--- a/service/java/com/android/server/wifi/rtt/RttMetrics.java
+++ b/service/java/com/android/server/wifi/rtt/RttMetrics.java
@@ -75,12 +75,21 @@ public class RttMetrics {
// >= 100
private static final int[] DISTANCE_MM_HISTOGRAM =
{0, 5 * 1000, 15 * 1000, 30 * 1000, 60 * 1000, 100 * 1000};
+ // Histogram for duration for ap only measurement. Indicates 5 buckets with 1000 ms interval.
+ private static final int[] MEASUREMENT_DURATION_HISTOGRAM_AP =
+ {1 * 1000, 2 * 1000, 3 * 1000, 4 * 1000};
+
+ // Histogram for duration for measurement with aware. Indicates 5 buckets with 2000 ms interval.
+ private static final int[] MEASUREMENT_DURATION_HISTOGRAM_AWARE =
+ {2 * 1000, 4 * 1000, 6 * 1000, 8 * 1000};
private static final int PEER_AP = 0;
private static final int PEER_AWARE = 1;
private int mNumStartRangingCalls = 0;
private SparseIntArray mOverallStatusHistogram = new SparseIntArray();
+ private SparseIntArray mMeasurementDurationApOnlyHistogram = new SparseIntArray();
+ private SparseIntArray mMeasurementDurationWithAwareHistogram = new SparseIntArray();
private PerPeerTypeInfo[] mPerPeerTypeInfo;
public RttMetrics(Clock clock) {
@@ -150,13 +159,14 @@ public class RttMetrics {
/**
* Record metrics for the range results.
*/
- public void recordResult(RangingRequest requests, List<RangingResult> results) {
+ public void recordResult(RangingRequest requests, List<RangingResult> results,
+ int measurementDuration) {
Map<MacAddress, ResponderConfig> requestEntries = new HashMap<>();
for (ResponderConfig responder : requests.mRttPeers) {
requestEntries.put(responder.macAddress, responder);
}
-
if (results != null) {
+ boolean containsAwarePeer = false;
for (RangingResult result : results) {
if (result == null) {
continue;
@@ -172,11 +182,21 @@ public class RttMetrics {
if (responder.responderType == ResponderConfig.RESPONDER_AP) {
updatePeerInfoWithResultInfo(mPerPeerTypeInfo[PEER_AP], result);
} else if (responder.responderType == ResponderConfig.RESPONDER_AWARE) {
+ containsAwarePeer = true;
updatePeerInfoWithResultInfo(mPerPeerTypeInfo[PEER_AWARE], result);
} else {
Log.e(TAG, "recordResult: unexpected peer type in responder: " + responder);
}
}
+ if (containsAwarePeer) {
+ addValueToLinearHistogram(measurementDuration,
+ mMeasurementDurationWithAwareHistogram,
+ MEASUREMENT_DURATION_HISTOGRAM_AWARE);
+ } else {
+ addValueToLinearHistogram(measurementDuration,
+ mMeasurementDurationApOnlyHistogram,
+ MEASUREMENT_DURATION_HISTOGRAM_AP);
+ }
}
for (ResponderConfig responder : requestEntries.values()) {
@@ -255,6 +275,12 @@ public class RttMetrics {
synchronized (mLock) {
log.numRequests = mNumStartRangingCalls;
log.histogramOverallStatus = consolidateOverallStatus(mOverallStatusHistogram);
+ log.histogramMeasurementDurationApOnly = genericBucketsToRttBuckets(
+ linearHistogramToGenericBuckets(mMeasurementDurationApOnlyHistogram,
+ MEASUREMENT_DURATION_HISTOGRAM_AP));
+ log.histogramMeasurementDurationWithAware = genericBucketsToRttBuckets(
+ linearHistogramToGenericBuckets(mMeasurementDurationWithAwareHistogram,
+ MEASUREMENT_DURATION_HISTOGRAM_AWARE));
consolidatePeerType(log.rttToAp, mPerPeerTypeInfo[PEER_AP]);
consolidatePeerType(log.rttToAware, mPerPeerTypeInfo[PEER_AWARE]);
@@ -356,6 +382,9 @@ public class RttMetrics {
pw.println("RTT Metrics:");
pw.println("mNumStartRangingCalls:" + mNumStartRangingCalls);
pw.println("mOverallStatusHistogram:" + mOverallStatusHistogram);
+ pw.println("mMeasurementDurationApOnlyHistogram" + mMeasurementDurationApOnlyHistogram);
+ pw.println("mMeasurementDurationWithAwareHistogram"
+ + mMeasurementDurationWithAwareHistogram);
pw.println("AP:" + mPerPeerTypeInfo[PEER_AP]);
pw.println("AWARE:" + mPerPeerTypeInfo[PEER_AWARE]);
}
@@ -370,6 +399,8 @@ public class RttMetrics {
mOverallStatusHistogram.clear();
mPerPeerTypeInfo[PEER_AP] = new PerPeerTypeInfo();
mPerPeerTypeInfo[PEER_AWARE] = new PerPeerTypeInfo();
+ mMeasurementDurationApOnlyHistogram.clear();
+ mMeasurementDurationWithAwareHistogram.clear();
}
}
diff --git a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
index 02c262bba..ca986d112 100644
--- a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
+++ b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
@@ -92,6 +92,7 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
private ActivityManager mActivityManager;
private PowerManager mPowerManager;
private int mBackgroundProcessExecGapMs;
+ private long mLastRequestTimestamp;
private RttServiceSynchronized mRttServiceSynchronized;
@@ -829,6 +830,7 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
}
nextRequest.cmdId = mNextCommandId++;
+ mLastRequestTimestamp = mClock.getWallClockMillis();
if (mRttNative.rangeRequest(nextRequest.cmdId, nextRequest.request,
nextRequest.isCalledFromPrivilegedContext)) {
long timeout = HAL_RANGING_TIMEOUT_MS;
@@ -1065,7 +1067,8 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
List<RangingResult> finalResults = postProcessResults(topOfQueueRequest.request,
results, topOfQueueRequest.isCalledFromPrivilegedContext);
mRttMetrics.recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
- mRttMetrics.recordResult(topOfQueueRequest.request, results);
+ mRttMetrics.recordResult(topOfQueueRequest.request, results,
+ (int) (mClock.getWallClockMillis() - mLastRequestTimestamp));
if (VDBG) {
Log.v(TAG, "RttServiceSynchronized.onRangingResults: finalResults="
+ finalResults);
diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto
index 688b45376..ad52af1f4 100644
--- a/service/proto/src/metrics.proto
+++ b/service/proto/src/metrics.proto
@@ -1918,6 +1918,12 @@ message WifiRttLog {
// RTT to Wi-Fi Aware peers metrics
optional RttToPeerLog rtt_to_aware = 4;
+ // Histogram of how long a measurement with only AP take.
+ repeated HistogramBucket histogram_measurement_duration_ap_only = 5;
+
+ // Histogram of how long a measurement with aware peer included take.
+ repeated HistogramBucket histogram_measurement_duration_with_aware = 6;
+
// Metrics for a RTT to Peer (peer = AP or Wi-Fi Aware)
message RttToPeerLog {
// Total number of API calls