From 0bd272f1ccd88f6c1c887db07d875964838569e9 Mon Sep 17 00:00:00 2001 From: Matthew Sedam Date: Tue, 6 Sep 2022 21:48:04 +0000 Subject: [PATCH] Add clear() to ContextHubEventLogger Test: unit tests Bug: 217576459 Change-Id: If9aab16975807e8fa482f4be0f389bb81c1d52cd --- .../location/contexthub/ContextHubEventLogger.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubEventLogger.java b/services/core/java/com/android/server/location/contexthub/ContextHubEventLogger.java index 071917ca3e4ce..15b209396a889 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubEventLogger.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubEventLogger.java @@ -19,6 +19,8 @@ package com.android.server.location.contexthub; import android.hardware.location.NanoAppMessage; import android.util.Log; +import java.util.Collection; + /** * A class to log events and useful metrics within the Context Hub service. * @@ -216,6 +218,18 @@ public class ContextHubEventLogger { return sInstance; } + /** + * Clears all queues of events. + */ + public synchronized void clear() { + for (Collection deque: + new Collection[] {mNanoappLoadEventQueue, mNanoappUnloadEventQueue, + mMessageFromNanoappQueue, mMessageToNanoappQueue, + mContextHubRestartEventQueue}) { + deque.clear(); + } + } + /** * Logs a nanoapp load event *