summaryrefslogtreecommitdiff
path: root/include/input/PrintTools.h
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2023-04-06 22:16:44 +0000
committer Prabir Pradhan <prabirmsp@google.com> 2023-05-22 16:39:16 +0000
commit852db897ff33b7a8243b1cc85587d37bce3ddfbe (patch)
tree6bddc6d69530215a17399b77bdc3a1f89168f6ca /include/input/PrintTools.h
parent3a549bba86c98521f93fc613f407caa0f6598625 (diff)
Log InputDeviceUsageReported atom from the new metrics collector
Bug: 275726706 Test: atest inputflinger_tests Test: statsd_testdrive Change-Id: I3da4beefe161891ca9188e70ff58114d46801902
Diffstat (limited to 'include/input/PrintTools.h')
-rw-r--r--include/input/PrintTools.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/input/PrintTools.h b/include/input/PrintTools.h
index 02bc2010db..0ca6fa30ce 100644
--- a/include/input/PrintTools.h
+++ b/include/input/PrintTools.h
@@ -88,6 +88,20 @@ std::string dumpMap(const std::map<K, V>& map, std::string (*keyToString)(const
}
/**
+ * Convert map keys to string. The keys of the map should be integral type.
+ */
+template <typename K, typename V>
+std::string dumpMapKeys(const std::map<K, V>& map,
+ std::string (*keyToString)(const K&) = constToString) {
+ std::string out;
+ for (const auto& [k, _] : map) {
+ out += out.empty() ? "{" : ", ";
+ out += keyToString(k);
+ }
+ return out.empty() ? "{}" : (out + "}");
+}
+
+/**
* Convert a vector to a string. The values of the vector should be of a type supported by
* constToString.
*/