summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java8
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareMetrics.java18
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java10
4 files changed, 39 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
index 601fc4429..ca12d5d52 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
@@ -500,6 +500,7 @@ public class WifiAwareDataPathStateManager {
mAwareMetrics.recordNdpStatus(NanStatusType.SUCCESS, networkSpecifier.isOutOfBand(),
nnri.startTimestamp);
+ nnri.startTimestamp = SystemClock.elapsedRealtime(); // update time-stamp for duration
mAwareMetrics.recordNdpCreation(nnri.uid, mNetworkRequestsCache);
} else {
if (DBG) {
@@ -533,6 +534,11 @@ public class WifiAwareDataPathStateManager {
}
tearDownInterface(nnriE.getValue());
+ if (nnriE.getValue().state == AwareNetworkRequestInformation.STATE_RESPONDER_CONFIRMED
+ || nnriE.getValue().state
+ == AwareNetworkRequestInformation.STATE_INITIATOR_CONFIRMED) {
+ mAwareMetrics.recordNdpSessionDuration(nnriE.getValue().startTimestamp);
+ }
mNetworkRequestsCache.remove(nnriE.getKey());
}
@@ -990,7 +996,7 @@ public class WifiAwareDataPathStateManager {
", ndpId=").append(ndpId).append(", peerDataMac=").append(
peerDataMac == null ? ""
: String.valueOf(HexEncoding.encode(peerDataMac))).append(
- "startTimestamp=").append(startTimestamp);
+ ", startTimestamp=").append(startTimestamp);
return sb.toString();
}
}
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java b/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java
index 5001274d0..77823a3ad 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java
@@ -109,6 +109,8 @@ public class WifiAwareMetrics {
private long mNdpCreationTimeSumSq = 0;
private long mNdpCreationTimeNumSamples = 0;
+ private SparseIntArray mHistogramNdpDuration = new SparseIntArray();
+
public WifiAwareMetrics(Clock clock) {
mClock = clock;
}
@@ -396,6 +398,17 @@ public class WifiAwareMetrics {
}
/**
+ * Record the duration of the NDP session. The creation time is assumed to be the time at
+ * which a confirm message was received (i.e. the end of the setup negotiation).
+ */
+ public void recordNdpSessionDuration(long creationTime) {
+ synchronized (mLock) {
+ addLogValueToHistogram(mClock.getElapsedSinceBootMillis() - creationTime,
+ mHistogramNdpDuration, DURATION_LOG_HISTOGRAM);
+ }
+ }
+
+ /**
* Consolidate all metrics into the proto.
*/
public WifiMetricsProto.WifiAwareLog consolidateProto() {
@@ -462,6 +475,9 @@ public class WifiAwareMetrics {
log.ndpCreationTimeMsSum = mNdpCreationTimeSum;
log.ndpCreationTimeMsSumOfSq = mNdpCreationTimeSumSq;
log.ndpCreationTimeMsNumSamples = mNdpCreationTimeNumSamples;
+
+ log.histogramNdpSessionDurationMs = histogramToProtoArray(mHistogramNdpDuration,
+ DURATION_LOG_HISTOGRAM);
}
return log;
}
@@ -518,6 +534,8 @@ public class WifiAwareMetrics {
mNdpCreationTimeSum = 0;
mNdpCreationTimeSumSq = 0;
mNdpCreationTimeNumSamples = 0;
+
+ mHistogramNdpDuration.clear();
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
index 8d70f97e3..0ddf765d7 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
@@ -712,7 +712,9 @@ public class WifiAwareDataPathStateManagerTest {
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).endDataPath(transactionId.capture(), eq(ndpId));
mDut.onEndDataPathResponse(transactionId.getValue(), true, 0);
+ mDut.onDataPathEndNotification(ndpId);
mMockLooper.dispatchAll();
+ inOrderM.verify(mAwareMetricsMock).recordNdpSessionDuration(anyLong());
}
verifyNoMoreInteractions(mMockNative, mMockCm, mAwareMetricsMock);
@@ -809,7 +811,9 @@ public class WifiAwareDataPathStateManagerTest {
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).endDataPath(transactionId.capture(), eq(ndpId));
mDut.onEndDataPathResponse(transactionId.getValue(), true, 0);
+ mDut.onDataPathEndNotification(ndpId);
mMockLooper.dispatchAll();
+ inOrderM.verify(mAwareMetricsMock).recordNdpSessionDuration(anyLong());
}
verifyNoMoreInteractions(mMockNative, mMockCm, mAwareMetricsMock);
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java
index 10db1a7b3..8cd1e1097 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java
@@ -425,6 +425,13 @@ public class WifiAwareMetricsTest {
mDut.recordNdpStatus(NanStatusType.INTERNAL_FAILURE, false, 0);
mDut.recordNdpStatus(NanStatusType.NO_RESOURCES_AVAILABLE, false, 0);
+ // and some durations
+ setTime(150);
+ mDut.recordNdpSessionDuration(7); // 143ms
+ mDut.recordNdpSessionDuration(10); // 140ms
+ mDut.recordNdpSessionDuration(25); // 125ms
+ mDut.recordNdpSessionDuration(140); // 10ms
+
//verify
log = mDut.consolidateProto();
@@ -453,6 +460,9 @@ public class WifiAwareMetricsTest {
validateProtoHistBucket("Creation[1]", log.histogramNdpCreationTimeMs[1], 2, 3, 1);
validateProtoHistBucket("Creation[2]", log.histogramNdpCreationTimeMs[2], 3, 4, 1);
validateProtoHistBucket("Creation[3]", log.histogramNdpCreationTimeMs[3], 10, 20, 2);
+
+ validateProtoHistBucket("Duration[0]", log.histogramNdpSessionDurationMs[0], 10, 20, 1);
+ validateProtoHistBucket("Duration[1]", log.histogramNdpSessionDurationMs[1], 100, 200, 3);
}
/**