From 989cd1c168d12be13efa4e1cd9df6b2c28ad5fbb Mon Sep 17 00:00:00 2001 From: Arthur Ishiguro Date: Wed, 27 Oct 2021 15:44:01 +0000 Subject: [PATCH 1/2] Add support for CHRE metrics in core framework Bug: 194287570 Test: Compile Change-Id: Ib15d4d9e71493182d2837f9b6c8e3be0ecd76010 --- services/core/Android.bp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/core/Android.bp b/services/core/Android.bp index 216224c7aad62..f135fbfd9f8d5 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -88,12 +88,21 @@ genrule { out: ["com/android/internal/art/ArtStatsLog.java"], } +genrule { + name: "statslog-contexthub-java-gen", + tools: ["stats-log-api-gen"], + cmd: "$(location stats-log-api-gen) --java $(out) --module contexthub" + + " --javaPackage com.android.server.location.contexthub --javaClass ContextHubStatsLog", + out: ["com/android/server/location/contexthub/ContextHubStatsLog.java"], +} + java_library_static { name: "services.core.unboosted", defaults: ["platform_service_defaults"], srcs: [ ":android.hardware.biometrics.face-V1-java-source", ":statslog-art-java-gen", + ":statslog-contexthub-java-gen", ":services.core-sources", ":services.core.protologsrc", ":dumpstate_aidl", From 7b1a3b259cc19447f1a3bc7fb45258f695a76049 Mon Sep 17 00:00:00 2001 From: Arthur Ishiguro Date: Wed, 27 Oct 2021 16:58:54 +0000 Subject: [PATCH 2/2] Add logging code for ContextHubBooted atom Bug: 194287570 Test: Compile Change-Id: I3f0904efabcb3cf861567654826675a19187c420 --- .../server/location/contexthub/ContextHubService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubService.java b/services/core/java/com/android/server/location/contexthub/ContextHubService.java index 686926f592e37..1c04d8cbbbdee 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubService.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubService.java @@ -49,6 +49,7 @@ import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ShellCallback; +import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; @@ -184,6 +185,7 @@ public class ContextHubService extends IContextHubService.Stub { } public ContextHubService(Context context) { + long startTimeNs = SystemClock.elapsedRealtimeNanos(); mContext = context; mContextHubWrapper = getContextHubWrapper(); @@ -205,6 +207,9 @@ public class ContextHubService extends IContextHubService.Stub { Log.e(TAG, "RemoteException while getting Context Hub info", e); hubInfo = new Pair(Collections.emptyList(), Collections.emptyList()); } + long bootTimeNs = SystemClock.elapsedRealtimeNanos() - startTimeNs; + int numContextHubs = hubInfo.first.size(); + ContextHubStatsLog.write(ContextHubStatsLog.CONTEXT_HUB_BOOTED, bootTimeNs, numContextHubs); mContextHubIdToInfoMap = Collections.unmodifiableMap( ContextHubServiceUtil.createContextHubInfoMap(hubInfo.first));