diff options
| author | David Chen <dwchen@google.com> | 2017-11-22 10:56:48 -0800 |
|---|---|---|
| committer | David Chen <dwchen@google.com> | 2017-12-04 10:23:28 -0800 |
| commit | 2e8f3807379f5d5d151ad2cb434d8a7aca910238 (patch) | |
| tree | 0b67079827a7368229fbb39915907839b73189f1 /core/java/android/util/StatsManager.java | |
| parent | d796c9062e9201ef8cbdb59abd982cd16f9b8ae1 (diff) | |
Adds new API to retrieve statsd metadata.
This API can be used by clients to gather stats about statsd, eg.
memory usage, number of metrics/matchers, etc. This data can be used
to debug if devices are not providing expected metrics. The metadata
will be for all configurations, but will not contain the actual
collected metrics since those might have privacy implications.
Test: Tests that statsd and Android still build.
Bug: 69522276
Change-Id: I8e0fedc142f5deed7be6e6309f9444e67d8369ce
Diffstat (limited to 'core/java/android/util/StatsManager.java')
| -rw-r--r-- | core/java/android/util/StatsManager.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/core/java/android/util/StatsManager.java b/core/java/android/util/StatsManager.java index 2bcd863cd409..26a3c361e8c1 100644 --- a/core/java/android/util/StatsManager.java +++ b/core/java/android/util/StatsManager.java @@ -93,10 +93,11 @@ public final class StatsManager { } /** - * Clients can request data with a binder call. + * Clients can request data with a binder call. This getter is destructive and also clears + * the retrieved metrics from statsd memory. * * @param configKey Configuration key to retrieve data from. - * @return Serialized ConfigMetricsReport proto. Returns null on failure. + * @return Serialized ConfigMetricsReportList proto. Returns null on failure. */ @RequiresPermission(Manifest.permission.DUMP) public byte[] getData(String configKey) { @@ -115,6 +116,30 @@ public final class StatsManager { } } + /** + * Clients can request metadata for statsd. Will contain stats across all configurations but not + * the actual metrics themselves (metrics must be collected via {@link #getData(String)}. + * This getter is not destructive and will not reset any metrics/counters. + * + * @return Serialized StatsdStatsReport proto. Returns null on failure. + */ + @RequiresPermission(Manifest.permission.DUMP) + public byte[] getMetadata() { + synchronized (this) { + try { + IStatsManager service = getIStatsManagerLocked(); + if (service == null) { + Slog.d(TAG, "Failed to find statsd when getting metadata"); + return null; + } + return service.getMetadata(); + } catch (RemoteException e) { + Slog.d(TAG, "Failed to connecto statsd when getting metadata"); + return null; + } + } + } + private class StatsdDeathRecipient implements IBinder.DeathRecipient { @Override public void binderDied() { |
