MediaMetrics: Update dumpsys parameters
Make --prefix and --since work for analytics.
Test: adb shell dumpsys media.metrics --all
Test: adb shell dumpsys media.metrics --clear
Test: adb shell dumpsys media.metrics --heap
Test: adb shell dumpsys media.metrics --help
Test: adb shell dumpsys media.metrics --prefix c
Test: adb shell dumpsys media.metrics --prefix audio.volume
Test: adb shell dumpsys media.metrics --since -100
Test: adb shell dumpsys media.metrics --unreachable
Bug: 149850236
Change-Id: Id3e0cb6fe789027b5d5c86cce93ce07f636736bf
diff --git a/services/mediametrics/AnalyticsState.h b/services/mediametrics/AnalyticsState.h
index 290ed21..e8fedcf 100644
--- a/services/mediametrics/AnalyticsState.h
+++ b/services/mediametrics/AnalyticsState.h
@@ -84,8 +84,11 @@
* delivered.
*
* \param lines the maximum number of lines in the string returned.
+ * \param sinceNs the nanoseconds since Unix epoch to start dump (0 shows all)
+ * \param prefix the desired key prefix to match (nullptr shows all)
*/
- std::pair<std::string, int32_t> dump(int32_t lines = INT32_MAX) const {
+ std::pair<std::string, int32_t> dump(
+ int32_t lines = INT32_MAX, int64_t sinceNs = 0, const char *prefix = nullptr) const {
std::stringstream ss;
int32_t ll = lines;
@@ -94,8 +97,8 @@
--ll;
}
if (ll > 0) {
- auto [s, l] = mTransactionLog.dump(ll);
- ss << s;
+ auto [s, l] = mTransactionLog.dump(ll, sinceNs, prefix);
+ ss << std::move(s);
ll -= l;
}
if (ll > 0) {
@@ -103,8 +106,8 @@
--ll;
}
if (ll > 0) {
- auto [s, l] = mTimeMachine.dump(ll);
- ss << s;
+ auto [s, l] = mTimeMachine.dump(ll, sinceNs, prefix);
+ ss << std::move(s);
ll -= l;
}
return { ss.str(), lines - ll };